0334a5f607
TaxBaik CI/CD / build-and-deploy (push) Successful in 1m19s
**Implementation:** - AdminDashboardClient: HTTP API client interface - GetSummaryAsync: Fetch dashboard metrics - GetUpcomingFilingsAsync: 30-day filings forecast - GetRecentInquiriesAsync: Latest inquiries - GetMonthlyStatsAsync: Monthly statistics - Program.cs: Register IAdminDashboardClient - Dashboard.razor: Replace service injection with API client - Remove: Direct AdminDashboardService/TaxFilingService injection - Add: IAdminDashboardClient injection - Add: Error handling & loading state - Change: OnInitializedAsync() calls API endpoints **SOLID Principles Applied:** ✓ D (Dependency Inversion): Blazor depends on IAdminDashboardClient abstraction ✓ S (Single Responsibility): Client handles only HTTP communication ✓ O (Open/Closed): Can extend API without changing Blazor component **Architecture Pattern:** - Before: Blazor → Service (server-side logic) → Repository → DB - After: Blazor → HTTP → API → Service → Repository → DB **Benefits:** - Clear separation of concerns - Easier to test (mock HTTP) - Foundation for token refresh middleware - Prepare for SignalR integration Status: Ready for Phase 5 (JWT token refresh) Next: Implement automatic token refresh on 401 responses Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
201 lines
9.2 KiB
Plaintext
201 lines
9.2 KiB
Plaintext
@page "/admin/dashboard"
|
|
@attribute [Authorize]
|
|
@using TaxBaik.Web.Services
|
|
@inject IAdminDashboardClient DashboardClient
|
|
@inject NavigationManager Nav
|
|
|
|
<PageTitle>대시보드</PageTitle>
|
|
|
|
<section class="admin-page-hero">
|
|
<div>
|
|
<MudText Typo="Typo.caption" Class="admin-eyebrow">Overview</MudText>
|
|
<MudText Typo="Typo.h4" Class="admin-page-title">대시보드</MudText>
|
|
<MudText Typo="Typo.body2" Class="admin-page-subtitle">문의 흐름과 콘텐츠 상태를 한 화면에서 확인합니다.</MudText>
|
|
</div>
|
|
<MudButton Variant="Variant.Filled" Color="Color.Primary" StartIcon="@Icons.Material.Filled.Add" Href="/taxbaik/admin/blog/create">
|
|
새 포스트 작성
|
|
</MudButton>
|
|
</section>
|
|
|
|
<!-- Metrics Grid - Pure HTML div instead of MudGrid to ensure proper layout -->
|
|
<div class="admin-metric-grid">
|
|
<div class="admin-metric-card accent-blue cursor-pointer" @onclick='(() => Nav.NavigateTo("/taxbaik/admin/inquiries"))' style="cursor: pointer;">
|
|
<div style="display: flex; flex-direction: column; gap: 12px; height: 100%;">
|
|
<span style="font-size: 0.75rem; color: #999; text-transform: uppercase; font-weight: 600;">이번달 문의</span>
|
|
<div style="display: flex; justify-content: space-between; align-items: center; flex: 1;">
|
|
<span style="font-size: 2rem; font-weight: 700; color: #1565c0;">@summary.ThisMonthInquiries</span>
|
|
<span style="font-size: 2.5rem; opacity: 0.15; color: #1976d2;">💬</span>
|
|
</div>
|
|
<span style="font-size: 0.9rem; color: #666;">월간 상담 유입 (클릭 시 이동)</span>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="admin-metric-card accent-amber cursor-pointer" @onclick='(() => Nav.NavigateTo("/taxbaik/admin/inquiries?status=new"))' style="cursor: pointer;">
|
|
<div style="display: flex; flex-direction: column; gap: 12px; height: 100%;">
|
|
<span style="font-size: 0.75rem; color: #999; text-transform: uppercase; font-weight: 600;">신규 문의</span>
|
|
<div style="display: flex; justify-content: space-between; align-items: center; flex: 1;">
|
|
<span style="font-size: 2rem; font-weight: 700; color: #e65100;">@summary.NewInquiries</span>
|
|
<span style="font-size: 2.5rem; opacity: 0.15; color: #f57c00;">⚠️</span>
|
|
</div>
|
|
<span style="font-size: 0.9rem; color: #666;">처리 대기 (클릭 시 이동)</span>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="admin-metric-card accent-slate cursor-pointer" @onclick='(() => Nav.NavigateTo("/taxbaik/admin/blog"))' style="cursor: pointer;">
|
|
<div style="display: flex; flex-direction: column; gap: 12px; height: 100%;">
|
|
<span style="font-size: 0.75rem; color: #999; text-transform: uppercase; font-weight: 600;">전체 포스트</span>
|
|
<div style="display: flex; justify-content: space-between; align-items: center; flex: 1;">
|
|
<span style="font-size: 2rem; font-weight: 700; color: #455a64;">@summary.TotalPosts</span>
|
|
<span style="font-size: 2.5rem; opacity: 0.15; color: #607d8b;">📄</span>
|
|
</div>
|
|
<span style="font-size: 0.9rem; color: #666;">콘텐츠 자산 (클릭 시 이동)</span>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="admin-metric-card accent-green cursor-pointer" @onclick='(() => Nav.NavigateTo("/taxbaik/admin/blog"))' style="cursor: pointer;">
|
|
<div style="display: flex; flex-direction: column; gap: 12px; height: 100%;">
|
|
<span style="font-size: 0.75rem; color: #999; text-transform: uppercase; font-weight: 600;">발행된 포스트</span>
|
|
<div style="display: flex; justify-content: space-between; align-items: center; flex: 1;">
|
|
<span style="font-size: 2rem; font-weight: 700; color: #2e7d32;">@summary.PublishedPosts</span>
|
|
<span style="font-size: 2.5rem; opacity: 0.15; color: #388e3c;">🌐</span>
|
|
</div>
|
|
<span style="font-size: 0.9rem; color: #666;">검색 노출 대상 (클릭 시 이동)</span>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
@if (upcomingFilings.Count > 0)
|
|
{
|
|
<MudPaper Class="admin-surface mt-4" Elevation="0">
|
|
<div class="admin-section-header">
|
|
<div>
|
|
<MudText Typo="Typo.h6">이번 달 마감 임박 신고</MudText>
|
|
<MudText Typo="Typo.body2">30일 이내 신고 예정 건 (고객명 클릭 시 상세 카드로 연결)</MudText>
|
|
</div>
|
|
<MudButton Variant="Variant.Outlined" Color="Color.Primary" Href="/taxbaik/admin/tax-filings">전체 일정 보기</MudButton>
|
|
</div>
|
|
<MudSimpleTable Striped="true" Dense="true" Class="admin-table">
|
|
<thead>
|
|
<tr>
|
|
<th>고객</th>
|
|
<th>신고 유형</th>
|
|
<th>기한</th>
|
|
<th>D-day</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
@foreach (var f in upcomingFilings)
|
|
{
|
|
var dday = (f.DueDate.Date - DateTime.Today).Days;
|
|
<tr>
|
|
<td>
|
|
<MudLink Href="@($"/taxbaik/admin/clients/{f.ClientId}")" Underline="Underline.Hover" Color="Color.Primary" Class="font-weight-bold">
|
|
@f.ClientName
|
|
</MudLink>
|
|
</td>
|
|
<td>@f.FilingType</td>
|
|
<td>@f.DueDate.ToString("yyyy-MM-dd")</td>
|
|
<td>
|
|
@if (dday < 0)
|
|
{
|
|
<MudChip T="string" Size="Size.Small" Color="Color.Dark">기한 초과 (@(-dday)일)</MudChip>
|
|
}
|
|
else if (dday <= 7)
|
|
{
|
|
<MudChip T="string" Size="Size.Small" Color="Color.Error">D-@dday</MudChip>
|
|
}
|
|
else
|
|
{
|
|
<span>D-@dday</span>
|
|
}
|
|
</td>
|
|
</tr>
|
|
}
|
|
</tbody>
|
|
</MudSimpleTable>
|
|
</MudPaper>
|
|
}
|
|
|
|
<MudPaper Class="admin-surface mt-4" Elevation="0">
|
|
<div class="admin-section-header">
|
|
<div>
|
|
<MudText Typo="Typo.h6">최근 문의</MudText>
|
|
<MudText Typo="Typo.body2">최근 유입된 상담 요청을 빠르게 확인합니다. (이름 클릭 시 상세 관리 화면으로 연계)</MudText>
|
|
</div>
|
|
<MudButton Variant="Variant.Outlined" Color="Color.Primary" Href="/taxbaik/admin/inquiries">문의 전체 보기</MudButton>
|
|
</div>
|
|
<MudSimpleTable Striped="true" Dense="true" Class="admin-table">
|
|
<thead>
|
|
<tr>
|
|
<th>이름</th>
|
|
<th>전화</th>
|
|
<th>분야</th>
|
|
<th>상태</th>
|
|
<th>날짜</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
@foreach (var inquiry in summary.RecentInquiries)
|
|
{
|
|
<tr>
|
|
<td>
|
|
<MudLink Href="@($"/taxbaik/admin/inquiries?id={inquiry.Id}")" Underline="Underline.Hover" Color="Color.Primary" Class="font-weight-bold">
|
|
@inquiry.Name
|
|
</MudLink>
|
|
</td>
|
|
<td>@inquiry.Phone</td>
|
|
<td>@inquiry.ServiceType</td>
|
|
<td>
|
|
<MudChip T="string" Size="Size.Small" Color="@StatusColor(inquiry.Status)">
|
|
@GetStatusLabel(inquiry.Status)
|
|
</MudChip>
|
|
</td>
|
|
<td>@inquiry.CreatedAt.ToString("yyyy-MM-dd")</td>
|
|
</tr>
|
|
}
|
|
</tbody>
|
|
</MudSimpleTable>
|
|
</MudPaper>
|
|
|
|
@code {
|
|
private AdminDashboardSummary summary = new(0, 0, 0, 0, []);
|
|
private List<Domain.Entities.TaxFiling> upcomingFilings = [];
|
|
private string? errorMessage;
|
|
private bool isLoading = true;
|
|
|
|
protected override async Task OnInitializedAsync()
|
|
{
|
|
try
|
|
{
|
|
// API 클라이언트 사용 (서비스 직접 호출 X)
|
|
var summaryTask = DashboardClient.GetSummaryAsync();
|
|
var filingsTask = DashboardClient.GetUpcomingFilingsAsync(30);
|
|
|
|
await Task.WhenAll(summaryTask, filingsTask);
|
|
summary = await summaryTask;
|
|
upcomingFilings = (await filingsTask).ToList();
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
errorMessage = "대시보드 데이터를 불러올 수 없습니다.";
|
|
Console.Error.WriteLine($"Dashboard error: {ex.Message}");
|
|
}
|
|
finally
|
|
{
|
|
isLoading = false;
|
|
}
|
|
}
|
|
|
|
private static string GetStatusLabel(string status) => InquiryStatusMapper.Labels.GetValueOrDefault(status, status);
|
|
|
|
private static Color StatusColor(string status) => status switch
|
|
{
|
|
"new" => Color.Warning,
|
|
"consulting" => Color.Info,
|
|
"contracted" => Color.Success,
|
|
"rejected" => Color.Error,
|
|
"closed" => Color.Dark,
|
|
_ => Color.Default
|
|
};
|
|
}
|