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
This commit is contained in:
parent
a3ec556ecc
commit
976d0f89a3
1 changed files with 17 additions and 8 deletions
|
|
@ -61,16 +61,25 @@ export async function action(args: any) {
|
|||
)
|
||||
);
|
||||
|
||||
let newTime: number;
|
||||
|
||||
if (!currentTimer) {
|
||||
if (adjustment <= 0) {
|
||||
return Response.json({ error: "Timer not found for this team" }, { status: 404 });
|
||||
}
|
||||
|
||||
const newTime = Math.max(0, currentTimer.timeRemaining + adjustment);
|
||||
|
||||
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));
|
||||
}
|
||||
|
||||
try {
|
||||
getSocketIO()
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue