Add per-user phase navigation with results toggle
This commit is contained in:
@@ -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
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user