From 0c7cd96130ac30b0b03bb9b305008196d3dc1984 Mon Sep 17 00:00:00 2001 From: Chris Farhood Date: Sat, 16 May 2026 15:59:24 +0000 Subject: [PATCH] fix: resolve duplicate 'end' variable declaration in book.ts Using `let end` so the buffer-aware recalculation can reassign the variable rather than redeclaring it in a nested scope. Co-Authored-By: Paperclip --- apps/api/src/routes/book.ts | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/apps/api/src/routes/book.ts b/apps/api/src/routes/book.ts index 9a88a60..e020754 100644 --- a/apps/api/src/routes/book.ts +++ b/apps/api/src/routes/book.ts @@ -143,7 +143,7 @@ bookRouter.post( .where(and(eq(services.id, body.serviceId), eq(services.active, true))); if (!service) return c.json({ error: "Service not found" }, 404); - const end = new Date(start.getTime() + service.durationMinutes * 60_000); + let end = new Date(start.getTime() + service.durationMinutes * 60_000); // Find all active groomers const groomers = await db @@ -213,10 +213,9 @@ bookRouter.post( if (!pet) return c.json({ error: "Failed to create pet" }, 500); // Buffer-aware end time: large/x-large pets add service bufferMinutes - const extraBuffer = (body.petSizeCategory === "large" || body.petSizeCategory === "x-large") - ? (service.defaultBufferMinutes ?? 0) - : 0; - const end = new Date(start.getTime() + (service.durationMinutes + extraBuffer) * 60_000); + if (body.petSizeCategory === "large" || body.petSizeCategory === "x-large") { + end = new Date(start.getTime() + (service.durationMinutes + (service.defaultBufferMinutes ?? 0)) * 60_000); + } // Insert appointment in a transaction to guard against race conditions let appointment;