/** 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" ); }