Add votes-final flag, warn on missing votes, and sync phases with results toggle

This commit is contained in:
2026-02-04 22:54:36 +01:00
parent 91692856f9
commit 13c8bb6194
13 changed files with 318 additions and 6 deletions

View File

@@ -62,5 +62,18 @@ public static class VoteEndpoints
await db.SaveChangesAsync();
return Results.Ok(new { vote.Id, vote.Score });
});
app.MapPost("/api/votes/finalize", async ([FromBody] VoteFinalizeRequest request, HttpContext ctx, AppDbContext db) =>
{
var player = await EndpointHelpers.GetAuthenticatedPlayer(ctx, db);
if (player is null) return Results.Unauthorized();
var phase = await EndpointHelpers.GetPhase(db, player.Id);
if (phase != Phase.Vote)
return EndpointHelpers.PhaseMismatch(Phase.Vote, phase);
player.VotesFinal = request.Final;
await db.SaveChangesAsync();
return Results.Ok(new { player.VotesFinal });
});
}
}