diff options
Diffstat (limited to 'app/src/lib/common/assignments.ts')
-rw-r--r-- | app/src/lib/common/assignments.ts | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/app/src/lib/common/assignments.ts b/app/src/lib/common/assignments.ts new file mode 100644 index 0000000..79553cd --- /dev/null +++ b/app/src/lib/common/assignments.ts @@ -0,0 +1,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") +} |