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:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user