summaryrefslogtreecommitdiff
path: root/app/src/lib/common/assignments.ts
blob: 79553cdc825064bd626478bd0aedb4bfc3759b4b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
/** A row from the `cemetary_plot` table. */
export interface CemetaryPlot {
	id: number;
	address: string;
	ownerId: number;
	//assignmentInterval: Date;
}

/** Corresponds to `assignment_state`. */
export type AssignmentState = "AWAITING_GARDENER_NOTIFICATION"
                            | "AWAITING_FINISH"
                            | "AWAITING_WATERMARKING"
                            | "AWAITING_OWNER_NOTIFICATION"
                            | "DONE"
			    ;

/** A row from the `assignments` table. */
export interface Assignment {
	id: number;
	gardenerId: number;
	cemetaryPlotId: number;
	date: Date;
	state: AssignmentState;
}


// FIXME: We have ORM at home. A more clearly defined (OOP) model layer.
/** Checks whether the state of the assignment allows it to be "finished". */
export function canBeFinished(assignment: Assignment): boolean {
	return (assignment.state === "AWAITING_GARDENER_NOTIFICATION" ||
		assignment.state === "AWAITING_FINISH")
}