From 976d0f89a3246f8876f414116c2eb63af308df08 Mon Sep 17 00:00:00 2001 From: Claude Date: Mon, 23 Feb 2026 01:20:11 +0000 Subject: [PATCH] Create timer when adding time to a team with no existing timer When a commissioner tries to add time to a team that has no draft timer, instead of returning a 404 error, create a new timer record with the specified amount of time. Removing time still returns a 404 if no timer exists (nothing to remove from). https://claude.ai/code/session_016VpJKZZFNQQqzfmLu8pHoc --- app/routes/api/draft.adjust-time-bank.ts | 25 ++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/app/routes/api/draft.adjust-time-bank.ts b/app/routes/api/draft.adjust-time-bank.ts index 9109fbd..78246e9 100644 --- a/app/routes/api/draft.adjust-time-bank.ts +++ b/app/routes/api/draft.adjust-time-bank.ts @@ -61,17 +61,26 @@ export async function action(args: any) { ) ); + let newTime: number; + if (!currentTimer) { - return Response.json({ error: "Timer not found for this team" }, { status: 404 }); + if (adjustment <= 0) { + return Response.json({ error: "Timer not found for this team" }, { status: 404 }); + } + newTime = adjustment; + await db.insert(schema.draftTimers).values({ + seasonId, + teamId, + timeRemaining: newTime, + }); + } else { + newTime = Math.max(0, currentTimer.timeRemaining + adjustment); + await db + .update(schema.draftTimers) + .set({ timeRemaining: newTime, updatedAt: new Date() }) + .where(eq(schema.draftTimers.id, currentTimer.id)); } - const newTime = Math.max(0, currentTimer.timeRemaining + adjustment); - - await db - .update(schema.draftTimers) - .set({ timeRemaining: newTime, updatedAt: new Date() }) - .where(eq(schema.draftTimers.id, currentTimer.id)); - try { getSocketIO() .to(`draft-${seasonId}`)