@page "/admin/clients" @attribute [Authorize] @using TaxBaik.Web.Services @using TaxBaik.Domain.Entities @inject IClientBrowserClient ClientClient @inject NavigationManager Navigation @inject IJSRuntime JS 고객 관리
CRM

고객 관리

고객 카드를 등록하고 상담 이력을 관리합니다.

@if (clients is null) { } else if (!clients.Any()) {
등록된 고객이 없습니다.
} else {
@foreach (var c in clients) { }
이름 회사명 연락처 서비스 세금 유형 상태 유입 경로 등록일
@c.Name @(c.CompanyName ?? "—") @(c.Phone ?? "—") @(c.ServiceType ?? "—") @(c.TaxType ?? "—") @(c.Status == "active" ? "활성" : "비활성") @(c.Source ?? "—") @c.CreatedAt.ToLocalTime().ToString("yy.MM.dd")
@if (totalPages > 1) {
@currentPage / @totalPages
} }
@code { [CascadingParameter] private Task? AuthStateTask { get; set; } private List? clients; private string searchText = ""; private string statusFilter = ""; private int currentPage = 1; private int totalCount; private int totalPages; private const int PageSize = 20; protected override async Task OnAfterRenderAsync(bool firstRender) { if (firstRender && AuthStateTask != null) { var authState = await AuthStateTask; if (authState.User.Identity?.IsAuthenticated == true) { await LoadAsync(); StateHasChanged(); } } } 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) { await JS.InvokeVoidAsync("alert", $"오류: {ex.Message}"); clients = []; } } private async Task SearchAsync() { currentPage = 1; await LoadAsync(); } private async Task ResetAsync() { searchText = ""; statusFilter = ""; currentPage = 1; await LoadAsync(); } private async Task PreviousPage() { if (currentPage > 1) { currentPage--; await LoadAsync(); } } private async Task NextPage() { if (currentPage < totalPages) { currentPage++; await LoadAsync(); } } private async Task OnSearchKeyUp(KeyboardEventArgs e) { if (e.Key == "Enter") await SearchAsync(); } private async Task DeleteAsync(Client client) { var confirmed = await JS.InvokeAsync("confirm", $"'{client.Name}' 고객을 삭제하시겠습니까? 관련 데이터도 함께 삭제됩니다."); if (!confirmed) return; try { var success = await ClientClient.DeleteAsync(client.Id); if (success) { await JS.InvokeVoidAsync("alert", $"{client.Name} 고객이 삭제되었습니다."); await LoadAsync(); } } catch (Exception ex) { await JS.InvokeVoidAsync("alert", $"오류: {ex.Message}"); } } }