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

@@ -20,6 +20,7 @@ public static class StateEndpoints
var summary = new
{
CurrentPhase = phase,
player.VotesFinal,
state.ResultsOpen,
state.UpdatedAt,
Players = await db.Players.CountAsync(),
@@ -34,7 +35,7 @@ public static class StateEndpoints
var player = await EndpointHelpers.GetAuthenticatedPlayer(ctx, db);
if (player is null) return Results.Unauthorized();
var phase = await EndpointHelpers.GetPhase(db, player.Id);
return Results.Ok(new { player.Id, player.DisplayName, player.Username, player.IsAdmin, CurrentPhase = phase });
return Results.Ok(new { player.Id, player.DisplayName, player.Username, player.IsAdmin, CurrentPhase = phase, player.VotesFinal });
});
app.MapPost("/api/me/phase/next", async (HttpContext ctx, AppDbContext db, IConfiguration config) =>
@@ -52,6 +53,7 @@ public static class StateEndpoints
}
player.CurrentPhase = next;
player.VotesFinal = false; // moving forward clears any prior finalize
await db.SaveChangesAsync();
return Results.Ok(new { player.CurrentPhase, appState.ResultsOpen });
});
@@ -67,6 +69,7 @@ public static class StateEndpoints
}
player.CurrentPhase = PrevPhase(player.CurrentPhase);
player.VotesFinal = false;
await db.SaveChangesAsync();
var appState = await db.AppState.AsNoTracking().FirstAsync();
return Results.Ok(new { player.CurrentPhase, appState.ResultsOpen });