Add per-user phase navigation with results toggle

This commit is contained in:
2026-02-04 21:43:12 +01:00
parent b64a33d833
commit e5e27af0af
24 changed files with 507 additions and 88 deletions

View File

@@ -18,14 +18,14 @@ internal static class EndpointHelpers
return existing;
}
public static async Task<Phase> GetPhase(AppDbContext db)
public static async Task<Phase> GetPhase(AppDbContext db, Guid playerId)
{
var state = await db.AppState.AsNoTracking().FirstAsync();
return state.CurrentPhase;
var player = await db.Players.AsNoTracking().FirstOrDefaultAsync(p => p.Id == playerId);
return player?.CurrentPhase ?? Phase.Suggest;
}
public static IResult PhaseMismatch(Phase required, Phase current) =>
Results.BadRequest(new { error = $"This endpoint is available in the {required} phase. Current phase is {current}." });
Results.BadRequest(new { error = $"This endpoint is available in the {required} phase. Your current phase is {current}." });
public static string? TrimTo(string? input, int max) =>
string.IsNullOrWhiteSpace(input)
@@ -138,7 +138,7 @@ internal static class EndpointHelpers
public static AppState NewAppState() => new()
{
Id = 1,
CurrentPhase = Phase.Suggest,
ResultsOpen = false,
UpdatedAt = DateTimeOffset.UnixEpoch
};
}