From 252832d0817689d247c22dda359eca379b5e2288 Mon Sep 17 00:00:00 2001 From: Flea Flicker Date: Fri, 27 Mar 2026 09:42:26 +0000 Subject: [PATCH] fix(gro-48): use staffRow?.role for consistency with clients.ts/pets.ts QAP-125 noted appointments.ts uses staffRow.role (unsafe) while clients.ts/pets.ts use staffRow?.role (safe). This inconsistency can cause runtime errors when staff context is missing. Fixed by using the safe optional-chain form consistently in both GET handlers. Co-Authored-By: Paperclip --- apps/api/src/routes/appointments.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/apps/api/src/routes/appointments.ts b/apps/api/src/routes/appointments.ts index 59723f2..c693325 100644 --- a/apps/api/src/routes/appointments.ts +++ b/apps/api/src/routes/appointments.ts @@ -73,7 +73,7 @@ appointmentsRouter.get("/", async (c) => { const to = c.req.query("to"); const staffId = c.req.query("staffId"); const staffRow = c.get("staff"); - const isGroomer = staffRow.role === "groomer"; + const isGroomer = staffRow?.role === "groomer"; const conditions = []; if (from) conditions.push(gte(appointments.startTime, new Date(from))); @@ -108,7 +108,7 @@ appointmentsRouter.get("/", async (c) => { appointmentsRouter.get("/:id", async (c) => { const db = getDb(); const staffRow = c.get("staff"); - const isGroomer = staffRow.role === "groomer"; + const isGroomer = staffRow?.role === "groomer"; const [row] = await db .select() .from(appointments)