From f7a6244cc1a8f39ad44186a4da6b743ab6821d51 Mon Sep 17 00:00:00 2001 From: Linnnus Date: Wed, 19 Feb 2025 18:37:33 +0100 Subject: Add assignment submission --- app/src/lib/common/assignments.ts | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 app/src/lib/common/assignments.ts (limited to 'app/src/lib/common') 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") +} -- cgit v1.2.3