Files
taxbaik/TaxBaik.Web.Client/Components/Admin/Pages/Clients/ClientList.razor
T
kjh2064 e5981769b9
TaxBaik CI/CD / build-and-deploy (push) Successful in 2m11s
fix: per-page WASM render mode, Contact checkbox binding, Telegram inquiry channel
- Admin: replace the global @rendermode on <Routes>/<Router> with per-page
  render mode. Login.razor now prerenders (form visible before WASM loads);
  every other [Authorize] page stays prerender: false to avoid the
  AuthorizeRouteView blank-render regression from earlier attempts. Adds a
  "준비 중" -> "로그인" splash tied to WASM boot completion, and lets the
  authenticated-shell loading overlay stay up until AdminShell actually renders.
- Contact.cshtml: fix the "Agree" checkbox missing value="true" - a checked
  box sent the browser-default "on", which bool model binding can't parse,
  so ModelState.IsValid silently went false and OnPostAsync returned a blank
  form with no visible error on every submission. Validation summary widened
  from ModelOnly to All so this class of failure isn't silent again.
- TelegramInquiryNotificationService: read Telegram:InquiryChatId (falling
  back to ChatId) instead of only ChatId, matching the channel routing
  CLAUDE.md documents and deploy.yml already provisions as separate secrets.
- Reconcile CLAUDE.md's self-contradicting Phase 8 prerender notes (Phase 9),
  rewrite validate_admin_render.sh for the per-page design, and add a
  SmartAdmin 5.5 design reference section to DOUZONE_UX_GUIDE.md for future
  admin screens (existing screens unchanged, tracked as WBS P4-03).

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-07-03 10:15:27 +09:00

229 lines
7.8 KiB
Plaintext

