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 <noreply@paperclip.ing>
This commit is contained in:
Flea Flicker
2026-03-27 09:42:26 +00:00
parent 3c21807b3d
commit 252832d081
+2 -2
View File
@@ -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)