Files
sor/Server/src/SOR.Admin/Components/Pages/Bazaar/CosmeticsPage.razor
T
58c5778bfb Remove stale per-page Authorize(Roles) attributes
All 26 pages had @attribute [Authorize(Roles = "Admin,SuperAdmin")] which
conflicts with the Keycloak role sor-admin. The fallback policy in Program.cs
already enforces RequireRole("sor-admin") globally, making these attributes
redundant. Removing them fixes Access Denied for all admin pages.

Generated with [Claude Code](https://claude.ai/code)
via [Happy](https://happy.engineering)

Co-Authored-By: Claude <noreply@anthropic.com>
Co-Authored-By: Happy <yesreply@happy.engineering>
2026-04-04 14:00:03 -04:00

121 lines
4.1 KiB
Plaintext
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
@page "/bazaar/cosmetics"
@using Microsoft.EntityFrameworkCore
@using SOR.Database.Contexts
@using SOR.Database.Enums
@inject BazaarDbContext Db
@inject NavigationManager Nav
<PageTitle>Cosmetics – SOR Admin</PageTitle>
<div class="d-flex justify-content-between align-items-center mb-4">
<h1 class="mb-0">Cosmetics</h1>
<a href="/bazaar/cosmetics/new" class="btn btn-primary">
<i class="bi bi-plus-lg me-1"></i>New Cosmetic
</a>
</div>
@if (_loading)
{
<p class="text-muted">Loading…</p>
}
else
{
<div class="card shadow-sm">
<div class="card-body p-0">
<table class="table table-sm table-hover mb-0">
<thead class="table-light">
<tr>
<th>Name</th>
<th>Type</th>
<th>Card</th>
<th class="text-end">OP Price</th>
<th class="text-end">USD</th>
<th>Status</th>
<th></th>
</tr>
</thead>
<tbody>
@foreach (var c in _cosmetics)
{
<tr>
<td class="fw-medium">@c.Name</td>
<td>
<span class="badge @TypeBadge(c.Type)">@c.Type</span>
</td>
<td class="text-muted small">@(c.CardName ?? "—")</td>
<td class="text-end">@c.OriginPointPrice.ToString("N0")</td>
<td class="text-end text-muted small">
@(c.UsdPrice.HasValue ? $"${c.UsdPrice:F2}" : "—")
</td>
<td>
@if (c.IsActive)
{
<span class="badge bg-success">Active</span>
}
else
{
<span class="badge bg-secondary">Inactive</span>
}
</td>
<td>
<a href="/bazaar/cosmetics/@c.Id"
class="btn btn-sm btn-outline-secondary">
<i class="bi bi-pencil"></i>
</a>
</td>
</tr>
}
@if (!_cosmetics.Any())
{
<tr>
<td colspan="7" class="text-muted text-center py-3">
No cosmetics yet. <a href="/bazaar/cosmetics/new">Create one.</a>
</td>
</tr>
}
</tbody>
</table>
</div>
</div>
}
@code {
private bool _loading = true;
private record CosmeticRow(
Guid Id,
string Name,
string Type,
string? CardName,
int OriginPointPrice,
decimal? UsdPrice,
bool IsActive);
private List<CosmeticRow> _cosmetics = new();
protected override async Task OnInitializedAsync()
{
_cosmetics = await Db.Cosmetics
.OrderBy(c => c.CosmeticType)
.ThenBy(c => c.Name)
.Select(c => new CosmeticRow(
c.Id,
c.Name,
c.CosmeticType.ToString(),
null,
c.OriginPointPrice,
c.UsdPrice,
c.IsActive))
.ToListAsync();
_loading = false;
}
private static string TypeBadge(string type) => type switch
{
nameof(CosmeticType.CardBack) => "bg-info text-dark",
nameof(CosmeticType.AlternateCardArt) => "bg-primary",
nameof(CosmeticType.AlternateCardModel) => "bg-warning text-dark",
_ => "bg-secondary",
};
}