@page "/admin/clients"
@rendermode @(new InteractiveWebAssemblyRenderMode(prerender: false))
@attribute [Authorize]
@using TaxBaik.Web.Services
@using TaxBaik.Domain.Entities
@inject IClientBrowserClient ClientClient
@inject NavigationManager Navigation
@inject IDialogService DialogService
@inject ISnackbar Snackbar
<PageTitle>고객 관리</PageTitle>
<AdminPageHeader Title="고객 관리" Eyebrow="CRM" Subtitle="고객 카드를 등록하고 상담 이력을 관리합니다.">
<ChildContent>
<MudButton Variant="Variant.Filled" Color="Color.Primary"
StartIcon="@Icons.Material.Filled.PersonAdd"
Href="/taxbaik/admin/clients/create">
고객 등록
</MudButton>
</ChildContent>
</AdminPageHeader>
@* 검색/필터 바 *@
<MudPaper Class="admin-surface mb-3 pa-3" Elevation="0">
<MudGrid>
<MudItem xs="12" md="5">
<MudTextField @bind-Value="searchText" Label="검색 (이름·연락처·회사명)"
Adornment="Adornment.End" AdornmentIcon="@Icons.Material.Filled.Search"
Immediate="false" OnKeyUp="@OnSearchKeyUp" />
</MudItem>
<MudItem xs="12" md="3">
<CommonCodeSelect @bind-Value="statusFilter" Group="CLIENT_STATUS" Label="상태" Placeholder="전체" Clearable="true" />
</MudItem>
<MudItem xs="12" md="2" Class="d-flex align-center">
<MudButton Variant="Variant.Outlined" OnClick="@SearchAsync" FullWidth="true">검색</MudButton>
</MudItem>
<MudItem xs="12" md="2" Class="d-flex align-center">
<MudButton Variant="Variant.Text" OnClick="@ResetAsync" FullWidth="true">초기화</MudButton>
</MudItem>
</MudGrid>
</MudPaper>
<AdminDataPanel Loading="@(clients is null)" SkeletonContent="@ClientListSkeleton">
@if (clients is null)
{
}
else if (!clients.Any())
{
<AdminEmptyState Icon="@Icons.Material.Filled.PeopleAlt" Message="등록된 고객이 없습니다." />
}
else
{
<MudSimpleTable Striped="true" Dense="true" Class="admin-table">
<thead>
<tr>
<th>이름</th>
<th>회사명</th>
<th>연락처</th>
<th>서비스</th>
<th>세금 유형</th>
<th>상태</th>
<th>유입 경로</th>
<th>등록일</th>
<th></th>
</tr>
</thead>
<tbody>
@foreach (var c in clients)
{
<tr>
<td><strong>@c.Name</strong></td>
<td>@(c.CompanyName ?? "—")</td>
<td>@(c.Phone ?? "—")</td>
<td>
@if (!string.IsNullOrEmpty(c.ServiceType))
{
<MudChip Size="Size.Small" Color="Color.Primary">@c.ServiceType</MudChip>
}
</td>
<td>@(c.TaxType ?? "—")</td>
<td>
@if (c.Status == "active")
{
<MudChip Size="Size.Small" Color="Color.Success">활성</MudChip>
}
else
{
<MudChip Size="Size.Small" Color="Color.Default">비활성</MudChip>
}
</td>
<td>@(c.Source ?? "—")</td>
<td class="small">@c.CreatedAt.ToLocalTime().ToString("yy.MM.dd")</td>
<td>
<MudButtonGroup Size="Size.Small" Variant="Variant.Outlined">
<MudButton @onclick="@(() => Navigation.NavigateTo($"/taxbaik/admin/clients/{c.Id}/edit"))">
수정
</MudButton>
<MudButton Color="Color.Error" @onclick="@(() => DeleteAsync(c))">
삭제
</MudButton>
</MudButtonGroup>
</td>
</tr>
}
</tbody>
</MudSimpleTable>
@* 페이징 *@
@if (totalPages > 1)
{
<div class="d-flex justify-center pa-3">
<MudPagination BoundaryCount="1" MiddleCount="3"
Count="@totalPages" Selected="@currentPage"
SelectedChanged="@OnPageChanged" />
</div>
}
<MudText Typo="Typo.caption" Class="pa-2 text-muted">총 @(totalCount)명</MudText>
}
</AdminDataPanel>
@code {
[CascadingParameter]
private Task<AuthenticationState>? AuthStateTask { get; set; }
private List<Client>? clients;
private string searchText = "";
private string statusFilter = "";
private int currentPage = 1;
private int totalCount;
private int totalPages;
private const int PageSize = 20;
private RenderFragment ClientListSkeleton => builder =>
{
builder.OpenComponent<AdminSkeletonRows>(0);
builder.AddAttribute(1, "Rows", 5);
builder.AddAttribute(2, "Columns", 5);
builder.CloseComponent();
};
protected override async Task OnInitializedAsync()
{
if (AuthStateTask != null)
{
var authState = await AuthStateTask;
if (authState.User.Identity?.IsAuthenticated == true)
{
await LoadAsync();
}
}
}
private async Task LoadAsync()
{
try
{
var (items, total) = await ClientClient.GetPagedAsync(
currentPage, PageSize,
string.IsNullOrEmpty(statusFilter) ? null : statusFilter,
string.IsNullOrEmpty(searchText) ? null : searchText);
clients = items.ToList();
totalCount = total;
totalPages = (int)Math.Ceiling((double)total / PageSize);
}
catch (Exception ex)
{
Snackbar.Add($"오류: {ex.Message}", Severity.Error);
clients = [];
totalCount = 0;
totalPages = 0;
}
}
private async Task SearchAsync()
{
currentPage = 1;
await LoadAsync();
}
private async Task ResetAsync()
{
searchText = "";
statusFilter = "";
currentPage = 1;
await LoadAsync();
}
private async Task OnPageChanged(int page)
{
currentPage = page;
await LoadAsync();
}
private async Task OnSearchKeyUp(KeyboardEventArgs e)
{
if (e.Key == "Enter") await SearchAsync();
}
private async Task DeleteAsync(Client client)
{
var confirmed = await DialogService.ShowMessageBox(
"고객 삭제",
$"'{client.Name}' 고객을 삭제하시겠습니까? 관련 데이터도 함께 삭제됩니다.",
yesText: "삭제", cancelText: "취소");
if (confirmed != true) return;
try
{
var success = await ClientClient.DeleteAsync(client.Id);
if (success)
{
Snackbar.Add($"{client.Name} 고객이 삭제되었습니다.", Severity.Success);
await LoadAsync();
}
else
{
Snackbar.Add("삭제에 실패했습니다.", Severity.Error);
}
}
catch (Exception ex)
{
Snackbar.Add($"오류: {ex.Message}", Severity.Error);
}
await LoadAsync();
}
}