Allow deleting own suggestions in Suggest phase and surface delete chip

This commit is contained in:
2026-01-28 16:58:18 +01:00
parent e6b341d837
commit 3ec1808ad1
3 changed files with 35 additions and 2 deletions

View File

@@ -205,6 +205,22 @@ api.MapPost("/suggestions", async ([FromBody] SuggestionRequest request, HttpCon
return Results.Created($"/api/suggestions/{suggestion.Id}", new { suggestion.Id });
});
api.MapDelete("/suggestions/{id:int}", async (int id, HttpContext ctx, AppDbContext db) =>
{
var phase = await GetPhase(db);
if (phase != Phase.Suggest)
return PhaseMismatch(Phase.Suggest, phase);
var player = await GetOrCreatePlayer(ctx, db);
var suggestion = await db.Suggestions.FirstOrDefaultAsync(s => s.Id == id && s.PlayerId == player.Id);
if (suggestion == null)
return Results.NotFound(new { error = "Suggestion not found." });
db.Suggestions.Remove(suggestion);
await db.SaveChangesAsync();
return Results.NoContent();
});
api.MapGet("/suggestions/all", async (AppDbContext db) =>
{
var phase = await GetPhase(db);