@page "/admin/clients/{ClientId:int}" @attribute [Authorize] @using TaxBaik.Application.Services @inject ClientService ClientService @inject ConsultationService ConsultationService @inject NavigationManager Navigation @inject IJSRuntime JS 고객 상세
Client Details

고객 상세

고객 정보와 상담 이력을 관리합니다.

@if (client == null) {
고객을 찾을 수 없습니다.
} else {
수정

고객 정보

이름@client.Name
상호@(client.CompanyName ?? "-")
연락처@(client.Phone ?? "-")
이메일@(client.Email ?? "-")
서비스@(client.ServiceType ?? "-")
사업자 유형@(client.TaxType ?? "-")
유입 경로@(client.Source ?? "-")
등록일@client.CreatedAt.ToLocalTime().ToString("yyyy-MM-dd")
@if (!string.IsNullOrWhiteSpace(client.Memo)) {
메모@client.Memo
}

상담 이력

@if (showAddForm) {
} @if (consultations.Count == 0) {

상담 이력이 없습니다.

} else {
@foreach (var c in consultations) {
@c.ConsultationDate.ToString("yyyy-MM-dd") @(string.IsNullOrEmpty(c.ServiceType) ? "" : $"· {c.ServiceType}")

@c.Summary

@if (!string.IsNullOrEmpty(c.Result)) { @c.Result } @if (c.Fee.HasValue) {
수임료: @c.Fee.Value.ToString("N0")원
}
}
}
} @code { [Parameter] public int ClientId { get; set; } private Domain.Entities.Client? client; private List consultations = []; private bool showAddForm; private DateTime? newDate = DateTime.Today; private string newServiceType = ""; private string newSummary = ""; private string newResult = ""; private decimal? newFee; private string ConsultationDateText { get => newDate?.ToString("yyyy-MM-dd") ?? ""; set => newDate = DateTime.TryParse(value, out var dt) ? dt : null; } private string FeeText { get => newFee?.ToString() ?? ""; set => newFee = decimal.TryParse(value, out var d) ? d : null; } protected override async Task OnInitializedAsync() => await LoadAll(); private async Task LoadAll() { client = await ClientService.GetByIdAsync(ClientId); consultations = (await ConsultationService.GetByClientIdAsync(ClientId)).ToList(); } private void OpenAddConsultation() { showAddForm = true; newDate = DateTime.Today; newServiceType = ""; newSummary = ""; newResult = ""; newFee = null; } private async Task AddConsultation() { try { if (string.IsNullOrWhiteSpace(newSummary)) { await JS.InvokeVoidAsync("alert", "상담 내용을 입력하세요."); return; } var c = new Domain.Entities.Consultation { ClientId = ClientId, ConsultationDate = newDate?.ToUniversalTime() ?? DateTime.UtcNow, ServiceType = string.IsNullOrWhiteSpace(newServiceType) ? null : newServiceType, Summary = newSummary, Result = string.IsNullOrWhiteSpace(newResult) ? null : newResult, Fee = newFee }; await ConsultationService.CreateAsync(c); showAddForm = false; consultations = (await ConsultationService.GetByClientIdAsync(ClientId)).ToList(); await JS.InvokeVoidAsync("alert", "상담이 추가되었습니다."); } catch (ValidationException ex) { await JS.InvokeVoidAsync("alert", ex.Message); } } private async Task DeleteConsultation(int id) { if (!await JS.InvokeAsync("confirm", "이 상담을 삭제하시겠습니까?")) return; await ConsultationService.DeleteAsync(id); consultations = (await ConsultationService.GetByClientIdAsync(ClientId)).ToList(); await JS.InvokeVoidAsync("alert", "삭제되었습니다."); } }