refactor: complete WebAssembly migration - proper architecture
TaxBaik CI/CD / build-and-deploy (push) Failing after 2m17s

Phase 8: Complete WebAssembly 렌더 모드 전환 (정공법)

Migration Summary:
- ALL Admin components → TaxBaik.Web.Client
- Routes.razor, Pages/*, Layout/*, Shared/*, Forms/*
- App.razor → TaxBaik.WasmClient (호스트 컴포넌트)
- Shared utilities → TaxBaik.Application.Utils

Architecture:
 App.razor: TaxBaik.WasmClient (WebAssembly, 호스트)
 Routes + Pages: TaxBaik.WasmClient (WebAssembly)
 Layout + Shared + Forms: TaxBaik.WasmClient (WebAssembly)
 Services: TaxBaik.Web (API-First)

Key Changes:
- Namespaces: TaxBaik.Web.Components.Admin → TaxBaik.WasmClient.Components.Admin
- Shared utilities: TaxBaik.Application.Utils (single source of truth)
- Program.cs: MapRazorComponents<TaxBaik.WasmClient.Components.Admin.App>()
- _Imports.razor: Components/Admin 폴더에 재구성

Build Status:  0 errors, 0 warnings

Benefits:
- Stateless server (no Circuit memory)
- Client-side rendering (WebAssembly)
- Unlimited concurrent users (horizontal scaling)
- ERP-ready architecture

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
This commit is contained in:
2026-07-03 01:03:51 +09:00
parent 76446ee0f0
commit 8202c3278b
63 changed files with 41 additions and 30 deletions
@@ -0,0 +1,10 @@
@page "/admin"
@attribute [Authorize]
@inject NavigationManager NavigationManager
@code {
protected override void OnInitialized()
{
NavigationManager.NavigateTo("/taxbaik/admin/dashboard", replace: true);
}
}
@@ -0,0 +1,176 @@
@page "/admin/announcements/create"
@page "/admin/announcements/{Id:int}/edit"
@attribute [Authorize]
@using TaxBaik.Application.DTOs
@using TaxBaik.Web.Services
@using TaxBaik.WasmClient.Components.Admin.Shared
@inject IAnnouncementBrowserClient AnnouncementClient
@inject NavigationManager Navigation
@inject ISnackbar Snackbar
<PageTitle>@(Id.HasValue ? "공지 수정" : "공지 등록")</PageTitle>
<section class="admin-page-hero">
<div>
<MudText Typo="Typo.caption" Class="admin-eyebrow">Homepage</MudText>
<MudText Typo="Typo.h4" Class="admin-page-title">@(Id.HasValue ? "공지 수정" : "공지 등록")</MudText>
</div>
</section>
<MudPaper Class="admin-surface" Elevation="0">
<MudForm @ref="form">
<MudGrid>
<MudItem xs="12">
<MudTextField @bind-Value="model.Title"
Label="제목"
Variant="Variant.Outlined"
Required="true"
RequiredError="제목을 입력하세요."
HelperText="홈페이지 상단 공지 바에 표시되는 텍스트입니다." />
</MudItem>
<MudItem xs="12">
<MudTextField @bind-Value="model.Content"
Label="상세 내용 (선택)"
Variant="Variant.Outlined"
Lines="3"
HelperText="부가 설명이 있을 경우 입력합니다. 없으면 제목만 표시됩니다." />
</MudItem>
<MudItem xs="12" sm="6">
<CommonCodeSelect @bind-Value="model.DisplayType"
Group="ANNOUNCEMENT_DISPLAY_TYPE"
Label="유형"
Class="mb-0" />
</MudItem>
<MudItem xs="12" sm="6">
<MudNumericField @bind-Value="model.SortOrder"
Label="노출 순서"
Variant="Variant.Outlined"
HelperText="숫자가 클수록 먼저 표시됩니다." />
</MudItem>
<MudItem xs="12" sm="6">
<MudDatePicker @bind-Date="startsAtDate"
Label="게시 시작일 (비우면 즉시)"
Variant="Variant.Outlined"
DateFormat="yyyy-MM-dd"
Clearable="true" />
</MudItem>
<MudItem xs="12" sm="6">
<MudDatePicker @bind-Date="endsAtDate"
Label="게시 종료일 (비우면 무기한)"
Variant="Variant.Outlined"
DateFormat="yyyy-MM-dd"
Clearable="true" />
</MudItem>
<MudItem xs="12">
<MudSwitch @bind-Checked="model.IsActive"
Label="@(model.IsActive ? "활성화 (홈페이지에 노출)" : "비활성화 (홈페이지 미노출)")"
Color="Color.Primary" />
</MudItem>
</MudGrid>
<div class="d-flex gap-2 mt-4">
<MudButton Variant="Variant.Filled" Color="Color.Primary"
StartIcon="@Icons.Material.Filled.Save"
Disabled="isSaving"
@onclick="SaveAsync">
@(isSaving ? "저장 중..." : "저장")
</MudButton>
<MudButton Variant="Variant.Outlined"
@onclick="@(() => Navigation.NavigateTo("/taxbaik/admin/announcements"))">
취소
</MudButton>
</div>
</MudForm>
</MudPaper>
@code {
[Parameter] public int? Id { get; set; }
private MudForm? form;
private bool isSaving;
private DateTime? startsAtDate;
private DateTime? endsAtDate;
private AnnouncementDto model = new();
protected override async Task OnInitializedAsync()
{
if (Id.HasValue)
{
try
{
var entity = await AnnouncementClient.GetByIdAsync(Id.Value);
if (entity is null)
{
Navigation.NavigateTo("/taxbaik/admin/announcements");
return;
}
model = new AnnouncementDto
{
Id = entity.Id,
Title = entity.Title,
Content = entity.Content,
DisplayType = entity.DisplayType,
IsActive = entity.IsActive,
SortOrder = entity.SortOrder
};
startsAtDate = entity.StartsAt?.ToLocalTime();
endsAtDate = entity.EndsAt?.ToLocalTime();
}
catch
{
Navigation.NavigateTo("/taxbaik/admin/announcements");
}
}
}
private async Task SaveAsync()
{
if (form is null) return;
await form.Validate();
if (!form.IsValid) return;
isSaving = true;
try
{
model.StartsAt = startsAtDate.HasValue
? DateTime.SpecifyKind(startsAtDate.Value.Date, DateTimeKind.Local).ToUniversalTime()
: null;
model.EndsAt = endsAtDate.HasValue
? DateTime.SpecifyKind(endsAtDate.Value.Date.AddDays(1).AddSeconds(-1), DateTimeKind.Local).ToUniversalTime()
: null;
if (Id.HasValue)
{
var result = await AnnouncementClient.UpdateAsync(Id.Value, model);
if (result != null)
Snackbar.Add("공지사항이 저장되었습니다.", Severity.Success);
else
Snackbar.Add("저장 실패", Severity.Error);
}
else
{
var result = await AnnouncementClient.CreateAsync(model);
if (result != null)
Snackbar.Add("공지사항이 저장되었습니다.", Severity.Success);
else
Snackbar.Add("저장 실패", Severity.Error);
}
Navigation.NavigateTo("/taxbaik/admin/announcements");
}
catch (Exception ex)
{
Snackbar.Add($"저장 실패: {ex.Message}", Severity.Error);
}
finally
{
isSaving = false;
}
}
}
@@ -0,0 +1,204 @@
@page "/admin/announcements"
@attribute [Authorize]
@using TaxBaik.Web.Services
@using TaxBaik.Domain.Entities
@inject IAnnouncementBrowserClient AnnouncementClient
@inject NavigationManager Navigation
@inject IDialogService DialogService
@inject ISnackbar Snackbar
<PageTitle>공지사항 관리</PageTitle>
<section class="admin-page-hero">
<div>
<MudText Typo="Typo.caption" Class="admin-eyebrow">Homepage</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/announcements/create">
공지 등록
</MudButton>
</section>
<div class="d-flex pa-4 gap-4 align-center">
<MudTextField @bind-Value="searchQuery" Placeholder="공지사항 제목 검색..." Adornment="Adornment.Start"
AdornmentIcon="@Icons.Material.Filled.Search" IconSize="Size.Medium" Class="flex-grow-1" Immediate="true" Clearable="true" />
</div>
<AdminDataPanel Loading="@(announcements is null)" SkeletonContent="@AnnouncementSkeleton">
@if (announcements is null)
{
}
else if (!FilteredAnnouncements.Any())
{
<div class="pa-6 text-center">
<MudIcon Icon="@Icons.Material.Filled.Campaign" Style="font-size:3rem; opacity:.3;" />
<MudText Class="mt-2 text-muted">검색 조건에 맞는 공지사항이 없습니다.</MudText>
</div>
}
else
{
<MudSimpleTable Striped="true" Dense="true" Class="admin-table">
<thead>
<tr>
<th>제목</th>
<th>유형</th>
<th>상태</th>
<th>게시 기간</th>
<th>순서</th>
<th></th>
</tr>
</thead>
<tbody>
@foreach (var item in FilteredAnnouncements)
{
<tr>
<td>@item.Title</td>
<td>
<MudChip Size="Size.Small" Color="@GetTypeColor(item.DisplayType)">
@GetTypeLabel(item.DisplayType)
</MudChip>
</td>
<td>
@if (IsCurrentlyActive(item))
{
<MudChip Size="Size.Small" Color="Color.Success">노출 중</MudChip>
}
else if (!item.IsActive)
{
<MudChip Size="Size.Small" Color="Color.Default">비활성</MudChip>
}
else
{
<MudChip Size="Size.Small" Color="Color.Warning">기간 외</MudChip>
}
</td>
<td class="small">
@FormatPeriod(item)
</td>
<td>@item.SortOrder</td>
<td>
<MudButtonGroup Size="Size.Small" Variant="Variant.Outlined">
<MudButton @onclick="@(() => Navigation.NavigateTo($"/taxbaik/admin/announcements/{item.Id}/edit"))">
수정
</MudButton>
<MudButton Color="Color.Error" @onclick="@(() => DeleteAsync(item))">
삭제
</MudButton>
</MudButtonGroup>
</td>
</tr>
}
</tbody>
</MudSimpleTable>
<MudText Typo="Typo.caption" Class="pa-2 text-muted">
검색 결과 @(FilteredAnnouncements.Count())개 · 총 @(announcements.Count)개
</MudText>
}
</AdminDataPanel>
@code {
[CascadingParameter]
private Task<AuthenticationState>? AuthStateTask { get; set; }
private List<Announcement>? announcements;
private string searchQuery = "";
private RenderFragment AnnouncementSkeleton => builder =>
{
builder.OpenComponent<AdminSkeletonRows>(0);
builder.AddAttribute(1, "Rows", 5);
builder.AddAttribute(2, "Columns", 4);
builder.CloseComponent();
};
private IEnumerable<Announcement> FilteredAnnouncements => announcements?
.Where(a => string.IsNullOrEmpty(searchQuery) ||
a.Title.Contains(searchQuery, StringComparison.OrdinalIgnoreCase))
.OrderBy(a => a.SortOrder) ?? Enumerable.Empty<Announcement>();
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
{
announcements = (await AnnouncementClient.GetAllAsync()).ToList();
}
catch (Exception ex)
{
Snackbar.Add($"오류: {ex.Message}", Severity.Error);
announcements = [];
}
}
private async Task DeleteAsync(Announcement item)
{
var confirmed = await DialogService.ShowMessageBox(
"공지 삭제",
$"'{item.Title}' 공지를 삭제하시겠습니까?",
yesText: "삭제", cancelText: "취소");
if (confirmed != true) return;
try
{
var success = await AnnouncementClient.DeleteAsync(item.Id);
if (success)
{
Snackbar.Add("공지사항이 삭제되었습니다.", Severity.Success);
await LoadAsync();
}
else
{
Snackbar.Add("삭제 실패", Severity.Error);
}
}
catch (Exception ex)
{
Snackbar.Add($"오류: {ex.Message}", Severity.Error);
}
}
private static bool IsCurrentlyActive(Announcement a)
{
if (!a.IsActive) return false;
var now = DateTime.UtcNow;
if (a.StartsAt.HasValue && a.StartsAt > now) return false;
if (a.EndsAt.HasValue && a.EndsAt < now) return false;
return true;
}
private static string FormatPeriod(Announcement a)
{
var start = a.StartsAt?.ToLocalTime().ToString("MM/dd") ?? "즉시";
var end = a.EndsAt?.ToLocalTime().ToString("MM/dd") ?? "무기한";
return $"{start} ~ {end}";
}
private static Color GetTypeColor(string type) => type switch
{
"urgent" => Color.Error,
"banner" => Color.Warning,
_ => Color.Info
};
private static string GetTypeLabel(string type) => type switch
{
"urgent" => "긴급",
"banner" => "배너",
_ => "일반"
};
}
@@ -0,0 +1,65 @@
@page "/admin/blog/create"
@attribute [Authorize]
@using TaxBaik.Application.DTOs
@using TaxBaik.WasmClient.Components.Admin.Pages.Blog
@inject IBlogBrowserClient BlogClient
@inject ICategoryBrowserClient CategoryClient
@inject NavigationManager Navigation
@inject ISnackbar Snackbar
<PageTitle>새 포스트 작성</PageTitle>
<AdminCrudPageShell Title="새 포스트 작성"
Eyebrow="Content"
Subtitle="새로운 블로그 포스트를 작성합니다."
Loading="@false"
OnCancel="@GoBack">
<MudPaper Class="pa-4 mt-4" Elevation="1">
<BlogForm Model="model" Categories="categories" SubmitText="저장" OnSubmit="SavePost" OnCancel="GoBack" />
</MudPaper>
</AdminCrudPageShell>
@code {
private IReadOnlyList<Domain.Entities.Category> categories = [];
private BlogForm.BlogFormModel model = new();
protected override async Task OnInitializedAsync()
{
categories = await CategoryClient.GetAllAsync();
}
private void GoBack()
{
Navigation.NavigateTo("/taxbaik/admin/blog");
}
private async Task SavePost()
{
try
{
var result = await BlogClient.CreateAsync(new CreateBlogPostDto
{
Title = model.Title,
Content = model.Content,
CategoryId = model.CategoryId,
Tags = model.Tags,
SeoTitle = model.SeoTitle,
SeoDescription = model.SeoDescription,
IsPublished = model.IsPublished
});
if (result == null)
{
Snackbar.Add("포스트 저장에 실패했습니다.", Severity.Error);
return;
}
Snackbar.Add("포스트가 저장되었습니다.", Severity.Success);
Navigation.NavigateTo("/taxbaik/admin/blog");
}
catch (ValidationException ex)
{
Snackbar.Add(ex.Message, Severity.Error);
}
}
}
@@ -0,0 +1,154 @@
@page "/admin/blog/{id:int}/edit"
@attribute [Authorize]
@using TaxBaik.Application.DTOs
@using TaxBaik.WasmClient.Components.Admin.Pages.Blog
@inject IBlogBrowserClient BlogClient
@inject ICategoryBrowserClient CategoryClient
@inject NavigationManager Navigation
@inject ISnackbar Snackbar
@inject IDialogService DialogService
<PageTitle>포스트 수정</PageTitle>
<AdminCrudPageShell Title="포스트 수정"
Eyebrow="Content"
Subtitle="블로그 포스트를 수정합니다."
Loading="@isLoading"
SkeletonContent="@EditorSkeleton"
OnCancel="@GoBack">
@if (post == null)
{
<MudAlert Severity="Severity.Error" Class="mt-4">포스트를 찾을 수 없습니다.</MudAlert>
}
else
{
<MudPaper Class="pa-4 mt-4" Elevation="1">
<BlogForm Model="model" Categories="categories" SubmitText="저장" OnSubmit="SavePost" />
<div class="mt-4">
<MudButton Variant="Variant.Outlined" Color="Color.Error" @onclick="DeletePost">삭제</MudButton>
</div>
</MudPaper>
}
</AdminCrudPageShell>
@code {
[Parameter]
public int Id { get; set; }
private TaxBaik.Application.DTOs.BlogPostResponseDto? post;
private IReadOnlyList<Domain.Entities.Category> categories = [];
private BlogForm.BlogFormModel model = new();
private bool isLoading = true;
private RenderFragment EditorSkeleton => builder =>
{
builder.OpenComponent<AdminSkeletonRows>(0);
builder.AddAttribute(1, "Rows", 5);
builder.AddAttribute(2, "Columns", 3);
builder.CloseComponent();
};
protected override async Task OnInitializedAsync()
{
try
{
post = await BlogClient.GetByIdAsync(Id);
if (post != null)
{
categories = await CategoryClient.GetAllAsync();
MapPostToModel(post);
}
}
catch (Exception ex)
{
Snackbar.Add($"포스트 로드 실패: {ex.Message}", Severity.Error);
}
finally
{
isLoading = false;
}
}
private void MapPostToModel(TaxBaik.Application.DTOs.BlogPostResponseDto post)
{
model.Title = post.Title;
model.Content = post.Content;
model.CategoryId = post.CategoryId;
model.Tags = post.Tags;
model.SeoTitle = post.SeoTitle;
model.SeoDescription = post.SeoDescription;
model.IsPublished = post.IsPublished;
}
private void GoBack()
{
Navigation.NavigateTo("/taxbaik/admin/blog");
}
private async Task SavePost()
{
if (post == null)
return;
try
{
var result = await BlogClient.UpdateAsync(post.Id, new CreateBlogPostDto
{
Title = model.Title,
Content = model.Content,
CategoryId = model.CategoryId,
Tags = model.Tags,
SeoTitle = model.SeoTitle,
SeoDescription = model.SeoDescription,
IsPublished = model.IsPublished
});
if (result == null)
{
Snackbar.Add("저장 실패: 포스트를 저장하지 못했습니다.", Severity.Error);
return;
}
Snackbar.Add("포스트가 저장되었습니다.", Severity.Success);
Navigation.NavigateTo("/taxbaik/admin/blog");
}
catch (ValidationException ex)
{
Snackbar.Add(ex.Message, Severity.Error);
}
catch (Exception ex)
{
Snackbar.Add($"저장 실패: {ex.Message}", Severity.Error);
}
}
private async Task DeletePost()
{
if (post == null)
return;
var result = await DialogService.ShowMessageBox(
"포스트 삭제",
"정말 삭제하시겠습니까? 이 작업은 취소할 수 없습니다.",
"삭제", "취소");
if (result != true)
return;
try
{
var deleted = await BlogClient.DeleteAsync(post.Id);
if (!deleted)
{
Snackbar.Add("삭제 실패: 포스트를 삭제하지 못했습니다.", Severity.Error);
return;
}
Snackbar.Add("포스트가 삭제되었습니다.", Severity.Success);
Navigation.NavigateTo("/taxbaik/admin/blog");
}
catch (Exception ex)
{
Snackbar.Add($"삭제 실패: {ex.Message}", Severity.Error);
}
}
}
@@ -0,0 +1,84 @@
@using TaxBaik.Application.DTOs
@using TaxBaik.Domain.Entities
<MudForm @ref="form">
<AdminFormSection Title="기본 정보" Description="제목과 카테고리, 발행 여부를 먼저 설정합니다." CssClass="mb-4">
<MudTextField @bind-Value="Model.Title" Label="제목 *"
Variant="Variant.Outlined" Class="mb-4" Required="true" RequiredError="제목을 입력하세요." Counter="100" MaxLength="100" />
<MudSelect T="int?" @bind-Value="Model.CategoryId" Label="카테고리"
Variant="Variant.Outlined" Class="mb-4">
@foreach (var category in Categories)
{
<MudSelectItem T="int?" Value="@((int?)category.Id)">@category.Name</MudSelectItem>
}
</MudSelect>
<MudCheckBox @bind-Checked="Model.IsPublished" Label="즉시 발행" Class="mb-4" />
</AdminFormSection>
<AdminFormSection Title="본문" Description="SEO와 실제 노출 본문을 함께 관리합니다." CssClass="mb-4">
<MudTextField @bind-Value="Model.Content" Label="본문 내용 *"
Variant="Variant.Outlined" Lines="16" Required="true" RequiredError="본문 내용을 입력하세요."
Class="mb-4" />
<MudTextField @bind-Value="Model.Tags" Label="태그 (쉼표로 구분)"
Variant="Variant.Outlined" Class="mb-4" />
<MudTextField @bind-Value="Model.SeoTitle" Label="SEO 제목"
Variant="Variant.Outlined" Class="mb-4" />
<MudTextField @bind-Value="Model.SeoDescription" Label="SEO 설명"
Variant="Variant.Outlined" Lines="3" Class="mb-4" />
</AdminFormSection>
<AdminFormActions SubmitText="@SubmitText"
LoadingText="저장 중..."
CancelText="취소"
SubmitIcon="@Icons.Material.Filled.Save"
OnSubmit="@HandleSubmit"
OnCancel="@OnCancel"
IsSubmitting="false" />
</MudForm>
@code {
[Parameter, EditorRequired]
public BlogFormModel Model { get; set; } = new();
[Parameter]
public IReadOnlyList<Category> Categories { get; set; } = [];
[Parameter]
public string SubmitText { get; set; } = "저장";
[Parameter]
public EventCallback OnSubmit { get; set; }
[Parameter]
public EventCallback OnCancel { get; set; }
private MudForm? form;
private async Task HandleSubmit()
{
if (form == null)
return;
await form.Validate();
if (!form.IsValid)
return;
await OnSubmit.InvokeAsync();
}
public class BlogFormModel
{
public string Title { get; set; } = "";
public string Content { get; set; } = "";
public int? CategoryId { get; set; }
public string? Tags { get; set; }
public string? SeoTitle { get; set; }
public string? SeoDescription { get; set; }
public bool IsPublished { get; set; }
}
}
@@ -0,0 +1,199 @@
@page "/admin/blog"
@attribute [Authorize]
@inject IBlogBrowserClient BlogClient
@inject ISnackbar Snackbar
<PageTitle>블로그 관리</PageTitle>
<AdminPageHeader Title="블로그 관리" Eyebrow="Content" Subtitle="검색 유입 콘텐츠의 발행 상태와 성과를 관리합니다.">
<ChildContent>
<MudButton Variant="Variant.Outlined" Color="Color.Secondary" StartIcon="@Icons.Material.Filled.Restore"
OnClick="ToggleArchiveView">
@(showArchived ? "전체 글 보기" : "숨김 글 보기")
</MudButton>
<MudButton Variant="Variant.Outlined" Color="Color.Secondary" StartIcon="@Icons.Material.Filled.Refresh"
OnClick="Reload">
새로고침
</MudButton>
<MudButton Variant="Variant.Filled" Color="Color.Primary" StartIcon="@Icons.Material.Filled.EditNote"
Href="/taxbaik/admin/blog/create">새 포스트 작성</MudButton>
</ChildContent>
</AdminPageHeader>
<div class="d-flex pa-4 gap-4 align-center">
<MudTextField @bind-Value="searchQuery" Placeholder="블로그 제목 또는 본문 검색..." Adornment="Adornment.Start"
AdornmentIcon="@Icons.Material.Filled.Search" IconSize="Size.Medium" Class="flex-grow-1" Immediate="true" Clearable="true" />
</div>
<AdminDataPanel Loading="@isLoading">
<MudStack Row="true" AlignItems="AlignItems.Center" Justify="Justify.SpaceBetween" Class="mb-3">
<MudText Typo="Typo.subtitle1">@($"검색 결과 {FilteredPosts.Count()}개 / 전체 포스트 {totalPosts}개")</MudText>
<MudText Typo="Typo.body2">페이지 @currentPage / @totalPages</MudText>
</MudStack>
<MudDataGrid Items="@FilteredPosts" Striped="true" Hoverable="true" Class="admin-grid">
<Columns>
<PropertyColumn Property="x => x.Title" Title="제목" />
<PropertyColumn Property="x => x.IsPublished" Title="발행">
<CellTemplate Context="cell">
<MudCheckBox T="bool" Value="@cell.Item.IsPublished"
ValueChanged="@(async (bool value) => await TogglePublish(cell.Item, value))" />
</CellTemplate>
</PropertyColumn>
<PropertyColumn Property="x => x.ViewCount" Title="조회수" />
<PropertyColumn Property="x => x.CreatedAt" Title="작성일" Format="yyyy-MM-dd" />
<TemplateColumn>
<CellTemplate Context="cell">
<MudButton Variant="Variant.Outlined" Size="Size.Small" Color="Color.Primary"
Href="@($"/taxbaik/admin/blog/{cell.Item.Id}/edit")">수정하기</MudButton>
@if (showArchived)
{
<MudButton Variant="Variant.Text" Size="Size.Small" Color="Color.Success"
@onclick="@(async () => await RestorePost(cell.Item.Id))">복원</MudButton>
}
else
{
<MudButton Variant="Variant.Text" Size="Size.Small" Color="Color.Error"
@onclick="@(async () => await DeletePost(cell.Item.Id))">삭제</MudButton>
}
</CellTemplate>
</TemplateColumn>
</Columns>
</MudDataGrid>
<MudStack Row="true" Justify="Justify.Center" Class="mt-4" Spacing="2">
<MudButton Variant="Variant.Outlined" Disabled="@(currentPage <= 1 || isLoading)" @onclick="PreviousPage">이전</MudButton>
<MudButton Variant="Variant.Outlined" Disabled="@(currentPage >= totalPages || isLoading)" @onclick="NextPage">다음</MudButton>
</MudStack>
</AdminDataPanel>
@code {
[CascadingParameter]
private Task<AuthenticationState>? AuthStateTask { get; set; }
private List<TaxBaik.Application.DTOs.BlogPostResponseDto> posts = [];
private string searchQuery = "";
private bool isLoading = true;
private int currentPage = 1;
private int totalPages = 1;
private int totalPosts = 0;
private bool showArchived;
private const int PageSize = 20;
private IEnumerable<TaxBaik.Application.DTOs.BlogPostResponseDto> FilteredPosts => posts
.Where(p => string.IsNullOrEmpty(searchQuery) ||
p.Title.Contains(searchQuery, StringComparison.OrdinalIgnoreCase) ||
(p.Content != null && p.Content.Contains(searchQuery, StringComparison.OrdinalIgnoreCase)));
protected override async Task OnInitializedAsync()
{
if (AuthStateTask != null)
{
var authState = await AuthStateTask;
if (authState.User.Identity?.IsAuthenticated == true)
{
await LoadPosts();
}
}
}
private async Task LoadPosts()
{
isLoading = true;
try
{
var result = showArchived
? await BlogClient.GetArchivedPagedAsync(currentPage, PageSize)
: await BlogClient.GetAdminPagedAsync(currentPage, PageSize);
posts = result.Items.ToList();
totalPosts = result.Total;
totalPages = Math.Max(1, (int)Math.Ceiling(totalPosts / (double)PageSize));
}
catch
{
posts = [];
totalPosts = 0;
totalPages = 1;
}
isLoading = false;
}
private async Task PreviousPage()
{
if (currentPage <= 1)
return;
currentPage--;
await LoadPosts();
}
private async Task NextPage()
{
if (currentPage >= totalPages)
return;
currentPage++;
await LoadPosts();
}
private async Task TogglePublish(TaxBaik.Application.DTOs.BlogPostResponseDto post, bool isPublished)
{
var previous = post.IsPublished;
post.IsPublished = isPublished;
var result = await BlogClient.UpdateAsync(post.Id, new TaxBaik.Application.DTOs.CreateBlogPostDto
{
Title = post.Title,
Content = post.Content,
CategoryId = post.CategoryId,
Tags = post.Tags,
SeoTitle = post.SeoTitle,
SeoDescription = post.SeoDescription,
ThumbnailUrl = post.ThumbnailUrl,
IsPublished = isPublished,
AuthorId = post.AuthorId
});
if (result == null)
{
post.IsPublished = previous;
Snackbar.Add("발행 상태 변경에 실패했습니다.", Severity.Error);
return;
}
Snackbar.Add("발행 상태가 변경되었습니다.", Severity.Success);
}
private async Task DeletePost(int postId)
{
var deleted = await BlogClient.DeleteAsync(postId);
if (!deleted)
{
Snackbar.Add("포스트 삭제에 실패했습니다.", Severity.Error);
return;
}
Snackbar.Add("포스트가 삭제되었습니다.", Severity.Success);
await LoadPosts();
}
private async Task RestorePost(int postId)
{
var restored = await BlogClient.RestoreAsync(postId);
if (!restored)
{
Snackbar.Add("포스트 복원에 실패했습니다.", Severity.Error);
return;
}
Snackbar.Add("포스트가 복원되었습니다.", Severity.Success);
await LoadPosts();
}
private async Task ToggleArchiveView()
{
showArchived = !showArchived;
currentPage = 1;
await LoadPosts();
}
private async Task Reload() => await LoadPosts();
}
@@ -0,0 +1,258 @@
@page "/admin/clients/{ClientId:int}"
@attribute [Authorize]
@using TaxBaik.Web.Services
@using TaxBaik.Web.Services.AdminClients
@using TaxBaik.WasmClient.Components.Admin.Shared
@inject IClientBrowserClient ClientClient
@inject IConsultingActivityBrowserClient ConsultingClient
@inject NavigationManager Navigation
@inject ISnackbar Snackbar
<PageTitle>고객 상세</PageTitle>
<section class="admin-page-hero">
<div>
<MudText Typo="Typo.caption" Class="admin-eyebrow">Client Details</MudText>
<MudText Typo="Typo.h4" Class="admin-page-title">고객 상세</MudText>
<MudText Typo="Typo.body2" Class="admin-page-subtitle">고객 정보와 상담 이력을 관리합니다.</MudText>
</div>
</section>
@if (client == null)
{
<MudText>고객을 찾을 수 없습니다.</MudText>
return;
}
<MudStack Row="true" AlignItems="AlignItems.Center" Class="mb-4" Spacing="2">
<MudButton Variant="Variant.Outlined" Color="Color.Primary"
StartIcon="@Icons.Material.Filled.ArrowBack"
@onclick="@(() => Navigation.NavigateTo("/taxbaik/admin/clients"))">
목록으로
</MudButton>
<MudButton Variant="Variant.Outlined" Color="Color.Warning"
StartIcon="@Icons.Material.Filled.Edit"
Href="@($"/taxbaik/admin/clients/{ClientId}/edit")">
수정
</MudButton>
</MudStack>
<MudGrid>
<MudItem xs="12" md="5">
<MudPaper Class="pa-4" Elevation="1">
<MudText Typo="Typo.h6" Class="mb-3">고객 정보</MudText>
<MudGrid Spacing="2">
<MudItem xs="6">
<MudText Typo="Typo.subtitle2" Color="Color.Secondary">이름</MudText>
<MudText>@client.Name</MudText>
</MudItem>
<MudItem xs="6">
<MudText Typo="Typo.subtitle2" Color="Color.Secondary">상호</MudText>
<MudText>@(client.CompanyName ?? "-")</MudText>
</MudItem>
<MudItem xs="6">
<MudText Typo="Typo.subtitle2" Color="Color.Secondary">연락처</MudText>
<MudText>@(client.Phone ?? "-")</MudText>
</MudItem>
<MudItem xs="6">
<MudText Typo="Typo.subtitle2" Color="Color.Secondary">이메일</MudText>
<MudText>@(client.Email ?? "-")</MudText>
</MudItem>
<MudItem xs="6">
<MudText Typo="Typo.subtitle2" Color="Color.Secondary">서비스</MudText>
<MudText>@(client.ServiceType ?? "-")</MudText>
</MudItem>
<MudItem xs="6">
<MudText Typo="Typo.subtitle2" Color="Color.Secondary">사업자 유형</MudText>
<MudText>@(client.TaxType ?? "-")</MudText>
</MudItem>
<MudItem xs="6">
<MudText Typo="Typo.subtitle2" Color="Color.Secondary">유입 경로</MudText>
<MudText>@(client.Source ?? "-")</MudText>
</MudItem>
<MudItem xs="6">
<MudText Typo="Typo.subtitle2" Color="Color.Secondary">등록일</MudText>
<MudText>@client.CreatedAt.ToLocalTime().ToString("yyyy-MM-dd")</MudText>
</MudItem>
@if (!string.IsNullOrWhiteSpace(client.Memo))
{
<MudItem xs="12">
<MudText Typo="Typo.subtitle2" Color="Color.Secondary">메모</MudText>
<MudText Style="white-space: pre-wrap;">@client.Memo</MudText>
</MudItem>
}
</MudGrid>
</MudPaper>
</MudItem>
<MudItem xs="12" md="7">
<MudPaper Class="pa-4" Elevation="1">
<MudStack Row="true" AlignItems="AlignItems.Center" Justify="Justify.SpaceBetween" Class="mb-3">
<MudText Typo="Typo.h6">상담 이력</MudText>
<MudButton Variant="Variant.Filled" Color="Color.Primary"
Size="Size.Small"
OnClick="OpenAddConsultation">
+ 상담 추가
</MudButton>
</MudStack>
@if (showAddForm)
{
<MudPaper Class="pa-3 mb-3" Outlined="true">
<MudGrid Spacing="2">
<MudItem xs="12" sm="6">
<MudDatePicker @bind-Date="newDate" Label="상담일" DateFormat="yyyy-MM-dd" />
</MudItem>
<MudItem xs="12" sm="6">
<CommonCodeSelect @bind-Value="newServiceType" Group="CONSULTING_ACTIVITY_TYPE" Label="서비스 분야" Placeholder="선택" Clearable="true" />
</MudItem>
<MudItem xs="12">
<MudTextField T="string" @bind-Value="newSummary" Label="상담 내용 *"
Lines="3" Variant="Variant.Outlined" Required="true" />
</MudItem>
<MudItem xs="12" sm="6">
<MudSelect T="string" @bind-Value="newResult" Label="결과">
<MudSelectItem Value="@("")">-</MudSelectItem>
@foreach (var r in results)
{
<MudSelectItem Value="@r">@r</MudSelectItem>
}
</MudSelect>
</MudItem>
<MudItem xs="12" sm="6">
<MudNumericField T="decimal?" @bind-Value="newFee" Label="수임료 (원)"
Format="N0" />
</MudItem>
</MudGrid>
<MudStack Row="true" Class="mt-2" Spacing="2">
<MudButton Variant="Variant.Filled" Color="Color.Primary" OnClick="AddConsultation">저장</MudButton>
<MudButton Variant="Variant.Outlined" OnClick="@(() => showAddForm = false)">취소</MudButton>
</MudStack>
</MudPaper>
}
@if (consultations.Count == 0)
{
<MudText Color="Color.Secondary">상담 이력이 없습니다.</MudText>
}
else
{
<MudList T="string" Dense="true">
@foreach (var c in consultations)
{
<MudListItem>
<MudPaper Class="pa-3" Outlined="true" Style="width:100%">
<MudStack Row="true" AlignItems="AlignItems.Start" Justify="Justify.SpaceBetween">
<div>
<MudText Typo="Typo.caption" Color="Color.Secondary">
@c.ConsultationDate.ToString("yyyy-MM-dd")
@if (!string.IsNullOrEmpty(c.ServiceType)) { <text> · @c.ServiceType</text> }
</MudText>
<MudText Style="white-space: pre-wrap;" Class="mt-1">@c.Summary</MudText>
@if (!string.IsNullOrEmpty(c.Result))
{
<MudChip T="string" Size="Size.Small" Color="Color.Info" Class="mt-1">@c.Result</MudChip>
}
@if (c.Fee.HasValue)
{
<MudText Typo="Typo.caption" Color="Color.Secondary" Class="mt-1">
수임료: @c.Fee.Value.ToString("N0")원
</MudText>
}
</div>
<MudIconButton Icon="@Icons.Material.Filled.Delete"
Size="Size.Small" Color="Color.Error"
OnClick="@(() => DeleteConsultation(c.Id))" />
</MudStack>
</MudPaper>
</MudListItem>
}
</MudList>
}
</MudPaper>
</MudItem>
</MudGrid>
@code {
[Parameter]
public int ClientId { get; set; }
private Domain.Entities.Client? client;
private List<Domain.Entities.Consultation> consultations = [];
private static readonly string[] results = ["", "상담완료", "추가자료 요청", "견적발송", "계약전환", "보류"];
private bool showAddForm;
private DateTime? newDate = DateTime.Today;
private string newServiceType = "";
private string newSummary = "";
private string newResult = "";
private decimal? newFee;
protected override async Task OnInitializedAsync()
{
await LoadAll();
}
private async Task LoadAll()
{
client = await ClientClient.GetByIdAsync(ClientId);
consultations = (await ConsultingClient.GetByClientIdAsync(ClientId))
.Select(c => new Domain.Entities.Consultation
{
Id = c.Id,
ClientId = c.ClientId,
ConsultationDate = c.ActivityDate,
ServiceType = c.ActivityType,
Summary = c.Description,
Result = null,
Fee = null
})
.ToList();
}
private void OpenAddConsultation()
{
showAddForm = true;
newDate = DateTime.Today;
newServiceType = "";
newSummary = "";
newResult = "";
newFee = null;
}
private async Task AddConsultation()
{
try
{
var newId = await ConsultingClient.CreateAsync(
ClientId,
string.IsNullOrWhiteSpace(newServiceType) ? "기타" : newServiceType,
newDate?.ToUniversalTime() ?? DateTime.UtcNow,
newSummary,
null,
null);
if (newId <= 0)
throw new Exception("상담 생성 실패");
showAddForm = false;
await LoadAll();
Snackbar.Add("상담이 추가되었습니다.", Severity.Success);
}
catch (ValidationException ex)
{
Snackbar.Add(ex.Message, Severity.Error);
}
catch (Exception ex)
{
Snackbar.Add(ex.Message, Severity.Error);
}
}
private async Task DeleteConsultation(int id)
{
await ConsultingClient.DeleteAsync(id);
await LoadAll();
Snackbar.Add("삭제되었습니다.", Severity.Info);
}
}
@@ -0,0 +1,183 @@
@page "/admin/clients/create"
@page "/admin/clients/{Id:int}/edit"
@attribute [Authorize]
@using TaxBaik.Application.DTOs
@using TaxBaik.Web.Services
@using TaxBaik.Domain.Entities
@using TaxBaik.WasmClient.Components.Admin.Shared
@inject IClientBrowserClient ClientClient
@inject NavigationManager Navigation
@inject ISnackbar Snackbar
<PageTitle>@(Id.HasValue ? "고객 수정" : "고객 등록")</PageTitle>
<section class="admin-page-hero">
<div>
<MudText Typo="Typo.caption" Class="admin-eyebrow">CRM</MudText>
<MudText Typo="Typo.h4" Class="admin-page-title">@(Id.HasValue ? "고객 수정" : "고객 등록")</MudText>
</div>
<MudButton Variant="Variant.Outlined" Href="/taxbaik/admin/clients"
StartIcon="@Icons.Material.Filled.ArrowBack">목록으로</MudButton>
</section>
<AdminEditorPanel Loading="@isLoading" SkeletonContent="@ClientEditSkeleton">
@if (isLoading)
{
}
else
{
<MudForm @ref="form" @bind-IsValid="isValid">
<MudGrid Spacing="3">
@* 기본 정보 *@
<MudItem xs="12">
<MudText Typo="Typo.subtitle1" Class="fw-bold mb-1">기본 정보</MudText>
<MudDivider />
</MudItem>
<MudItem xs="12" md="6">
<MudTextField @bind-Value="dto.Name" Label="고객명 *" Required="true"
RequiredError="고객명을 입력하세요." />
</MudItem>
<MudItem xs="12" md="6">
<MudTextField @bind-Value="dto.CompanyName" Label="회사명 (선택)" />
</MudItem>
<MudItem xs="12" md="6">
<MudTextField @bind-Value="dto.Phone" Label="연락처"
Placeholder="010-0000-0000" />
</MudItem>
<MudItem xs="12" md="6">
<MudTextField @bind-Value="dto.Email" Label="이메일" InputType="InputType.Email" />
</MudItem>
@* 세무 정보 *@
<MudItem xs="12" Class="mt-2">
<MudText Typo="Typo.subtitle1" Class="fw-bold mb-1">세무 정보</MudText>
<MudDivider />
</MudItem>
<MudItem xs="12" md="6">
<CommonCodeSelect @bind-Value="dto.ServiceType" Group="CLIENT_SERVICE_TYPE" Label="서비스 유형" Clearable="true" />
</MudItem>
<MudItem xs="12" md="6">
<CommonCodeSelect @bind-Value="dto.TaxType" Group="CLIENT_TAX_TYPE" Label="세금 유형" Clearable="true" />
</MudItem>
@* 관리 정보 *@
<MudItem xs="12" Class="mt-2">
<MudText Typo="Typo.subtitle1" Class="fw-bold mb-1">관리 정보</MudText>
<MudDivider />
</MudItem>
<MudItem xs="12" md="6">
<CommonCodeSelect @bind-Value="dto.Status" Group="CLIENT_STATUS" Label="상태 *" Required="true" />
</MudItem>
<MudItem xs="12" md="6">
<CommonCodeSelect @bind-Value="dto.Source" Group="CLIENT_SOURCE" Label="유입 경로" Clearable="true" />
</MudItem>
<MudItem xs="12">
<MudTextField @bind-Value="dto.Memo" Label="메모"
Lines="4" AutoGrow="true"
Placeholder="상담 배경, 특이사항, 중요 날짜 등 자유롭게 기록하세요" />
</MudItem>
@* 저장 버튼 *@
<MudItem xs="12" Class="d-flex gap-2 mt-2">
<MudButton Variant="Variant.Filled" Color="Color.Primary"
StartIcon="@Icons.Material.Filled.Save"
OnClick="@SaveAsync" Disabled="@isSaving">
@(isSaving ? "저장 중..." : "저장")
</MudButton>
<MudButton Variant="Variant.Outlined" Href="/taxbaik/admin/clients">
취소
</MudButton>
</MudItem>
</MudGrid>
</MudForm>
}
</AdminEditorPanel>
@code {
[Parameter] public int? Id { get; set; }
private MudForm form = null!;
private CreateClientDto dto = new() { Status = "active" };
private bool isValid;
private bool isLoading = true;
private bool isSaving;
private RenderFragment ClientEditSkeleton => builder =>
{
builder.OpenComponent<AdminSkeletonRows>(0);
builder.AddAttribute(1, "Rows", 6);
builder.AddAttribute(2, "Columns", 3);
builder.CloseComponent();
};
protected override async Task OnInitializedAsync()
{
if (Id.HasValue)
{
try
{
var client = await ClientClient.GetByIdAsync(Id.Value);
if (client is null)
{
Snackbar.Add("고객을 찾을 수 없습니다.", Severity.Error);
Navigation.NavigateTo("/taxbaik/admin/clients");
return;
}
dto = new CreateClientDto
{
Name = client.Name,
CompanyName = client.CompanyName,
Phone = client.Phone,
Email = client.Email,
ServiceType = client.ServiceType,
TaxType = client.TaxType,
Status = client.Status,
Source = client.Source,
Memo = client.Memo
};
}
catch (Exception ex)
{
Snackbar.Add($"오류: {ex.Message}", Severity.Error);
Navigation.NavigateTo("/taxbaik/admin/clients");
return;
}
}
isLoading = false;
}
private async Task SaveAsync()
{
await form.Validate();
if (!isValid) return;
isSaving = true;
try
{
if (Id.HasValue)
{
var result = await ClientClient.UpdateAsync(Id.Value, dto);
if (result != null)
Snackbar.Add("고객 정보가 수정되었습니다.", Severity.Success);
else
Snackbar.Add("수정에 실패했습니다.", Severity.Error);
}
else
{
var result = await ClientClient.CreateAsync(dto);
if (result != null)
Snackbar.Add("고객이 등록되었습니다.", Severity.Success);
else
Snackbar.Add("등록에 실패했습니다.", Severity.Error);
}
Navigation.NavigateTo("/taxbaik/admin/clients");
}
catch (Exception ex)
{
Snackbar.Add($"저장 실패: {ex.Message}", Severity.Error);
}
finally
{
isSaving = false;
}
}
}
@@ -0,0 +1,227 @@
@page "/admin/clients"
@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();
}
}
@@ -0,0 +1,137 @@
@page "/admin/common-codes"
@using TaxBaik.Web.Services.AdminClients
@using TaxBaik.Domain.Entities
@attribute [Authorize]
@inject ICommonCodeBrowserClient CommonCodeClient
@inject ISnackbar Snackbar
<PageTitle>공통관리</PageTitle>
<AdminPageHeader Title="공통관리" Eyebrow="System" Subtitle="공통코드 그룹과 항목을 일관된 기준으로 관리합니다." />
<MudGrid Spacing="2">
<MudItem XS="12" MD="4">
<CommonCodeGroupPanel Groups="groups"
SelectedGroup="selectedGroup"
SelectedGroupChanged="OnGroupChanged"
OnCreateRequested="PrepareCreate" />
</MudItem>
<MudItem XS="12" MD="8">
<CommonCodeListPanel Loading="@isLoading"
Codes="codes"
EditModel="editModel"
IsCreateMode="isCreateMode"
Form="form"
EditRequested="EditCode"
DeleteRequested="DeleteCode"
SaveRequested="SaveCode"
ResetRequested="PrepareCreate" />
</MudItem>
</MudGrid>
@code {
private List<string> groups = [];
private List<CommonCode> codes = [];
private string selectedGroup = "";
private bool isLoading = true;
private CommonCode editModel = new();
private bool isCreateMode = true;
protected override async Task OnInitializedAsync()
{
groups = await CommonCodeClient.GetGroupsAsync();
selectedGroup = groups.FirstOrDefault() ?? "";
await LoadCodes();
PrepareCreate();
}
private async Task OnGroupChanged(string value)
{
selectedGroup = value;
await LoadCodes();
PrepareCreate();
}
private async Task LoadCodes()
{
isLoading = true;
codes = string.IsNullOrWhiteSpace(selectedGroup)
? []
: await CommonCodeClient.GetByGroupAsync(selectedGroup);
isLoading = false;
}
private void PrepareCreate()
{
isCreateMode = true;
editModel = new CommonCode
{
CodeGroup = selectedGroup,
IsActive = true
};
}
private void EditCode(CommonCode code)
{
isCreateMode = false;
editModel = new CommonCode
{
CodeGroup = code.CodeGroup,
CodeValue = code.CodeValue,
CodeName = code.CodeName,
SortOrder = code.SortOrder,
IsActive = code.IsActive
};
}
private async Task SaveCode()
{
editModel.CodeGroup = editModel.CodeGroup?.Trim() ?? string.Empty;
editModel.CodeValue = editModel.CodeValue?.Trim() ?? string.Empty;
editModel.CodeName = editModel.CodeName?.Trim() ?? string.Empty;
if (string.IsNullOrWhiteSpace(editModel.CodeGroup) ||
string.IsNullOrWhiteSpace(editModel.CodeValue) ||
string.IsNullOrWhiteSpace(editModel.CodeName))
{
Snackbar.Add("그룹, 값, 이름은 모두 입력해야 합니다.", Severity.Error);
return;
}
if (editModel.CodeGroup.Any(char.IsWhiteSpace))
{
Snackbar.Add("code_group에는 공백을 넣을 수 없습니다.", Severity.Error);
return;
}
if (editModel.CodeValue.Any(char.IsWhiteSpace))
{
Snackbar.Add("code_value에는 공백을 넣을 수 없습니다.", Severity.Error);
return;
}
if (!await CommonCodeClient.UpsertAsync(editModel))
{
Snackbar.Add("저장 실패", Severity.Error);
return;
}
Snackbar.Add("저장되었습니다.", Severity.Success);
await LoadCodes();
PrepareCreate();
}
private async Task DeleteCode(CommonCode code)
{
if (!await CommonCodeClient.DeleteAsync(code.CodeGroup, code.CodeValue))
{
Snackbar.Add("삭제 실패", Severity.Error);
return;
}
Snackbar.Add("삭제되었습니다.", Severity.Success);
await LoadCodes();
PrepareCreate();
}
}
@@ -0,0 +1,51 @@
@page "/admin/companies/create"
@attribute [Authorize]
@using TaxBaik.WasmClient.Components.Admin.Forms
@inject IApiClient ApiClient
@inject NavigationManager Navigation
@inject ISnackbar Snackbar
<PageTitle>고객사 등록</PageTitle>
<section class="admin-page-hero">
<div>
<MudText Typo="Typo.caption" Class="admin-eyebrow">Settings</MudText>
<MudText Typo="Typo.h4" Class="admin-page-title">새 고객사 등록</MudText>
<MudText Typo="Typo.body2" Class="admin-page-subtitle">새로운 고객사를 추가합니다.</MudText>
</div>
<MudButton Variant="Variant.Outlined" StartIcon="@Icons.Material.Filled.Close" @onclick="GoBack">취소</MudButton>
</section>
<MudPaper Class="pa-4 mt-4" Elevation="1">
<CompanyForm ButtonText="등록" OnSubmit="HandleCreate" OnCancel="GoBack" />
</MudPaper>
@code {
private void GoBack()
{
Navigation.NavigateTo("/taxbaik/admin/companies");
}
private async Task HandleCreate(CompanyForm.CompanyFormModel model)
{
try
{
await ApiClient.PostAsync<object>("company", new
{
companyCode = model.CompanyCode,
companyName = model.CompanyName,
contactPerson = model.ContactPerson,
phone = model.Phone,
email = model.Email,
memo = model.Memo
});
Snackbar.Add("고객사가 등록되었습니다.", Severity.Success);
Navigation.NavigateTo("/taxbaik/admin/companies");
}
catch (Exception ex)
{
Snackbar.Add($"등록 실패: {ex.Message}", Severity.Error);
}
}
}
@@ -0,0 +1,134 @@
@page "/admin/companies/{id:int}/edit"
@attribute [Authorize]
@using TaxBaik.WasmClient.Components.Admin.Forms
@inject IApiClient ApiClient
@inject NavigationManager Navigation
@inject ISnackbar Snackbar
@inject IDialogService DialogService
<PageTitle>고객사 수정</PageTitle>
<section class="admin-page-hero">
<div>
<MudText Typo="Typo.caption" Class="admin-eyebrow">Settings</MudText>
<MudText Typo="Typo.h4" Class="admin-page-title">고객사 수정</MudText>
<MudText Typo="Typo.body2" Class="admin-page-subtitle">고객사 정보를 수정합니다.</MudText>
</div>
<MudButton Variant="Variant.Outlined" StartIcon="@Icons.Material.Filled.Close" @onclick="GoBack">취소</MudButton>
</section>
<AdminEditorPanel Loading="@isLoading" SkeletonContent="@CompanySkeleton">
@if (formModel == null)
{
<MudAlert Severity="Severity.Error" Class="mt-4">고객사를 찾을 수 없습니다.</MudAlert>
}
else
{
<MudPaper Class="pa-4 mt-4" Elevation="1">
<CompanyForm ButtonText="수정" InitialData="formModel" OnSubmit="HandleUpdate" OnCancel="GoBack" />
<MudDivider Class="my-4" />
<MudButton Variant="Variant.Outlined" Color="Color.Error" @onclick="DeleteCompany" Class="mt-2">
고객사 삭제
</MudButton>
</MudPaper>
}
</AdminEditorPanel>
@code {
[Parameter]
public int Id { get; set; }
private CompanyForm.CompanyFormModel? formModel;
private bool isLoading = true;
private RenderFragment CompanySkeleton => builder =>
{
builder.OpenComponent<AdminSkeletonRows>(0);
builder.AddAttribute(1, "Rows", 6);
builder.AddAttribute(2, "Columns", 3);
builder.CloseComponent();
};
protected override async Task OnInitializedAsync()
{
try
{
var company = await ApiClient.GetAsync<dynamic>($"company/{Id}");
IDictionary<string, object>? dict = company as IDictionary<string, object>;
if (dict != null)
{
formModel = new CompanyForm.CompanyFormModel
{
CompanyCode = (string)dict["companyCode"],
CompanyName = (string)dict["companyName"],
ContactPerson = (string?)dict["contactPerson"],
Phone = (string?)dict["phone"],
Email = (string?)dict["email"],
Memo = (string?)dict["memo"],
IsActive = (bool)(dynamic)dict["isActive"]
};
}
}
catch (Exception ex)
{
Snackbar.Add($"고객사 로드 실패: {ex.Message}", Severity.Error);
}
finally
{
isLoading = false;
}
}
private void GoBack()
{
Navigation.NavigateTo("/taxbaik/admin/companies");
}
private async Task HandleUpdate(CompanyForm.CompanyFormModel model)
{
try
{
await ApiClient.PutAsync<object>($"company/{Id}", new
{
companyCode = model.CompanyCode,
companyName = model.CompanyName,
contactPerson = model.ContactPerson,
phone = model.Phone,
email = model.Email,
memo = model.Memo,
isActive = model.IsActive
});
Snackbar.Add("고객사가 수정되었습니다.", Severity.Success);
Navigation.NavigateTo("/taxbaik/admin/companies");
}
catch (Exception ex)
{
Snackbar.Add($"수정 실패: {ex.Message}", Severity.Error);
}
}
private async Task DeleteCompany()
{
var result = await DialogService.ShowMessageBox(
"고객사 삭제",
"정말 삭제하시겠습니까? 이 작업은 취소할 수 없습니다.",
"삭제", "취소");
if (result != true)
return;
try
{
await ApiClient.DeleteAsync($"company/{Id}");
Snackbar.Add("고객사가 삭제되었습니다.", Severity.Success);
Navigation.NavigateTo("/taxbaik/admin/companies");
}
catch (Exception ex)
{
Snackbar.Add($"삭제 실패: {ex.Message}", Severity.Error);
}
}
}
@@ -0,0 +1,134 @@
@page "/admin/companies"
@attribute [Authorize]
@inject IApiClient ApiClient
@inject ISnackbar Snackbar
<PageTitle>고객사 관리</PageTitle>
<section class="admin-page-hero">
<div>
<MudText Typo="Typo.caption" Class="admin-eyebrow">Settings</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/companies/create">새 고객사 등록</MudButton>
</section>
<MudPaper Class="admin-surface mb-4 mt-4" Elevation="0">
<MudStack Row="true" AlignItems="AlignItems.Center" Justify="Justify.SpaceBetween">
<MudText Typo="Typo.subtitle1">@($"전체 고객사 {totalCompanies}개")</MudText>
<MudText Typo="Typo.body2">페이지 @currentPage / @totalPages</MudText>
</MudStack>
</MudPaper>
<MudDataGrid Items="@companies" Striped="true" Hoverable="true" Loading="@isLoading" Class="admin-grid">
<Columns>
<PropertyColumn Property="x => x.CompanyCode" Title="회사코드" />
<PropertyColumn Property="x => x.CompanyName" Title="회사명" />
<PropertyColumn Property="x => x.ContactPerson" Title="담당자" />
<PropertyColumn Property="x => x.Phone" Title="전화" />
<PropertyColumn Property="x => x.Email" Title="이메일" />
<PropertyColumn Property="x => x.IsActive" Title="활성">
<CellTemplate Context="cell">
<MudCheckBox T="bool" Value="@cell.Item.IsActive" Disabled="true" />
</CellTemplate>
</PropertyColumn>
<PropertyColumn Property="x => x.CreatedAt" Title="등록일" Format="yyyy-MM-dd" />
<TemplateColumn>
<CellTemplate Context="cell">
<MudButton Variant="Variant.Outlined" Size="Size.Small" Color="Color.Primary"
Href="@($"/taxbaik/admin/companies/{cell.Item.Id}/edit")">수정</MudButton>
</CellTemplate>
</TemplateColumn>
</Columns>
</MudDataGrid>
<MudStack Row="true" Justify="Justify.Center" Class="mt-4" Spacing="2">
<MudButton Variant="Variant.Outlined" Disabled="@(currentPage <= 1 || isLoading)" @onclick="PreviousPage">이전</MudButton>
<MudButton Variant="Variant.Outlined" Disabled="@(currentPage >= totalPages || isLoading)" @onclick="NextPage">다음</MudButton>
</MudStack>
@code {
private List<CompanyDto> companies = [];
private bool isLoading = true;
private int currentPage = 1;
private int totalPages = 1;
private int totalCompanies = 0;
private const int PageSize = 20;
protected override async Task OnInitializedAsync()
{
await LoadData();
}
private async Task LoadData()
{
try
{
isLoading = true;
var response = await ApiClient.GetAsync<dynamic>($"company?page={currentPage}&pageSize={PageSize}");
IDictionary<string, object>? dict = response as IDictionary<string, object>;
if (dict != null)
{
totalCompanies = (int)(dynamic)dict["total"];
totalPages = (totalCompanies + PageSize - 1) / PageSize;
if (dict["data"] is System.Collections.IEnumerable dataList)
{
companies = new List<CompanyDto>();
foreach (var item in dataList)
{
if (item is IDictionary<string, object> companyDict)
{
companies.Add(new CompanyDto
{
Id = (int)(dynamic)companyDict["id"],
CompanyCode = (string)companyDict["companyCode"],
CompanyName = (string)companyDict["companyName"],
ContactPerson = (string?)companyDict["contactPerson"],
Phone = (string?)companyDict["phone"],
Email = (string?)companyDict["email"],
IsActive = (bool)(dynamic)companyDict["isActive"],
CreatedAt = DateTime.Parse(companyDict["createdAt"].ToString()!)
});
}
}
}
}
}
catch (Exception ex)
{
Snackbar.Add($"고객사 로드 실패: {ex.Message}", Severity.Error);
}
finally
{
isLoading = false;
}
}
private async Task NextPage()
{
currentPage++;
await LoadData();
}
private async Task PreviousPage()
{
currentPage = Math.Max(1, currentPage - 1);
await LoadData();
}
private class CompanyDto
{
public int Id { get; set; }
public string CompanyCode { get; set; } = "";
public string CompanyName { get; set; } = "";
public string? ContactPerson { get; set; }
public string? Phone { get; set; }
public string? Email { get; set; }
public bool IsActive { get; set; }
public DateTime CreatedAt { get; set; }
}
}
@@ -0,0 +1,287 @@
@page "/admin/consulting-activities"
@using TaxBaik.Web.Services.AdminClients
@using TaxBaik.WasmClient.Components.Admin.Shared
@inject IConsultingActivityBrowserClient ActivityClient
@inject IClientBrowserClient ClientClient
@inject ISnackbar Snackbar
@inject IDialogService DialogService
@attribute [Authorize]
<PageTitle>상담 활동 관리</PageTitle>
<section class="admin-page-hero">
<div>
<MudText Typo="Typo.caption" Class="admin-eyebrow">CRM & 세무관리</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" OnClick="OpenCreateDialog" StartIcon="@Icons.Material.Filled.Add">
새 활동 기록
</MudButton>
</section>
<AdminDataPanel Loading="@(activities is null)" SkeletonContent="@ActivitySkeleton">
@if (activities is null)
{
}
else if (activities.Count == 0)
{
<MudAlert Severity="Severity.Info" Class="mt-4">
<MudIcon Icon="@Icons.Material.Filled.Timeline" Class="me-2" />
상담 활동이 없습니다.
</MudAlert>
}
else
{
<MudDataGrid T="ConsultingActivity"
Items="@activities"
Dense="true"
Hover="true"
Striped="true"
Virtualize="true"
RowsPerPage="30"
Class="admin-grid">
<Columns>
<PropertyColumn Property="x => x.Id" Title="ID" Sortable="true" />
<TemplateColumn Title="고객">
<CellTemplate>
@if (clientMap.TryGetValue(context.Item.ClientId, out var clientName))
{
<MudLink Href="@($"/taxbaik/admin/clients/{context.Item.ClientId}")" Color="Color.Primary">
@clientName
</MudLink>
}
</CellTemplate>
</TemplateColumn>
<PropertyColumn Property="x => x.ActivityType" Title="활동 유형" />
<PropertyColumn Property="x => x.ActivityDate" Title="활동일시" Format="g" />
<TemplateColumn Title="설명">
<CellTemplate>
@{
var desc = context.Item.Description ?? "";
if (desc.Length > 30) desc = desc.Substring(0, 30) + "...";
}
<span>@desc</span>
</CellTemplate>
</TemplateColumn>
<TemplateColumn Title="다음 팔로업">
<CellTemplate>
@if (context.Item.NextFollowupDate.HasValue)
{
var daysLeft = (context.Item.NextFollowupDate.Value.Date - DateTime.Today).Days;
<MudChip Size="Size.Small"
Color="@(daysLeft < 0 ? Color.Error : daysLeft <= 3 ? Color.Warning : Color.Success)"
Variant="Variant.Filled">
@context.Item.NextFollowupDate.Value.ToString("yyyy-MM-dd")
</MudChip>
}
</CellTemplate>
</TemplateColumn>
<TemplateColumn Title="작업" Sortable="false">
<CellTemplate>
<MudButtonGroup Size="Size.Small" Variant="Variant.Outlined">
<MudIconButton Icon="@Icons.Material.Filled.Edit" OnClick="@(async () => await OpenEditDialog(context.Item))" />
<MudIconButton Icon="@Icons.Material.Filled.Delete" Color="Color.Error"
OnClick="@(async () => await DeleteActivity(context.Item.Id))" />
</MudButtonGroup>
</CellTemplate>
</TemplateColumn>
</Columns>
</MudDataGrid>
}
</AdminDataPanel>
<MudDialog @bind-IsVisible="isDialogOpen" Options="new DialogOptions { MaxWidth = MaxWidth.Small, FullWidth = true }">
<TitleContent>
<MudText Typo="Typo.h6">@(editingActivity == null ? "새 활동 기록" : "활동 기록 수정")</MudText>
</TitleContent>
<DialogContent>
<MudForm @ref="form">
<MudSelect T="int" @bind-Value="activityForm.ClientId" Label="고객" Required="true" Variant="Variant.Outlined" FullWidth="true" Class="mb-4">
@foreach (var client in clients)
{
<MudSelectItem Value="@client.Id">@GetClientDisplayName(client)</MudSelectItem>
}
</MudSelect>
<CommonCodeSelect @bind-Value="activityForm.ActivityType" Group="CONSULTING_ACTIVITY_TYPE" Label="활동 유형" Class="mb-4" Required="true" />
<MudDatePicker @bind-Date="activityForm.ActivityDate" Label="활동일" Variant="Variant.Outlined" FullWidth="true" Class="mb-4" Required="true" />
<MudTextField T="string" @bind-Value="activityForm.Description" Label="설명" Variant="Variant.Outlined" FullWidth="true" Lines="3" Class="mb-4" Required="true" />
<MudDatePicker @bind-Date="activityForm.NextFollowupDate" Label="다음 팔로업일" Variant="Variant.Outlined" FullWidth="true" Class="mb-4" />
</MudForm>
</DialogContent>
<DialogActions>
<MudButton OnClick="CloseDialog">취소</MudButton>
<MudButton Color="Color.Primary" OnClick="SaveActivity">저장</MudButton>
</DialogActions>
</MudDialog>
@code {
[CascadingParameter]
private Task<AuthenticationState>? AuthStateTask { get; set; }
private List<ConsultingActivity>? activities;
private List<Client> clients = [];
private Dictionary<int, string> clientMap = new();
private MudForm? form;
private bool isDialogOpen;
private ConsultingActivity? editingActivity;
private ConsultingActivityForm activityForm = new();
private RenderFragment ActivitySkeleton => builder =>
{
builder.OpenComponent<AdminSkeletonRows>(0);
builder.AddAttribute(1, "Rows", 5);
builder.AddAttribute(2, "Columns", 4);
builder.CloseComponent();
};
protected override async Task OnInitializedAsync()
{
if (AuthStateTask != null)
{
var authState = await AuthStateTask;
if (authState.User.Identity?.IsAuthenticated == true)
{
await LoadData();
}
}
}
private async Task LoadData()
{
try
{
activities = await ActivityClient.GetAllAsync();
var (clientItems, _) = await ClientClient.GetPagedAsync(pageSize: 1000);
clients = clientItems.ToList();
clientMap = clients.ToDictionary(c => c.Id, GetClientDisplayName);
}
catch (Exception ex)
{
Snackbar.Add($"데이터 로드 실패: {ex.Message}", Severity.Error);
}
}
private void OpenCreateDialog()
{
editingActivity = null;
activityForm = new ConsultingActivityForm
{
ActivityDate = DateTime.Now,
ClientId = clients.FirstOrDefault()?.Id ?? 0
};
isDialogOpen = true;
}
private async Task OpenEditDialog(ConsultingActivity activity)
{
editingActivity = activity;
activityForm = new ConsultingActivityForm
{
ClientId = activity.ClientId,
ActivityType = activity.ActivityType,
ActivityDate = activity.ActivityDate,
Description = activity.Description,
NextFollowupDate = activity.NextFollowupDate
};
isDialogOpen = true;
}
private async Task SaveActivity()
{
if (form != null)
{
await form.Validate();
if (!form.IsValid)
{
Snackbar.Add("필수 항목을 입력해주세요.", Severity.Warning);
return;
}
}
try
{
if (editingActivity == null)
{
var actDate = activityForm.ActivityDate ?? DateTime.Now;
var newId = await ActivityClient.CreateAsync(
activityForm.ClientId,
activityForm.ActivityType,
actDate,
activityForm.Description,
null,
activityForm.NextFollowupDate);
if (newId > 0)
{
Snackbar.Add("활동이 기록되었습니다.", Severity.Success);
CloseDialog();
await LoadData();
}
}
else
{
await ActivityClient.UpdateAsync(
editingActivity.Id,
null,
activityForm.NextFollowupDate);
Snackbar.Add("활동이 업데이트되었습니다.", Severity.Success);
CloseDialog();
await LoadData();
}
}
catch (Exception ex)
{
Snackbar.Add($"저장 실패: {ex.Message}", Severity.Error);
}
}
private async Task DeleteActivity(int id)
{
var parameters = new DialogParameters
{
{ "Title", "삭제 확인" },
{ "Message", "이 활동을 삭제하시겠습니까?" }
};
var dialog = await DialogService.ShowAsync<ConfirmDialog>("", parameters);
var result = await dialog.Result;
if (result?.Canceled ?? true)
return;
try
{
await ActivityClient.DeleteAsync(id);
Snackbar.Add("활동이 삭제되었습니다.", Severity.Success);
await LoadData();
}
catch (Exception ex)
{
Snackbar.Add($"삭제 실패: {ex.Message}", Severity.Error);
}
}
private void CloseDialog()
{
isDialogOpen = false;
editingActivity = null;
activityForm = new();
}
private static string GetClientDisplayName(Client client)
=> !string.IsNullOrWhiteSpace(client.CompanyName)
? client.CompanyName
: !string.IsNullOrWhiteSpace(client.Name)
? client.Name
: $"Client #{client.Id}";
private class ConsultingActivityForm
{
public int ClientId { get; set; }
public string ActivityType { get; set; } = "";
public DateTime? ActivityDate { get; set; } = DateTime.Now;
public string Description { get; set; } = "";
public DateTime? NextFollowupDate { get; set; }
}
}
@@ -0,0 +1,303 @@
@page "/admin/contracts"
@using TaxBaik.Web.Services.AdminClients
@using TaxBaik.WasmClient.Components.Admin.Shared
@inject IContractBrowserClient ContractClient
@inject IClientBrowserClient ClientClient
@inject ISnackbar Snackbar
@inject IDialogService DialogService
@attribute [Authorize]
<PageTitle>계약 관리</PageTitle>
<section class="admin-page-hero">
<div>
<MudText Typo="Typo.caption" Class="admin-eyebrow">CRM & 세무관리</MudText>
<MudText Typo="Typo.h4" Class="admin-page-title">계약 관리</MudText>
<MudText Typo="Typo.body2" Class="admin-page-subtitle">고객 계약과 월 정기수익을 함께 관리합니다.</MudText>
@if (mrr > 0)
{
<MudText Typo="Typo.body2" Class="mt-2">
월 정기수익:
<MudChip Size="Size.Small" Color="Color.Primary" Variant="Variant.Filled">₩@mrr.ToString("N0")</MudChip>
</MudText>
}
</div>
<MudButton Variant="Variant.Filled" Color="Color.Primary" OnClick="PrepareCreate" StartIcon="@Icons.Material.Filled.Add" id="btn-add-contract">
새 계약 추가
</MudButton>
</section>
<AdminEditorPanel Loading="@(contracts is null)" SkeletonContent="@ContractSkeleton">
@if (contracts is null)
{
}
else
{
<MudGrid Spacing="2" Class="mt-2">
<!-- Left: Dense Grid List -->
<MudItem XS="12" MD="8">
@if (contracts.Count == 0)
{
<MudAlert Severity="Severity.Info">
<MudIcon Icon="@Icons.Material.Filled.Description" Class="me-2" />
계약이 없습니다.
</MudAlert>
}
else
{
<MudDataGrid T="Contract"
Items="@contracts"
Dense="true"
Hover="true"
Striped="true"
Virtualize="true"
RowsPerPage="30"
SelectedItem="@selectedContract"
SelectedItemChanged="OnRowSelected"
Class="admin-grid">
<Columns>
<PropertyColumn Property="x => x.Id" Title="ID" Sortable="true" />
<TemplateColumn Title="고객">
<CellTemplate>
@if (clientMap.TryGetValue(context.Item.ClientId, out var clientName))
{
@clientName
}
</CellTemplate>
</TemplateColumn>
<PropertyColumn Property="x => x.ContractNumber" Title="계약번호" />
<PropertyColumn Property="x => x.ServiceType" Title="서비스 유형" />
<PropertyColumn Property="x => x.MonthlyFee" Title="월 수수료" Format="C" />
<TemplateColumn Title="계약기간">
<CellTemplate>
@context.Item.StartDate.ToString("yyyy-MM-dd")
@if (context.Item.EndDate.HasValue)
{
<span>~@context.Item.EndDate.Value.ToString("yyyy-MM-dd")</span>
}
</CellTemplate>
</TemplateColumn>
<TemplateColumn Title="상태">
<CellTemplate>
@{
var isActive = !context.Item.EndDate.HasValue || context.Item.EndDate.Value >= DateTime.Today;
}
@if (isActive)
{
<MudChip Size="Size.Small" Color="Color.Success" Variant="Variant.Filled">활성</MudChip>
}
else
{
<MudChip Size="Size.Small" Color="Color.Default" Variant="Variant.Outlined">만료</MudChip>
}
</CellTemplate>
</TemplateColumn>
<TemplateColumn Title="작업" Sortable="false">
<CellTemplate>
<MudIconButton Icon="@Icons.Material.Filled.Delete" Color="Color.Error" Size="Size.Small"
OnClick="@(async () => await DeleteContract(context.Item.Id))" />
</CellTemplate>
</TemplateColumn>
</Columns>
</MudDataGrid>
}
</MudItem>
<!-- Right: Detail Form Panel (Inline Editor) -->
<MudItem XS="12" MD="4">
<MudPaper Class="pa-4 admin-surface admin-editor-panel" Elevation="0" Style="border: 1px solid var(--border-color); min-height: 400px;">
<div class="d-flex align-center justify-space-between mb-4">
<MudText Typo="Typo.h6" Class="font-weight-bold">@(isEditMode ? "계약 상세 정보" : "새 계약 추가")</MudText>
@if (isEditMode)
{
<MudButton Size="Size.Small" Variant="Variant.Outlined" Color="Color.Secondary" OnClick="PrepareCreate">
새로 작성
</MudButton>
}
</div>
<MudForm @ref="form">
<MudSelect T="int?" @bind-Value="contractForm.ClientId" Label="고객" Required="true" Variant="Variant.Outlined" FullWidth="@true" Class="mb-3" RequiredError="고객을 선택하세요." Disabled="@isEditMode">
@foreach (var client in clients)
{
<MudSelectItem Value="@((int?)client.Id)">@GetClientDisplayName(client)</MudSelectItem>
}
</MudSelect>
<MudTextField T="string" @bind-Value="contractForm.ContractNumber" Label="계약번호" Variant="Variant.Outlined" FullWidth="@true" Class="mb-3" Required="true" />
<CommonCodeSelect @bind-Value="contractForm.ServiceType" Group="CONTRACT_SERVICE_TYPE" Label="서비스 유형" Class="mb-3" Required="true" />
<MudDatePicker @bind-Date="contractForm.StartDate" Label="계약 시작일" Variant="Variant.Outlined" FullWidth="@true" Class="mb-3" Required="true" />
<MudNumericField T="decimal?" @bind-Value="contractForm.MonthlyFee" Label="월 수수료" Variant="Variant.Outlined" FullWidth="@true" Class="mb-4" />
<div class="d-flex justify-end gap-2">
@if (isEditMode)
{
<MudButton Variant="Variant.Outlined" Color="Color.Error" OnClick="@(async () => await DeleteContract(selectedContract?.Id ?? 0))">삭제</MudButton>
}
else
{
<MudButton Variant="Variant.Filled" Color="Color.Primary" OnClick="SaveContract" id="btn-save-contract">저장</MudButton>
}
</div>
</MudForm>
</MudPaper>
</MudItem>
</MudGrid>
}
</AdminEditorPanel>
@code {
[CascadingParameter]
private Task<AuthenticationState>? AuthStateTask { get; set; }
private List<Contract>? contracts;
private List<Client> clients = [];
private Dictionary<int, string> clientMap = new();
private decimal mrr = 0;
private MudForm? form;
private bool isEditMode;
private Contract? selectedContract;
private ContractForm contractForm = new();
private RenderFragment ContractSkeleton => builder =>
{
builder.OpenComponent<AdminSkeletonRows>(0);
builder.AddAttribute(1, "Rows", 6);
builder.AddAttribute(2, "Columns", 4);
builder.CloseComponent();
};
protected override async Task OnInitializedAsync()
{
if (AuthStateTask != null)
{
var authState = await AuthStateTask;
if (authState.User.Identity?.IsAuthenticated == true)
{
await LoadData();
PrepareCreate();
}
}
}
private async Task LoadData()
{
try
{
contracts = await ContractClient.GetAllAsync();
var (clientItems, _) = await ClientClient.GetPagedAsync(pageSize: 1000);
clients = clientItems.ToList();
clientMap = clients.ToDictionary(c => c.Id, GetClientDisplayName);
mrr = await ContractClient.GetMonthlyRecurringRevenueAsync();
}
catch (Exception ex)
{
Snackbar.Add($"데이터 로드 실패: {ex.Message}", Severity.Error);
}
}
private void PrepareCreate()
{
selectedContract = null;
isEditMode = false;
contractForm = new ContractForm
{
ClientId = clients.FirstOrDefault()?.Id,
StartDate = DateTime.Today
};
}
private void OnRowSelected(Contract contract)
{
if (contract == null) return;
selectedContract = contract;
isEditMode = true;
contractForm = new ContractForm
{
ClientId = contract.ClientId,
ContractNumber = contract.ContractNumber,
ServiceType = contract.ServiceType,
StartDate = contract.StartDate,
MonthlyFee = contract.MonthlyFee
};
}
private async Task SaveContract()
{
if (form != null)
{
await form.Validate();
if (!form.IsValid)
{
Snackbar.Add("필수 항목을 입력해주세요.", Severity.Warning);
return;
}
}
try
{
if (contractForm.ClientId == null) return;
var newId = await ContractClient.CreateAsync(
contractForm.ClientId.Value,
contractForm.ContractNumber,
contractForm.ServiceType,
contractForm.StartDate ?? DateTime.Now,
contractForm.MonthlyFee);
if (newId > 0)
{
Snackbar.Add("계약이 추가되었습니다.", Severity.Success);
PrepareCreate();
await LoadData();
}
}
catch (Exception ex)
{
Snackbar.Add($"저장 실패: {ex.Message}", Severity.Error);
}
}
private async Task DeleteContract(int id)
{
var parameters = new DialogParameters
{
{ "Title", "삭제 확인" },
{ "Message", "이 계약을 삭제하시겠습니까?" }
};
var dialog = await DialogService.ShowAsync<ConfirmDialog>("", parameters);
var result = await dialog.Result;
if (result?.Canceled ?? true)
return;
try
{
await ContractClient.DeleteAsync(id);
Snackbar.Add("계약이 삭제되었습니다.", Severity.Success);
if (selectedContract?.Id == id)
{
PrepareCreate();
}
await LoadData();
}
catch (Exception ex)
{
Snackbar.Add($"삭제 실패: {ex.Message}", Severity.Error);
}
}
private static string GetClientDisplayName(Client client)
=> !string.IsNullOrWhiteSpace(client.CompanyName)
? client.CompanyName
: !string.IsNullOrWhiteSpace(client.Name)
? client.Name
: $"Client #{client.Id}";
private class ContractForm
{
public int? ClientId { get; set; }
public string ContractNumber { get; set; } = "";
public string ServiceType { get; set; } = "";
public DateTime? StartDate { get; set; }
public decimal? MonthlyFee { get; set; }
}
}
@@ -0,0 +1,201 @@
@page "/admin/dashboard"
@attribute [Authorize]
@using TaxBaik.Web.Services
@using TaxBaik.WasmClient.Components.Admin.Shared
@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>
@if (!string.IsNullOrEmpty(errorMessage))
{
<MudAlert Severity="Severity.Error" Class="mb-4">@errorMessage</MudAlert>
}
<AdminDataPanel Loading="@isLoading" SkeletonContent="@DashboardSkeleton">
<div class="admin-metric-grid">
<AdminMetricCard Label="이번달 문의" Value="@summary.ThisMonthInquiries" Caption="월간 상담 유입 (클릭 시 이동)" Accent="accent-blue" Icon="💬" ValueColor="var(--primary-dark)" IconColor="var(--primary-color)" OnClick="@GoInquiries" />
<AdminMetricCard Label="신규 문의" Value="@summary.NewInquiries" Caption="처리 대기 (클릭 시 이동)" Accent="accent-amber" Icon="⚠️" ValueColor="var(--tertiary-dark)" IconColor="var(--tertiary-color)" OnClick="@GoNewInquiries" />
<AdminMetricCard Label="전체 포스트" Value="@summary.TotalPosts" Caption="콘텐츠 자산 (클릭 시 이동)" Accent="accent-slate" Icon="📄" ValueColor="#455a64" IconColor="#607d8b" OnClick="@GoBlog" />
<AdminMetricCard Label="발행된 포스트" Value="@summary.PublishedPosts" Caption="검색 노출 대상 (클릭 시 이동)" Accent="accent-green" Icon="🌐" ValueColor="var(--secondary-dark)" IconColor="var(--secondary-color)" OnClick="@GoBlog" />
</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 = BusinessDayCalculator.GetDday(DateOnly.FromDateTime(f.DueDate));
var effectiveDueDate = BusinessDayCalculator.GetEffectiveDueDate(DateOnly.FromDateTime(f.DueDate));
<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>@effectiveDueDate.ToDateTime(TimeOnly.MinValue).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>
</AdminDataPanel>
@code {
[CascadingParameter]
private Task<AuthenticationState>? AuthStateTask { get; set; }
private AdminDashboardSummary summary = new(0, 0, 0, 0, []);
private List<Domain.Entities.TaxFiling> upcomingFilings = [];
private string? errorMessage;
private bool isLoading = true;
private RenderFragment DashboardSkeleton => builder =>
{
builder.OpenComponent<AdminSkeletonRows>(0);
builder.AddAttribute(1, "Rows", 6);
builder.AddAttribute(2, "Columns", 4);
builder.CloseComponent();
};
private void GoInquiries()
{
Nav.NavigateTo("/taxbaik/admin/inquiries");
}
private void GoNewInquiries()
{
Nav.NavigateTo("/taxbaik/admin/inquiries?status=new");
}
private void GoBlog()
{
Nav.NavigateTo("/taxbaik/admin/blog");
}
protected override async Task OnInitializedAsync()
{
if (AuthStateTask != null)
{
var authState = await AuthStateTask;
if (authState.User.Identity?.IsAuthenticated == true)
{
try
{
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
};
}
@@ -0,0 +1,146 @@
@page "/admin/faqs/create"
@page "/admin/faqs/{Id:int}/edit"
@attribute [Authorize]
@using TaxBaik.Web.Services
@using TaxBaik.Domain.Entities
@inject IFaqBrowserClient FaqClient
@inject NavigationManager Navigation
@inject ISnackbar Snackbar
<PageTitle>@(Id.HasValue ? "FAQ 수정" : "FAQ 등록")</PageTitle>
<section class="admin-page-hero">
<div>
<MudText Typo="Typo.caption" Class="admin-eyebrow">홈페이지</MudText>
<MudText Typo="Typo.h4" Class="admin-page-title">@(Id.HasValue ? "FAQ 수정" : "FAQ 등록")</MudText>
</div>
<MudButton Variant="Variant.Outlined" Href="/taxbaik/admin/faqs"
StartIcon="@Icons.Material.Filled.ArrowBack">목록으로</MudButton>
</section>
<AdminEditorPanel Loading="@isLoading" SkeletonContent="@FaqSkeleton">
<MudPaper Class="admin-surface" Elevation="0" Style="max-width:720px;">
<MudForm @ref="form" @bind-IsValid="isValid">
<MudGrid Spacing="3">
<MudItem xs="12">
<MudTextField @bind-Value="faq.Question"
Label="질문 *" Required="true"
RequiredError="질문을 입력하세요."
Counter="300" MaxLength="300"
Lines="2" AutoGrow="true"
Placeholder="예: 기장료가 얼마인지 미리 알 수 있나요?" />
</MudItem>
<MudItem xs="12">
<MudTextField @bind-Value="faq.Answer"
Label="답변 *" Required="true"
RequiredError="답변을 입력하세요."
Lines="5" AutoGrow="true"
Placeholder="방문자에게 보여질 답변을 입력하세요." />
</MudItem>
<MudItem xs="12" md="6">
<CommonCodeSelect @bind-Value="faq.Category" Group="FAQ_CATEGORY" Label="카테고리" Clearable="true" Placeholder="전체" />
</MudItem>
<MudItem xs="12" md="3">
<MudNumericField @bind-Value="faq.SortOrder"
Label="정렬 순서"
HelperText="작을수록 위에 노출"
Min="0" Max="9999" />
</MudItem>
<MudItem xs="12" md="3" Class="d-flex align-center">
<MudSwitch T="bool" @bind-Value="faq.IsActive" Color="Color.Success"
Label="@(faq.IsActive ? "노출 중" : "비활성")" />
</MudItem>
<MudItem xs="12" Class="d-flex gap-2 mt-2">
<MudButton Variant="Variant.Filled" Color="Color.Primary"
StartIcon="@Icons.Material.Filled.Save"
OnClick="@SaveAsync" Disabled="@isSaving">
@(isSaving ? "저장 중..." : "저장")
</MudButton>
<MudButton Variant="Variant.Outlined" Href="/taxbaik/admin/faqs">
취소
</MudButton>
</MudItem>
</MudGrid>
</MudForm>
</MudPaper>
</AdminEditorPanel>
@code {
[Parameter] public int? Id { get; set; }
private MudForm form = null!;
private Faq faq = new() { SortOrder = 10, IsActive = true };
private bool isValid;
private bool isLoading = true;
private bool isSaving;
private RenderFragment FaqSkeleton => builder =>
{
builder.OpenComponent<AdminSkeletonRows>(0);
builder.AddAttribute(1, "Rows", 5);
builder.AddAttribute(2, "Columns", 3);
builder.CloseComponent();
};
protected override async Task OnInitializedAsync()
{
if (Id.HasValue)
{
try
{
var existing = await FaqClient.GetByIdAsync(Id.Value);
if (existing is null)
{
Snackbar.Add("FAQ를 찾을 수 없습니다.", Severity.Error);
Navigation.NavigateTo("/taxbaik/admin/faqs");
return;
}
faq = existing;
}
catch (Exception ex)
{
Snackbar.Add($"오류: {ex.Message}", Severity.Error);
Navigation.NavigateTo("/taxbaik/admin/faqs");
return;
}
}
isLoading = false;
}
private async Task SaveAsync()
{
await form.Validate();
if (!isValid) return;
isSaving = true;
try
{
if (Id.HasValue)
{
var result = await FaqClient.UpdateAsync(Id.Value, faq);
if (result != null)
Snackbar.Add("FAQ가 수정되었습니다.", Severity.Success);
else
Snackbar.Add("수정 실패", Severity.Error);
}
else
{
var result = await FaqClient.CreateAsync(faq);
if (result != null)
Snackbar.Add("FAQ가 등록되었습니다.", Severity.Success);
else
Snackbar.Add("등록 실패", Severity.Error);
}
Navigation.NavigateTo("/taxbaik/admin/faqs");
}
catch (Exception ex)
{
Snackbar.Add($"저장 실패: {ex.Message}", Severity.Error);
}
finally
{
isSaving = false;
}
}
}
@@ -0,0 +1,238 @@
@page "/admin/faqs"
@attribute [Authorize]
@using TaxBaik.Web.Services
@using TaxBaik.Domain.Entities
@inject IFaqBrowserClient FaqClient
@inject NavigationManager Navigation
@inject IDialogService DialogService
@inject ISnackbar Snackbar
<PageTitle>FAQ 관리</PageTitle>
<section class="admin-page-hero">
<div>
<MudText Typo="Typo.caption" Class="admin-eyebrow">홈페이지</MudText>
<MudText Typo="Typo.h4" Class="admin-page-title">FAQ 관리</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/faqs/create">
FAQ 등록
</MudButton>
</section>
<div class="d-flex pa-4 gap-4 align-center">
<MudTextField @bind-Value="searchQuery" Placeholder="질문 또는 답변 검색..." Adornment="Adornment.Start"
AdornmentIcon="@Icons.Material.Filled.Search" IconSize="Size.Medium" Class="flex-grow-1" Immediate="true" Clearable="true" />
</div>
<AdminDataPanel Loading="@(faqs is null)" SkeletonContent="@FaqListSkeleton">
@if (faqs is null)
{
}
else if (!FilteredFaqs.Any())
{
<div class="pa-6 text-center">
<MudIcon Icon="@Icons.Material.Filled.QuestionAnswer" Style="font-size:3rem; opacity:.3;" />
<MudText Class="mt-2 text-muted">검색 조건에 맞는 FAQ가 없습니다.</MudText>
</div>
}
else
{
<MudSimpleTable Striped="true" Dense="true" Class="admin-table">
<thead>
<tr>
<th style="width:110px;">순서</th>
<th>질문</th>
<th style="width:130px;">카테고리</th>
<th style="width:90px;">상태</th>
<th style="width:160px;"></th>
</tr>
</thead>
<tbody>
@foreach (var item in FilteredFaqs)
{
<tr>
<td>
<div class="d-flex align-center justify-start gap-1">
<MudText Typo="Typo.body2" Class="mr-2">@item.SortOrder</MudText>
<MudIconButton Icon="@Icons.Material.Filled.ArrowDropUp" Size="Size.Small" OnClick="@(() => MoveUpAsync(item))" Style="padding:2px;" Dense="true" />
<MudIconButton Icon="@Icons.Material.Filled.ArrowDropDown" Size="Size.Small" OnClick="@(() => MoveDownAsync(item))" Style="padding:2px;" Dense="true" />
</div>
</td>
<td>
<MudText Typo="Typo.body2" Style="max-width:480px; white-space:nowrap; overflow:hidden; text-overflow:ellipsis;">
@item.Question
</MudText>
</td>
<td>
@if (!string.IsNullOrEmpty(item.Category))
{
<MudChip Size="Size.Small" Color="Color.Default">@item.Category</MudChip>
}
</td>
<td>
@if (item.IsActive)
{
<MudChip Size="Size.Small" Color="Color.Success">노출 중</MudChip>
}
else
{
<MudChip Size="Size.Small" Color="Color.Default">비활성</MudChip>
}
</td>
<td>
<MudButtonGroup Size="Size.Small" Variant="Variant.Outlined">
<MudButton @onclick="@(() => Navigation.NavigateTo($"/taxbaik/admin/faqs/{item.Id}/edit"))">
수정
</MudButton>
<MudButton Color="Color.Error" @onclick="@(() => DeleteAsync(item))">
삭제
</MudButton>
</MudButtonGroup>
</td>
</tr>
}
</tbody>
</MudSimpleTable>
<MudText Typo="Typo.caption" Class="pa-2 text-muted">
검색 결과 @(FilteredFaqs.Count())개 · 총 @(faqs.Count)개 · 노출 중 @(faqs.Count(f => f.IsActive))개
</MudText>
}
</AdminDataPanel>
@code {
[CascadingParameter]
private Task<AuthenticationState>? AuthStateTask { get; set; }
private List<Faq>? faqs;
private string searchQuery = "";
private RenderFragment FaqListSkeleton => builder =>
{
builder.OpenComponent<AdminSkeletonRows>(0);
builder.AddAttribute(1, "Rows", 5);
builder.AddAttribute(2, "Columns", 4);
builder.CloseComponent();
};
private IEnumerable<Faq> FilteredFaqs => faqs?
.Where(f => string.IsNullOrEmpty(searchQuery) ||
f.Question.Contains(searchQuery, StringComparison.OrdinalIgnoreCase) ||
(f.Answer != null && f.Answer.Contains(searchQuery, StringComparison.OrdinalIgnoreCase)))
.OrderBy(f => f.SortOrder) ?? Enumerable.Empty<Faq>();
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
{
faqs = (await FaqClient.GetAllAsync()).OrderBy(f => f.SortOrder).ToList();
}
catch (Exception ex)
{
Snackbar.Add($"오류: {ex.Message}", Severity.Error);
faqs = [];
}
}
private async Task MoveUpAsync(Faq item)
{
if (faqs == null) return;
var sorted = faqs.OrderBy(f => f.SortOrder).ToList();
var index = sorted.IndexOf(item);
if (index <= 0) return;
var prev = sorted[index - 1];
var temp = item.SortOrder;
item.SortOrder = prev.SortOrder;
prev.SortOrder = temp;
if (item.SortOrder == prev.SortOrder)
{
prev.SortOrder = item.SortOrder + 1;
}
try
{
await FaqClient.UpdateAsync(item.Id, item);
await FaqClient.UpdateAsync(prev.Id, prev);
Snackbar.Add("순서가 상향되었습니다.", Severity.Success);
await LoadAsync();
}
catch (Exception ex)
{
Snackbar.Add($"순서 조정 실패: {ex.Message}", Severity.Error);
}
}
private async Task MoveDownAsync(Faq item)
{
if (faqs == null) return;
var sorted = faqs.OrderBy(f => f.SortOrder).ToList();
var index = sorted.IndexOf(item);
if (index < 0 || index >= sorted.Count - 1) return;
var next = sorted[index + 1];
var temp = item.SortOrder;
item.SortOrder = next.SortOrder;
next.SortOrder = temp;
if (item.SortOrder == next.SortOrder)
{
next.SortOrder = item.SortOrder + 1;
}
try
{
await FaqClient.UpdateAsync(item.Id, item);
await FaqClient.UpdateAsync(next.Id, next);
Snackbar.Add("순서가 하향되었습니다.", Severity.Success);
await LoadAsync();
}
catch (Exception ex)
{
Snackbar.Add($"순서 조정 실패: {ex.Message}", Severity.Error);
}
}
private async Task DeleteAsync(Faq item)
{
var confirmed = await DialogService.ShowMessageBox(
"FAQ 삭제",
$"'{item.Question}' 항목을 삭제하시겠습니까?",
yesText: "삭제", cancelText: "취소");
if (confirmed != true) return;
try
{
var success = await FaqClient.DeleteAsync(item.Id);
if (success)
{
Snackbar.Add("FAQ가 삭제되었습니다.", Severity.Success);
await LoadAsync();
}
else
{
Snackbar.Add("삭제 실패", Severity.Error);
}
}
catch (Exception ex)
{
Snackbar.Add($"오류: {ex.Message}", Severity.Error);
}
}
}
@@ -0,0 +1,59 @@
@page "/admin/inquiries/create"
@attribute [Authorize]
@using TaxBaik.Application.DTOs
@using TaxBaik.WasmClient.Components.Admin.Forms
@inject IInquiryBrowserClient InquiryClient
@inject NavigationManager Navigation
@inject ISnackbar Snackbar
<PageTitle>문의 등록</PageTitle>
<AdminCrudPageShell Title="새 문의 등록"
Eyebrow="Customer Relations"
Subtitle="고객 문의를 등록합니다. (전화, 오프라인 등)"
Loading="@false"
OnCancel="@GoBack">
<MudPaper Class="pa-4 mt-4" Elevation="1">
<InquiryForm ButtonText="등록" OnSubmit="HandleCreate" OnCancel="GoBack" />
</MudPaper>
</AdminCrudPageShell>
@code {
private void GoBack()
{
Navigation.NavigateTo("/taxbaik/admin/inquiries");
}
private async Task HandleCreate(InquiryForm.InquiryFormModel model)
{
try
{
var result = await InquiryClient.CreateAsync(new SubmitInquiryDto
{
Name = model.Name,
Phone = model.Phone,
Email = model.Email,
ServiceType = model.ServiceType,
Message = model.Message,
SuppressNotification = true
});
if (result == null)
{
Snackbar.Add("문의가 등록되지 않았습니다.", Severity.Error);
return;
}
Snackbar.Add("문의가 등록되었습니다.", Severity.Success);
Navigation.NavigateTo("/taxbaik/admin/inquiries");
}
catch (ValidationException ex)
{
Snackbar.Add(ex.Message, Severity.Error);
}
catch (Exception ex)
{
Snackbar.Add($"등록 실패: {ex.Message}", Severity.Error);
}
}
}
@@ -0,0 +1,204 @@
@page "/admin/inquiries/{InquiryId:int}"
@attribute [Authorize]
@using TaxBaik.Web.Services
@inject IInquiryBrowserClient InquiryClient
@inject NavigationManager Navigation
@inject ISnackbar Snackbar
<PageTitle>문의 상세</PageTitle>
<section class="admin-page-hero">
<div>
<MudText Typo="Typo.caption" Class="admin-eyebrow">Inquiry Details</MudText>
<MudText Typo="Typo.h4" Class="admin-page-title">문의 상세</MudText>
<MudText Typo="Typo.body2" Class="admin-page-subtitle">문의 정보를 확인하고 처리 상태를 관리합니다.</MudText>
</div>
</section>
@if (inquiry != null)
{
<MudButton Variant="Variant.Outlined"
Color="Color.Primary"
StartIcon="@Icons.Material.Filled.ArrowBack"
@onclick="@(() => Navigation.NavigateTo("/taxbaik/admin/inquiries"))">
문의 목록으로
</MudButton>
<MudGrid Class="mt-4">
<MudItem xs="12" md="8">
<AdminDetailSection Title="문의 정보">
<MudGrid>
<MudItem xs="12" sm="6">
<MudText Typo="Typo.subtitle2" Color="Color.Secondary">이름</MudText>
<MudText>@inquiry.Name</MudText>
</MudItem>
<MudItem xs="12" sm="6">
<MudText Typo="Typo.subtitle2" Color="Color.Secondary">연락처</MudText>
<MudText>@inquiry.Phone</MudText>
</MudItem>
<MudItem xs="12" sm="6">
<MudText Typo="Typo.subtitle2" Color="Color.Secondary">이메일</MudText>
<MudText>@(inquiry.Email ?? "-")</MudText>
</MudItem>
<MudItem xs="12" sm="6">
<MudText Typo="Typo.subtitle2" Color="Color.Secondary">분야</MudText>
<MudText>@inquiry.ServiceType</MudText>
</MudItem>
<MudItem xs="12">
<MudText Typo="Typo.subtitle2" Color="Color.Secondary">문의 내용</MudText>
<MudPaper Class="pa-3 mt-1" Outlined="true">
<MudText Style="white-space: pre-wrap;">@inquiry.Message</MudText>
</MudPaper>
</MudItem>
<MudItem xs="12">
<MudText Typo="Typo.subtitle2" Color="Color.Secondary">접수일시</MudText>
<MudText>@inquiry.CreatedAt.ToLocalTime().ToString("yyyy-MM-dd HH:mm")</MudText>
</MudItem>
</MudGrid>
</AdminDetailSection>
<AdminDetailSection Title="담당자 메모" CssClass="pa-4 mt-4">
<MudTextField T="string" @bind-Value="adminMemo" Label="내부 메모 (고객에게 미노출)"
Lines="4" Variant="Variant.Outlined" />
<MudButton Class="mt-2" Variant="Variant.Filled" Color="Color.Primary"
OnClick="SaveMemo">메모 저장</MudButton>
</AdminDetailSection>
</MudItem>
<MudItem xs="12" md="4">
<AdminDetailSection Title="처리 상태">
<MudStack Spacing="2">
@foreach (var (key, label) in InquiryStatusMapper.Labels)
{
<MudButton Variant="@(inquiry.Status == key ? Variant.Filled : Variant.Outlined)"
Color="@StatusColor(key)"
FullWidth="true"
OnClick="@(() => OnStatusChanged(key))">
@label
</MudButton>
}
</MudStack>
</AdminDetailSection>
@if (inquiry.ClientId == null)
{
<AdminDetailSection Title="고객 카드 생성" CssClass="pa-4 mt-4">
<MudText Typo="Typo.body2" Class="mb-3">이 문의를 고객 카드로 등록합니다.</MudText>
<MudButton Variant="Variant.Filled" Color="Color.Success" FullWidth="true"
OnClick="ConvertToClient">
고객으로 등록
</MudButton>
</AdminDetailSection>
}
else
{
<AdminDetailSection Title="연결된 고객" CssClass="pa-4 mt-4">
<MudButton Variant="Variant.Outlined" Color="Color.Primary" FullWidth="true"
Href="@($"/taxbaik/admin/clients/{inquiry.ClientId}")">
고객 카드 보기
</MudButton>
</AdminDetailSection>
}
</MudItem>
</MudGrid>
}
else
{
<MudText>문의를 찾을 수 없습니다.</MudText>
}
@code {
[Parameter]
public int InquiryId { get; set; }
private Domain.Entities.Inquiry? inquiry;
private string adminMemo = "";
protected override async Task OnInitializedAsync()
{
inquiry = await InquiryClient.GetByIdAsync(InquiryId);
adminMemo = inquiry?.AdminMemo ?? "";
}
private async Task OnStatusChanged(string status)
{
if (inquiry == null) return;
try
{
var success = await InquiryClient.UpdateStatusAsync(inquiry.Id, status);
if (success)
{
inquiry.Status = status;
Snackbar.Add("상태가 변경되었습니다.", Severity.Success);
}
else
{
Snackbar.Add("상태 변경에 실패했습니다.", Severity.Error);
}
}
catch (Exception ex)
{
Snackbar.Add($"오류: {ex.Message}", Severity.Error);
}
}
private async Task SaveMemo()
{
if (inquiry == null) return;
try
{
var success = await InquiryClient.UpdateAdminMemoAsync(inquiry.Id, adminMemo);
if (success)
{
inquiry.AdminMemo = adminMemo;
Snackbar.Add("메모가 저장되었습니다.", Severity.Success);
}
else
{
Snackbar.Add("메모 저장에 실패했습니다.", Severity.Error);
}
}
catch (Exception ex)
{
Snackbar.Add($"오류: {ex.Message}", Severity.Error);
}
}
private async Task ConvertToClient()
{
if (inquiry == null) return;
try
{
var clientId = await InquiryClient.ConvertToClientAsync(
inquiry.Id,
inquiry.Name,
inquiry.Phone,
inquiry.ServiceType);
if (clientId > 0)
{
inquiry.ClientId = clientId;
inquiry.Status = "consulting";
Snackbar.Add("고객 카드가 생성되었습니다.", Severity.Success);
}
else
{
Snackbar.Add("고객 카드 생성에 실패했습니다.", Severity.Error);
}
}
catch (Exception ex)
{
Snackbar.Add($"오류: {ex.Message}", Severity.Error);
}
}
private Color StatusColor(string status) => status switch
{
"new" => Color.Default,
"consulting" => Color.Info,
"contracted" => Color.Success,
"rejected" => Color.Error,
"closed" => Color.Dark,
_ => Color.Default
};
}
@@ -0,0 +1,164 @@
@page "/admin/inquiries/{id:int}/edit"
@attribute [Authorize]
@using TaxBaik.Application.DTOs
@using TaxBaik.WasmClient.Components.Admin.Forms
@inject IInquiryBrowserClient InquiryClient
@inject NavigationManager Navigation
@inject ISnackbar Snackbar
@inject IDialogService DialogService
<PageTitle>문의 수정</PageTitle>
<AdminCrudPageShell Title="문의 수정"
Eyebrow="Customer Relations"
Subtitle="고객 문의 정보를 수정합니다."
Loading="@isLoading"
SkeletonContent="@EditorSkeleton"
OnCancel="@GoBack">
@if (inquiry == null)
{
<MudAlert Severity="Severity.Error" Class="mt-4">문의를 찾을 수 없습니다.</MudAlert>
}
else
{
<MudPaper Class="pa-4 mt-4" Elevation="1">
<InquiryForm ButtonText="수정" InitialData="formModel" OnSubmit="HandleUpdate" OnCancel="GoBack" />
<MudDivider Class="my-4" />
<MudButton Variant="Variant.Outlined" Color="Color.Error" @onclick="DeleteInquiry" Class="mt-2">
문의 삭제
</MudButton>
</MudPaper>
}
</AdminCrudPageShell>
@code {
[Parameter]
public int Id { get; set; }
private Domain.Entities.Inquiry? inquiry;
private InquiryForm.InquiryFormModel? formModel;
private bool isLoading = true;
private RenderFragment EditorSkeleton => builder =>
{
builder.OpenComponent<AdminSkeletonRows>(0);
builder.AddAttribute(1, "Rows", 5);
builder.AddAttribute(2, "Columns", 3);
builder.CloseComponent();
};
protected override async Task OnInitializedAsync()
{
try
{
inquiry = await InquiryClient.GetByIdAsync(Id);
if (inquiry != null)
{
formModel = new InquiryForm.InquiryFormModel
{
Name = inquiry.Name,
Phone = inquiry.Phone,
Email = inquiry.Email,
ServiceType = inquiry.ServiceType,
Message = inquiry.Message,
Status = inquiry.Status,
AdminMemo = inquiry.AdminMemo
};
}
}
catch (Exception ex)
{
Snackbar.Add($"문의 로드 실패: {ex.Message}", Severity.Error);
}
finally
{
isLoading = false;
}
}
private void GoBack()
{
Navigation.NavigateTo("/taxbaik/admin/inquiries");
}
private async Task HandleUpdate(InquiryForm.InquiryFormModel model)
{
if (inquiry == null)
return;
try
{
var updated = await InquiryClient.UpdateAsync(inquiry.Id, new UpdateInquiryDto
{
Name = model.Name,
Phone = model.Phone,
Email = model.Email,
ServiceType = model.ServiceType,
Message = model.Message,
Status = model.Status,
AdminMemo = model.AdminMemo
});
if (updated == null)
{
Snackbar.Add("문의 수정에 실패했습니다.", Severity.Error);
return;
}
inquiry = updated;
formModel = new InquiryForm.InquiryFormModel
{
Name = inquiry.Name,
Phone = inquiry.Phone,
Email = inquiry.Email,
ServiceType = inquiry.ServiceType,
Message = inquiry.Message,
Status = inquiry.Status,
AdminMemo = inquiry.AdminMemo
};
Snackbar.Add("문의가 수정되었습니다.", Severity.Success);
Navigation.NavigateTo("/taxbaik/admin/inquiries");
}
catch (ValidationException ex)
{
Snackbar.Add(ex.Message, Severity.Error);
}
catch (Exception ex)
{
Snackbar.Add($"수정 실패: {ex.Message}", Severity.Error);
}
}
private async Task DeleteInquiry()
{
if (inquiry == null)
return;
var result = await DialogService.ShowMessageBox(
"문의 삭제",
"정말 삭제하시겠습니까? 이 작업은 취소할 수 없습니다.",
"삭제", "취소");
if (result != true)
return;
try
{
var deleted = await InquiryClient.DeleteAsync(inquiry.Id);
if (!deleted)
{
Snackbar.Add("문의 삭제에 실패했습니다.", Severity.Error);
return;
}
Snackbar.Add("문의가 삭제되었습니다.", Severity.Success);
Navigation.NavigateTo("/taxbaik/admin/inquiries");
}
catch (Exception ex)
{
Snackbar.Add($"삭제 실패: {ex.Message}", Severity.Error);
}
}
}
@@ -0,0 +1,74 @@
@page "/admin/inquiries"
@attribute [Authorize]
@using TaxBaik.Web.Services
@inject IInquiryBrowserClient InquiryClient
<PageTitle>문의 관리</PageTitle>
<AdminPageHeader Title="문의 관리" Eyebrow="Customer Requests" Subtitle="상담 요청을 상태별로 확인하고 후속 조치를 기록합니다.">
<ChildContent>
<MudButton Variant="Variant.Filled" Color="Color.Primary" StartIcon="@Icons.Material.Filled.Add"
Href="/taxbaik/admin/inquiries/create">새 문의 등록</MudButton>
</ChildContent>
</AdminPageHeader>
<AdminDataPanel Loading="@isLoading">
<MudTabs Rounded="true" Elevation="0" Class="admin-tabs">
<MudTabPanel Text="전체">
<InquiryTable Inquiries="allInquiries" Status="" />
</MudTabPanel>
<MudTabPanel Text="신규">
<InquiryTable Inquiries="allInquiries" Status="new" />
</MudTabPanel>
<MudTabPanel Text="상담중">
<InquiryTable Inquiries="allInquiries" Status="consulting" />
</MudTabPanel>
<MudTabPanel Text="계약완료">
<InquiryTable Inquiries="allInquiries" Status="contracted" />
</MudTabPanel>
<MudTabPanel Text="거절">
<InquiryTable Inquiries="allInquiries" Status="rejected" />
</MudTabPanel>
<MudTabPanel Text="종결">
<InquiryTable Inquiries="allInquiries" Status="closed" />
</MudTabPanel>
</MudTabs>
</AdminDataPanel>
@code {
[CascadingParameter]
private Task<AuthenticationState>? AuthStateTask { get; set; }
private bool isLoading = true;
private IReadOnlyList<Domain.Entities.Inquiry> allInquiries = [];
protected override async Task OnInitializedAsync()
{
if (AuthStateTask != null)
{
var authState = await AuthStateTask;
if (authState.User.Identity?.IsAuthenticated == true)
{
await LoadData();
}
}
}
private async Task LoadData()
{
isLoading = true;
try
{
var (items, _) = await InquiryClient.GetPagedAsync(1, 200);
allInquiries = items.ToList();
}
catch
{
allInquiries = [];
}
finally
{
isLoading = false;
}
}
}
@@ -0,0 +1,6 @@
@page "/admin/login"
@layout TaxBaik.WasmClient.Components.Admin.Layout.BlankLayout
@attribute [AllowAnonymous]
@rendermode @(new InteractiveWebAssemblyRenderMode(prerender: true))
<PageTitle>로그인</PageTitle>
<AdminLoginForm />
@@ -0,0 +1,17 @@
@page "/admin/logout"
@using TaxBaik.Web.Services
@inject CustomAuthenticationStateProvider AuthStateProvider
@inject NavigationManager NavigationManager
<PageTitle>로그아웃</PageTitle>
@code {
protected override async Task OnInitializedAsync()
{
// 사용자 로그아웃
await AuthStateProvider.LogoutAsync();
// 로그인 페이지로 리다이렉트
NavigationManager.NavigateTo("/taxbaik/admin/login", forceLoad: true);
}
}
@@ -0,0 +1,268 @@
@page "/admin/revenue-trackings"
@using TaxBaik.Web.Services.AdminClients
@using TaxBaik.WasmClient.Components.Admin.Shared
@inject IRevenueTrackingBrowserClient RevenueClient
@inject IClientBrowserClient ClientClient
@inject ISnackbar Snackbar
@inject IDialogService DialogService
@attribute [Authorize]
<PageTitle>수익 추적 관리</PageTitle>
<section class="admin-page-hero">
<div>
<MudText Typo="Typo.caption" Class="admin-eyebrow">CRM & 세무관리</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" OnClick="OpenCreateDialog" StartIcon="@Icons.Material.Filled.Add">
새 청구 추가
</MudButton>
</section>
<AdminDataPanel Loading="@(revenues is null)" SkeletonContent="@RevenueSkeleton">
@if (revenues is null)
{
}
else if (revenues.Count == 0)
{
<MudAlert Severity="Severity.Info" Class="mt-4">
<MudIcon Icon="@Icons.Material.Filled.Payments" Class="me-2" />
청구 기록이 없습니다.
</MudAlert>
}
else
{
<MudDataGrid T="RevenueTracking"
Items="@revenues"
Dense="true"
Hover="true"
Striped="true"
Virtualize="true"
RowsPerPage="30"
Class="admin-grid">
<Columns>
<PropertyColumn Property="x => x.Id" Title="ID" Sortable="true" />
<TemplateColumn Title="고객">
<CellTemplate>
@if (clientMap.TryGetValue(context.Item.ClientId, out var clientName))
{
<MudLink Href="@($"/taxbaik/admin/clients/{context.Item.ClientId}")" Color="Color.Primary">
@clientName
</MudLink>
}
</CellTemplate>
</TemplateColumn>
<PropertyColumn Property="x => x.InvoiceNumber" Title="청구번호" />
<PropertyColumn Property="x => x.InvoiceDate" Title="청구일" Format="yyyy-MM-dd" />
<PropertyColumn Property="x => x.Amount" Title="청구액" Format="C" />
<TemplateColumn Title="납부여부">
<CellTemplate>
@if (context.Item.PaymentStatus == "paid")
{
<MudChip Size="Size.Small" Color="Color.Success" Variant="Variant.Filled">납부</MudChip>
}
else
{
<MudChip Size="Size.Small" Color="Color.Warning" Variant="Variant.Filled">미납</MudChip>
}
</CellTemplate>
</TemplateColumn>
<TemplateColumn Title="작업" Sortable="false">
<CellTemplate>
<MudButtonGroup Size="Size.Small" Variant="Variant.Outlined">
@if (context.Item.PaymentStatus != "paid")
{
<MudIconButton Icon="@Icons.Material.Filled.CheckCircle" Color="Color.Success"
OnClick="@(async () => await MarkPaid(context.Item.Id))" Title="납부 처리" />
}
<MudIconButton Icon="@Icons.Material.Filled.Delete" Color="Color.Error"
OnClick="@(async () => await DeleteRevenue(context.Item.Id))" />
</MudButtonGroup>
</CellTemplate>
</TemplateColumn>
</Columns>
</MudDataGrid>
}
</AdminDataPanel>
<!-- Create Dialog -->
<MudDialog @bind-IsVisible="isDialogOpen" Options="new DialogOptions { MaxWidth = MaxWidth.Small, FullWidth = true }">
<TitleContent>
<MudText Typo="Typo.h6">새 청구 추가</MudText>
</TitleContent>
<DialogContent>
<MudForm @ref="form">
<MudSelect T="int" @bind-Value="revenueForm.ClientId" Label="고객" Required="true" Variant="Variant.Outlined" FullWidth="true" Class="mb-4">
@foreach (var client in clients)
{
<MudSelectItem Value="@client.Id">@GetClientDisplayName(client)</MudSelectItem>
}
</MudSelect>
<MudTextField T="string" @bind-Value="revenueForm.InvoiceNumber" Label="청구번호" Variant="Variant.Outlined" FullWidth="true" Class="mb-4" Required="true" />
<MudDatePicker @bind-Date="revenueForm.InvoiceDate" Label="청구일" Variant="Variant.Outlined" FullWidth="true" Class="mb-4" Required="true" />
<MudNumericField T="decimal" @bind-Value="revenueForm.Amount" Label="청구액" Variant="Variant.Outlined" FullWidth="true" Class="mb-4" Required="true" />
<CommonCodeSelect @bind-Value="revenueForm.ServiceType" Group="REVENUE_SERVICE_TYPE" Label="서비스 유형" Class="mb-4" />
<MudDatePicker @bind-Date="revenueForm.DueDate" Label="납부예정일" Variant="Variant.Outlined" FullWidth="true" Class="mb-4" />
</MudForm>
</DialogContent>
<DialogActions>
<MudButton OnClick="CloseDialog">취소</MudButton>
<MudButton Color="Color.Primary" OnClick="SaveRevenue">저장</MudButton>
</DialogActions>
</MudDialog>
@code {
[CascadingParameter]
private Task<AuthenticationState>? AuthStateTask { get; set; }
private List<RevenueTracking>? revenues;
private List<Client> clients = [];
private Dictionary<int, string> clientMap = new();
private MudForm? form;
private bool isDialogOpen;
private RevenueForm revenueForm = new();
private RenderFragment RevenueSkeleton => 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 LoadData();
}
}
}
private async Task LoadData()
{
try
{
revenues = await RevenueClient.GetAllAsync();
var (clientItems, _) = await ClientClient.GetPagedAsync(pageSize: 1000);
clients = clientItems.ToList();
clientMap = clients.ToDictionary(c => c.Id, GetClientDisplayName);
}
catch (Exception ex)
{
Snackbar.Add($"데이터 로드 실패: {ex.Message}", Severity.Error);
}
}
private void OpenCreateDialog()
{
revenueForm = new RevenueForm
{
ClientId = clients.FirstOrDefault()?.Id ?? 0,
InvoiceDate = DateTime.Today,
DueDate = DateTime.Today.AddDays(14)
};
isDialogOpen = true;
}
private async Task SaveRevenue()
{
if (form != null)
{
await form.Validate();
if (!form.IsValid)
{
Snackbar.Add("필수 항목을 입력해주세요.", Severity.Warning);
return;
}
}
try
{
var newId = await RevenueClient.CreateAsync(
revenueForm.ClientId,
revenueForm.InvoiceNumber,
revenueForm.InvoiceDate ?? DateTime.Now,
revenueForm.Amount,
revenueForm.ServiceType,
revenueForm.DueDate);
if (newId > 0)
{
Snackbar.Add("청구가 추가되었습니다.", Severity.Success);
CloseDialog();
await LoadData();
}
}
catch (Exception ex)
{
Snackbar.Add($"저장 실패: {ex.Message}", Severity.Error);
}
}
private async Task MarkPaid(int id)
{
try
{
await RevenueClient.MarkPaidAsync(id, DateTime.Now);
Snackbar.Add("납부가 처리되었습니다.", Severity.Success);
await LoadData();
}
catch (Exception ex)
{
Snackbar.Add($"처리 실패: {ex.Message}", Severity.Error);
}
}
private async Task DeleteRevenue(int id)
{
var parameters = new DialogParameters
{
{ "Title", "삭제 확인" },
{ "Message", "이 청구를 삭제하시겠습니까?" }
};
var dialog = await DialogService.ShowAsync<ConfirmDialog>("", parameters);
var result = await dialog.Result;
if (result?.Canceled ?? true)
return;
try
{
await RevenueClient.DeleteAsync(id);
Snackbar.Add("청구가 삭제되었습니다.", Severity.Success);
await LoadData();
}
catch (Exception ex)
{
Snackbar.Add($"삭제 실패: {ex.Message}", Severity.Error);
}
}
private void CloseDialog()
{
isDialogOpen = false;
revenueForm = new();
}
private static string GetClientDisplayName(Client client)
=> !string.IsNullOrWhiteSpace(client.CompanyName)
? client.CompanyName
: !string.IsNullOrWhiteSpace(client.Name)
? client.Name
: $"Client #{client.Id}";
private class RevenueForm
{
public int ClientId { get; set; }
public string InvoiceNumber { get; set; } = "";
public DateTime? InvoiceDate { get; set; }
public decimal Amount { get; set; }
public string? ServiceType { get; set; }
public DateTime? DueDate { get; set; }
}
}
@@ -0,0 +1,211 @@
@page "/admin/season-simulator"
@attribute [Authorize]
@using TaxBaik.Application.Seasonal
@using TaxBaik.Application.Services
<PageTitle>시즌 시뮬레이터</PageTitle>
<section class="admin-page-hero">
<div>
<MudText Typo="Typo.caption" Class="admin-eyebrow">Season Preview</MudText>
<MudText Typo="Typo.h4" Class="admin-page-title">시즌 시뮬레이터</MudText>
<MudText Typo="Typo.body2" Class="admin-page-subtitle">날짜를 선택해 홈페이지 시즌 화면이 어떻게 보이는지 미리 확인합니다.</MudText>
</div>
</section>
<MudGrid>
<MudItem xs="12" md="4">
<MudPaper Class="pa-4" Elevation="1">
<MudText Typo="Typo.h6" Class="mb-3">시뮬레이션 날짜</MudText>
<MudDatePicker @bind-Date="simulationDate" Label="날짜 선택" DateFormat="yyyy-MM-dd" PickerVariant="PickerVariant.Static" />
<MudDivider Class="my-3" />
<MudText Typo="Typo.subtitle2" Class="mb-2">연간 세무 캘린더</MudText>
@foreach (var season in TaxSeasonCalendar.Seasons)
{
<MudButton Variant="Variant.Outlined" Size="Size.Small" FullWidth="true"
Class="mb-1" Color="Color.Primary"
OnClick="@(() => JumpToSeason(season))">
@season.StartMonth/@season.StartDay — @season.Name
</MudButton>
}
</MudPaper>
</MudItem>
<MudItem xs="12" md="8">
<MudPaper Class="pa-4" Elevation="1">
<MudText Typo="Typo.h6" Class="mb-1">
@(simulationDate?.ToString("yyyy년 MM월 dd일") ?? "날짜를 선택하세요") 홈페이지 미리보기
</MudText>
@if (activeSeason != null)
{
<MudChip T="string" Color="Color.Warning" Size="Size.Small" Class="mb-3">
@activeSeason.Name 시즌 활성
</MudChip>
<MudDivider Class="mb-4" />
<!-- Hero 섹션 미리보기 -->
<div style="background: linear-gradient(135deg, #1a365d 0%, #2a4365 100%); border-radius: 12px; padding: 2rem; color: white; margin-bottom: 1.5rem;">
@if (activeSeason.DaysUntilDeadline <= 7 && activeSeason.DaysUntilDeadline >= 0)
{
<div style="background: #f59e0b; color: #1a202c; display: inline-block; padding: 4px 12px; border-radius: 20px; font-size: 0.8rem; font-weight: 700; margin-bottom: 1rem;">
D-@activeSeason.DaysUntilDeadline 마감 임박
</div>
}
<div style="font-size: 1.8rem; font-weight: 800; white-space: pre-line; margin-bottom: 0.5rem; line-height: 1.3;">
@activeSeason.HeroHeadline
</div>
<div style="font-size: 0.95rem; color: rgba(255,255,255,0.8); margin-bottom: 1.5rem;">
@activeSeason.HeroSubtext
</div>
<div style="display: flex; gap: 0.75rem; flex-wrap: wrap;">
<div style="background: #e53e3e; color: white; padding: 10px 20px; border-radius: 8px; font-weight: 700; font-size: 0.95rem;">
@activeSeason.CtaText
</div>
<div style="background: transparent; border: 2px solid rgba(255,255,255,0.5); color: white; padding: 10px 20px; border-radius: 8px; font-size: 0.95rem;">
서비스 안내
</div>
</div>
</div>
<MudGrid Spacing="2">
<MudItem xs="6">
<MudText Typo="Typo.subtitle2" Color="Color.Secondary">활성 시즌 키</MudText>
<MudText><code>@activeSeason.Key</code></MudText>
</MudItem>
<MudItem xs="6">
<MudText Typo="Typo.subtitle2" Color="Color.Secondary">마감까지</MudText>
<MudText>
@if (activeSeason.DaysUntilDeadline >= 0)
{
<MudChip T="string" Size="Size.Small"
Color="@(activeSeason.DaysUntilDeadline <= 7 ? Color.Error : Color.Warning)">
D-@activeSeason.DaysUntilDeadline
</MudChip>
}
else
{
<span>마감 후 @(-activeSeason.DaysUntilDeadline)일</span>
}
</MudText>
</MudItem>
<MudItem xs="6">
<MudText Typo="Typo.subtitle2" Color="Color.Secondary">포커스 서비스</MudText>
<MudText>@activeSeason.FocusService</MudText>
</MudItem>
<MudItem xs="6">
<MudText Typo="Typo.subtitle2" Color="Color.Secondary">블로그 카테고리</MudText>
<MudText>@activeSeason.RelatedCategorySlug</MudText>
</MudItem>
<MudItem xs="12">
<MudText Typo="Typo.subtitle2" Color="Color.Secondary">긴박감 배지 문구</MudText>
<MudText><code>@activeSeason.UrgencyBadge</code></MudText>
</MudItem>
</MudGrid>
}
else
{
<MudAlert Severity="Severity.Info">
선택한 날짜(@(simulationDate?.ToString("MM월 dd일") ?? "-"))는 시즌 비활성 기간입니다.
홈페이지는 기본 Hero를 표시합니다.
</MudAlert>
<div style="background: linear-gradient(135deg, #1a365d 0%, #2a4365 100%); border-radius: 12px; padding: 2rem; color: white; margin-top: 1.5rem;">
<div style="font-size: 1.8rem; font-weight: 800; margin-bottom: 0.5rem;">
사업자 세금, 부동산,<br/>가족자산까지
</div>
<div style="font-size: 0.95rem; color: rgba(255,255,255,0.8); margin-bottom: 1.5rem;">
세무사·부동산중개사·보험설계사 자격 보유 | 온라인 맞춤 상담
</div>
<div style="background: #e53e3e; color: white; display: inline-block; padding: 10px 20px; border-radius: 8px; font-weight: 700;">
무료 상담 신청
</div>
</div>
}
</MudPaper>
<MudPaper Class="pa-4 mt-4" Elevation="1">
<MudText Typo="Typo.h6" Class="mb-3">연간 시즌 타임라인</MudText>
<MudSimpleTable Dense="true">
<thead>
<tr>
<th>기간</th>
<th>시즌</th>
<th>블로그 카테고리</th>
<th>상태</th>
</tr>
</thead>
<tbody>
@foreach (var s in TaxSeasonCalendar.Seasons)
{
var isActive = activeSeason?.Key == s.Key;
<tr style="@(isActive ? "background: rgba(66,153,225,0.1);" : "")">
<td style="white-space: nowrap;">
@s.StartMonth/@s.StartDay ~ @s.EndMonth/@s.EndDay
</td>
<td>@s.Name</td>
<td><code style="font-size:0.8rem;">@s.RelatedCategorySlug</code></td>
<td>
@if (isActive)
{
<MudChip T="string" Size="Size.Small" Color="Color.Success">활성</MudChip>
}
else
{
<span style="color: #a0aec0; font-size: 0.85rem;">비활성</span>
}
</td>
</tr>
}
</tbody>
</MudSimpleTable>
</MudPaper>
</MudItem>
</MudGrid>
@code {
private DateTime? simulationDate = DateTime.Today;
private CurrentSeasonDto? activeSeason;
protected override void OnInitialized() => ComputeSeason();
private void ComputeSeason()
{
if (simulationDate == null) { activeSeason = null; return; }
var date = simulationDate.Value;
var season = TaxSeasonCalendar.Seasons.FirstOrDefault(s =>
{
var start = new DateTime(date.Year, s.StartMonth, s.StartDay);
var endYear = (s.EndMonth < s.StartMonth) ? date.Year + 1 : date.Year;
var end = new DateTime(endYear, s.EndMonth, s.EndDay);
return date >= start && date <= end;
});
if (season == null) { activeSeason = null; return; }
var endYearCalc = (season.EndMonth < season.StartMonth) ? date.Year + 1 : date.Year;
var deadline = new DateTime(endYearCalc, season.EndMonth, season.EndDay);
var ddays = (deadline.Date - date.Date).Days;
var badge = ddays <= 7 && ddays >= 0
? season.UrgencyBadge.Replace("{n}", ddays.ToString())
: season.UrgencyBadge;
activeSeason = new CurrentSeasonDto
{
Key = season.Key,
Name = season.Name,
HeroHeadline = season.HeroHeadline,
HeroSubtext = season.HeroSubtext,
UrgencyBadge = badge,
FocusService = season.FocusService,
RelatedCategorySlug = season.RelatedCategorySlug,
CtaText = season.CtaText,
DaysUntilDeadline = ddays,
Deadline = deadline
};
}
private void JumpToSeason(TaxSeason season)
{
simulationDate = new DateTime(DateTime.Today.Year, season.StartMonth, season.StartDay);
ComputeSeason();
}
}
@@ -0,0 +1,208 @@
@page "/admin/settings"
@attribute [Authorize]
@using System.ComponentModel.DataAnnotations
@using System.Collections.Generic
@using TaxBaik.Web.Services
@using TaxBaik.Domain.Interfaces
@inject IApiClient ApiClient
@inject ISnackbar Snackbar
<PageTitle>설정</PageTitle>
<MudContainer MaxWidth="MaxWidth.Large" Class="pa-6">
<section class="admin-page-hero">
<div>
<MudText Typo="Typo.caption" Class="admin-eyebrow">System</MudText>
<MudText Typo="Typo.h4" Class="admin-page-title">설정</MudText>
<MudText Typo="Typo.body2" Class="admin-page-subtitle">공개 사이트 연락처와 관리자 계정 보안을 관리합니다.</MudText>
</div>
</section>
</MudContainer>
<MudGrid>
<MudItem xs="12" md="7">
<MudPaper Class="admin-surface" Elevation="0">
<div class="admin-section-header compact">
<div>
<MudText Typo="Typo.h6">사이트 정보</MudText>
<MudText Typo="Typo.body2">홈페이지와 문의 알림에 노출되는 기본 정보입니다.</MudText>
</div>
</div>
<MudForm>
<MudTextField @bind-Value="phone" Label="전화번호"
Variant="Variant.Outlined" Class="mb-4" />
<MudTextField @bind-Value="email" Label="이메일"
Variant="Variant.Outlined" Class="mb-4" />
<MudTextField @bind-Value="kakaoUrl" Label="카카오채널 URL"
Variant="Variant.Outlined" Class="mb-4" />
<MudTextField @bind-Value="instagramUrl" Label="인스타그램"
Variant="Variant.Outlined" Class="mb-4" />
<MudButton Variant="Variant.Filled" Color="Color.Primary"
StartIcon="@Icons.Material.Filled.Save"
@onclick="SaveSettings">사이트 정보 저장</MudButton>
</MudForm>
</MudPaper>
</MudItem>
<MudItem xs="12" md="5">
<MudPaper Class="admin-surface admin-account-card" Elevation="0">
<div class="admin-section-header compact">
<div>
<MudText Typo="Typo.h6">계정 관리</MudText>
<MudText Typo="Typo.body2">비밀번호는 12자 이상으로 관리합니다.</MudText>
</div>
</div>
<MudForm>
<MudTextField @bind-Value="currentPassword" Label="현재 비밀번호" InputType="InputType.Password"
Variant="Variant.Outlined" Class="mb-4" />
<MudTextField @bind-Value="newPassword" Label="새 비밀번호" InputType="InputType.Password"
Variant="Variant.Outlined" Class="mb-4" />
<MudTextField @bind-Value="confirmNewPassword" Label="새 비밀번호 확인" InputType="InputType.Password"
Variant="Variant.Outlined" Class="mb-4" />
<MudButton Variant="Variant.Filled" Color="Color.Primary"
Disabled="@isChangingPassword"
StartIcon="@Icons.Material.Filled.LockReset"
@onclick="ChangePassword">
@(isChangingPassword ? "변경 중..." : "비밀번호 변경")
</MudButton>
</MudForm>
</MudPaper>
</MudItem>
</MudGrid>
@code {
private string phone = "010-4122-8268";
private string email = "taxbaik5668@gmail.com";
private string kakaoUrl = "http://pf.kakao.com/_xoxchTX";
private string instagramUrl = "https://www.instagram.com/taxtory5668/";
private string currentPassword = "";
private string newPassword = "";
private string confirmNewPassword = "";
private bool isChangingPassword;
private bool isLoadingSettings;
protected override async Task OnInitializedAsync()
{
await LoadSettingsAsync();
}
private async Task LoadSettingsAsync()
{
isLoadingSettings = true;
try
{
var settings = await ApiClient.GetAsync<Dictionary<string, string>>("site-settings");
if (settings is null || settings.Count == 0)
return;
if (settings.TryGetValue("PhoneNumber", out var loadedPhone) && !string.IsNullOrWhiteSpace(loadedPhone))
phone = loadedPhone;
if (settings.TryGetValue("EmailAddress", out var loadedEmail) && !string.IsNullOrWhiteSpace(loadedEmail))
email = loadedEmail;
if (settings.TryGetValue("KakaoChannelUrl", out var loadedKakao) && !string.IsNullOrWhiteSpace(loadedKakao))
kakaoUrl = loadedKakao;
if (settings.TryGetValue("InstagramUrl", out var loadedInstagram) && !string.IsNullOrWhiteSpace(loadedInstagram))
instagramUrl = loadedInstagram;
}
catch
{
Snackbar.Add("사이트 설정을 불러오지 못했습니다.", Severity.Warning);
}
finally
{
isLoadingSettings = false;
}
}
private async Task SaveSettings()
{
if (isLoadingSettings)
return;
var response = await ApiClient.PutAsync<SaveSettingsResponse>("site-settings", new
{
Phone = phone,
Email = email,
KakaoUrl = kakaoUrl,
InstagramUrl = instagramUrl
});
if (response?.Message is null)
{
Snackbar.Add("설정 저장에 실패했습니다.", Severity.Error);
return;
}
Snackbar.Add(response.Message, Severity.Success);
}
private async Task ChangePassword()
{
if (isChangingPassword)
return;
if (string.IsNullOrWhiteSpace(currentPassword) || string.IsNullOrWhiteSpace(newPassword))
{
Snackbar.Add("현재 비밀번호와 새 비밀번호를 입력하세요.", Severity.Warning);
return;
}
if (newPassword != confirmNewPassword)
{
Snackbar.Add("새 비밀번호 확인이 일치하지 않습니다.", Severity.Warning);
return;
}
isChangingPassword = true;
try
{
var response = await ApiClient.PostAsync<ChangePasswordResponse>("auth/change-password", new
{
CurrentPassword = currentPassword,
NewPassword = newPassword
});
if (response?.Message == null)
{
Snackbar.Add("비밀번호 변경에 실패했습니다.", Severity.Error);
return;
}
Snackbar.Add(response.Message, Severity.Success);
currentPassword = "";
newPassword = "";
confirmNewPassword = "";
}
catch
{
Snackbar.Add("비밀번호 변경 중 오류가 발생했습니다.", Severity.Error);
}
finally
{
isChangingPassword = false;
}
}
private class ChangePasswordResponse
{
public string Message { get; set; } = "";
}
private class SaveSettingsResponse
{
public string Message { get; set; } = "";
}
}
@@ -0,0 +1,344 @@
@page "/admin/tax-filing-schedules"
@using TaxBaik.Web.Services.AdminClients
@using TaxBaik.Domain.Entities
@using TaxBaik.WasmClient.Components.Admin.Shared
@inject ITaxFilingScheduleBrowserClient TaxFilingClient
@inject IClientBrowserClient ClientClient
@inject ISnackbar Snackbar
@inject IDialogService DialogService
@attribute [Authorize]
<PageTitle>신고 일정</PageTitle>
<section class="admin-page-hero">
<div>
<MudText Typo="Typo.caption" Class="admin-eyebrow">CRM & 세무관리</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" OnClick="PrepareCreate" StartIcon="@Icons.Material.Filled.Add" id="btn-add-schedule">
새 일정 추가
</MudButton>
</section>
<AdminDataPanel Loading="@(schedules is null)" SkeletonContent="@ScheduleSkeleton">
@if (schedules is null)
{
}
else
{
<MudGrid Spacing="2" Class="mt-2">
<!-- Left: Dense Grid List -->
<MudItem XS="12" MD="8">
@if (schedules.Count == 0)
{
<MudAlert Severity="Severity.Info">
<MudIcon Icon="@Icons.Material.Filled.EventBusy" Class="me-2" />
신고 일정이 없습니다.
</MudAlert>
}
else
{
<MudDataGrid T="TaxFilingSchedule"
Items="@schedules"
Dense="true"
Hover="true"
Striped="true"
Virtualize="true"
RowsPerPage="30"
SelectedItem="@selectedSchedule"
SelectedItemChanged="OnRowSelected"
Class="admin-grid">
<Columns>
<PropertyColumn Property="x => x.Id" Title="ID" Sortable="true" />
<TemplateColumn Title="고객">
<CellTemplate>
@if (clientMap.TryGetValue(context.Item.ClientId, out var clientName))
{
@clientName
}
</CellTemplate>
</TemplateColumn>
<PropertyColumn Property="x => x.FilingType" Title="신고 유형" />
<TemplateColumn Title="마감일">
<CellTemplate>
@{
var effectiveDueDate = BusinessDayCalculator.GetEffectiveDueDate(DateOnly.FromDateTime(context.Item.DueDate));
var daysLeft = BusinessDayCalculator.GetDday(DateOnly.FromDateTime(context.Item.DueDate));
var statusColor = daysLeft < 0 ? Color.Error : daysLeft <= 7 ? Color.Warning : Color.Success;
}
<MudChip Size="Size.Small" Color="@statusColor" Variant="Variant.Filled">
@effectiveDueDate.ToDateTime(TimeOnly.MinValue).ToString("yyyy-MM-dd")
@if (daysLeft >= 0)
{
<span class="ms-1">(D-@daysLeft)</span>
}
else
{
<span class="ms-1">(마감 @Math.Abs(daysLeft)일 경과)</span>
}
</MudChip>
</CellTemplate>
</TemplateColumn>
<PropertyColumn Property="x => x.FilingYear" Title="신고연도" />
<TemplateColumn Title="상태">
<CellTemplate>
@if (context.Item.Status == "completed")
{
<MudChip Size="Size.Small" Color="Color.Success" Variant="Variant.Filled">완료</MudChip>
}
else
{
<MudChip Size="Size.Small" Color="Color.Default" Variant="Variant.Outlined">대기</MudChip>
}
</CellTemplate>
</TemplateColumn>
<TemplateColumn Title="작업" Sortable="false">
<CellTemplate>
<MudButtonGroup Size="Size.Small" Variant="Variant.Outlined">
@if (context.Item.Status != "completed")
{
<MudIconButton Icon="@Icons.Material.Filled.CheckCircle"
Color="Color.Success"
OnClick="@(async () => await CompleteSchedule(context.Item.Id))"
Title="완료" />
}
<MudIconButton Icon="@Icons.Material.Filled.Delete"
Color="Color.Error"
OnClick="@(async () => await DeleteSchedule(context.Item.Id))"
Title="삭제" />
</MudButtonGroup>
</CellTemplate>
</TemplateColumn>
</Columns>
</MudDataGrid>
}
</MudItem>
<!-- Right: Detail Form Panel (Inline Editor) -->
<MudItem XS="12" MD="4">
<MudPaper Class="pa-4 admin-surface admin-editor-panel" Elevation="0" Style="border: 1px solid var(--border-color); min-height: 400px;">
<div class="d-flex align-center justify-space-between mb-4">
<MudText Typo="Typo.h6" Class="font-weight-bold">@(isEditMode ? "신고 일정 상세" : "새 신고 일정 추가")</MudText>
@if (isEditMode)
{
<MudButton Size="Size.Small" Variant="Variant.Outlined" Color="Color.Secondary" OnClick="PrepareCreate">
새로 작성
</MudButton>
}
</div>
<MudForm @ref="form">
<MudSelect T="int?"
@bind-Value="scheduleForm.ClientId"
Label="고객"
Required="true"
Variant="Variant.Outlined"
FullWidth="@true"
Class="mb-3"
RequiredError="고객을 선택하세요."
Disabled="@isEditMode">
@foreach (var client in clients)
{
<MudSelectItem Value="@((int?)client.Id)">@GetClientDisplayName(client)</MudSelectItem>
}
</MudSelect>
<CommonCodeSelect @bind-Value="scheduleForm.FilingType" Group="FILING_TYPE" Label="신고 유형" Class="mb-3" Required="true" />
<MudDatePicker @bind-Date="scheduleForm.DueDate" Label="마감일" Variant="Variant.Outlined" FullWidth="@true" Class="mb-3" Required="true" />
<MudNumericField T="int" @bind-Value="scheduleForm.FilingYear" Label="신고연도" Variant="Variant.Outlined" FullWidth="@true" Class="mb-4" Required="true" />
<div class="d-flex justify-end gap-2">
@if (isEditMode && selectedSchedule?.Status != "completed")
{
<MudButton Variant="Variant.Outlined" Color="Color.Success" OnClick="@(async () => await CompleteSchedule(selectedSchedule?.Id ?? 0))">완료 처리</MudButton>
}
@if (isEditMode)
{
<MudButton Variant="Variant.Outlined" Color="Color.Error" OnClick="@(async () => await DeleteSchedule(selectedSchedule?.Id ?? 0))">삭제</MudButton>
}
else
{
<MudButton Variant="Variant.Filled" Color="Color.Primary" OnClick="SaveSchedule" id="btn-save-schedule">저장</MudButton>
}
</div>
</MudForm>
</MudPaper>
</MudItem>
</MudGrid>
}
</AdminDataPanel>
@code {
[CascadingParameter]
private Task<AuthenticationState>? AuthStateTask { get; set; }
private List<TaxFilingSchedule>? schedules;
private List<Client> clients = [];
private Dictionary<int, string> clientMap = new();
private MudForm? form;
private bool isEditMode;
private TaxFilingSchedule? selectedSchedule;
private TaxFilingScheduleForm scheduleForm = new();
private RenderFragment ScheduleSkeleton => builder =>
{
builder.OpenComponent<AdminSkeletonRows>(0);
builder.AddAttribute(1, "Rows", 6);
builder.AddAttribute(2, "Columns", 4);
builder.CloseComponent();
};
protected override async Task OnInitializedAsync()
{
if (AuthStateTask != null)
{
var authState = await AuthStateTask;
if (authState.User.Identity?.IsAuthenticated == true)
{
await LoadData();
PrepareCreate();
}
}
}
private async Task LoadData()
{
try
{
schedules = await TaxFilingClient.GetAllAsync();
var (clientItems, _) = await ClientClient.GetPagedAsync(pageSize: 1000);
clients = clientItems.ToList();
clientMap = clients.ToDictionary(c => c.Id, GetClientDisplayName);
}
catch (Exception ex)
{
Snackbar.Add($"데이터 로드 실패: {ex.Message}", Severity.Error);
}
}
private void PrepareCreate()
{
selectedSchedule = null;
isEditMode = false;
scheduleForm = new TaxFilingScheduleForm
{
FilingYear = DateTime.Now.Year,
DueDate = DateTime.Today,
ClientId = clients.FirstOrDefault()?.Id,
FilingType = string.Empty
};
}
private void OnRowSelected(TaxFilingSchedule schedule)
{
if (schedule == null) return;
selectedSchedule = schedule;
isEditMode = true;
scheduleForm = new TaxFilingScheduleForm
{
ClientId = schedule.ClientId,
FilingType = schedule.FilingType,
DueDate = schedule.DueDate,
FilingYear = schedule.FilingYear
};
}
private async Task SaveSchedule()
{
if (form != null)
{
await form.Validate();
if (!form.IsValid)
{
Snackbar.Add("필수 항목을 입력해주세요.", Severity.Warning);
return;
}
}
try
{
if (scheduleForm.ClientId == null) return;
var newId = await TaxFilingClient.CreateAsync(
scheduleForm.ClientId.Value,
scheduleForm.FilingType,
scheduleForm.DueDate ?? DateTime.Today,
scheduleForm.FilingYear);
if (newId > 0)
{
Snackbar.Add("신고 일정이 추가되었습니다.", Severity.Success);
PrepareCreate();
await LoadData();
}
else
{
Snackbar.Add("등록에 실패했습니다.", Severity.Error);
}
}
catch (Exception ex)
{
Snackbar.Add($"저장 실패: {ex.Message}", Severity.Error);
}
}
private async Task CompleteSchedule(int id)
{
try
{
await TaxFilingClient.MarkCompletedAsync(id);
Snackbar.Add("신고 일정이 완료 처리되었습니다.", Severity.Success);
if (selectedSchedule?.Id == id)
{
PrepareCreate();
}
await LoadData();
}
catch (Exception ex)
{
Snackbar.Add($"처리 실패: {ex.Message}", Severity.Error);
}
}
private async Task DeleteSchedule(int id)
{
var parameters = new DialogParameters
{
{ "Title", "삭제 확인" },
{ "Message", "이 신고 일정을 삭제하시겠습니까?" }
};
var dialog = await DialogService.ShowAsync<ConfirmDialog>("", parameters);
var result = await dialog.Result;
if (result?.Canceled ?? true)
return;
try
{
await TaxFilingClient.DeleteAsync(id);
Snackbar.Add("신고 일정이 삭제되었습니다.", Severity.Success);
if (selectedSchedule?.Id == id)
{
PrepareCreate();
}
await LoadData();
}
catch (Exception ex)
{
Snackbar.Add($"삭제 실패: {ex.Message}", Severity.Error);
}
}
private static string GetClientDisplayName(Client client)
=> !string.IsNullOrWhiteSpace(client.CompanyName)
? client.CompanyName
: !string.IsNullOrWhiteSpace(client.Name)
? client.Name
: $"Client #{client.Id}";
private class TaxFilingScheduleForm
{
public int? ClientId { get; set; }
public string FilingType { get; set; } = "";
public DateTime? DueDate { get; set; }
public int FilingYear { get; set; } = DateTime.Now.Year;
}
}
@@ -0,0 +1,110 @@
@using TaxBaik.Web.Services
@using TaxBaik.Domain.Entities
@using TaxBaik.WasmClient.Components.Admin.Shared
@inject ITaxFilingBrowserClient FilingClient
@inject ISnackbar Snackbar
@if (Filings == null || Filings.Count == 0)
{
<MudText Class="pa-4" Color="Color.Secondary">항목이 없습니다.</MudText>
}
else
{
<MudTable Items="Filings" Hover="true" Dense="true" Class="mt-2">
<HeaderContent>
<MudTh>고객</MudTh>
<MudTh>신고 유형</MudTh>
<MudTh>기한</MudTh>
<MudTh>D-day</MudTh>
<MudTh>메모</MudTh>
<MudTh>처리</MudTh>
</HeaderContent>
<RowTemplate>
<MudTd>@context.ClientName</MudTd>
<MudTd>@context.FilingType</MudTd>
<MudTd>@BusinessDayCalculator.GetEffectiveDueDate(DateOnly.FromDateTime(context.DueDate)).ToDateTime(TimeOnly.MinValue).ToString("yyyy-MM-dd")</MudTd>
<MudTd>
@{
var dday = BusinessDayCalculator.GetDday(DateOnly.FromDateTime(context.DueDate));
}
@if (dday < 0)
{
<MudChip T="string" Size="Size.Small" Color="Color.Error">D+@(-dday)</MudChip>
}
else if (dday <= 7)
{
<MudChip T="string" Size="Size.Small" Color="Color.Warning">D-@dday</MudChip>
}
else
{
<MudText Typo="Typo.body2">D-@dday</MudText>
}
</MudTd>
<MudTd>@(context.Memo ?? "")</MudTd>
<MudTd>
@if (context.Status == "pending")
{
<MudButton Size="Size.Small" Variant="Variant.Filled" Color="Color.Success"
OnClick="@(() => MarkFiled(context))">완료</MudButton>
}
else if (context.Status == "filed")
{
<MudChip T="string" Size="Size.Small" Color="Color.Success">완료</MudChip>
}
<MudIconButton Icon="@Icons.Material.Filled.Delete" Size="Size.Small" Color="Color.Error"
OnClick="@(() => DeleteFiling(context.Id))" />
</MudTd>
</RowTemplate>
</MudTable>
}
@code {
[Parameter]
public List<TaxFiling>? Filings { get; set; }
[Parameter]
public EventCallback OnStatusChange { get; set; }
private async Task MarkFiled(TaxFiling filing)
{
try
{
filing.Status = "filed";
var result = await FilingClient.UpdateAsync(filing.Id, filing);
if (result != null)
{
Snackbar.Add("신고 완료 처리되었습니다.", Severity.Success);
await OnStatusChange.InvokeAsync();
}
else
{
Snackbar.Add("처리 실패", Severity.Error);
}
}
catch (Exception ex)
{
Snackbar.Add($"오류: {ex.Message}", Severity.Error);
}
}
private async Task DeleteFiling(int id)
{
try
{
var success = await FilingClient.DeleteAsync(id);
if (success)
{
Snackbar.Add("삭제되었습니다.", Severity.Info);
await OnStatusChange.InvokeAsync();
}
else
{
Snackbar.Add("삭제 실패", Severity.Error);
}
}
catch (Exception ex)
{
Snackbar.Add($"오류: {ex.Message}", Severity.Error);
}
}
}
@@ -0,0 +1,153 @@
@page "/admin/tax-filings"
@attribute [Authorize]
@using TaxBaik.Web.Services
@using TaxBaik.Domain.Entities
@using TaxBaik.WasmClient.Components.Admin.Shared
@inject ITaxFilingBrowserClient FilingClient
@inject IClientBrowserClient ClientClient
@inject ISnackbar Snackbar
<PageTitle>신고 일정 관리</PageTitle>
<section class="admin-page-hero">
<div>
<MudText Typo="Typo.caption" Class="admin-eyebrow">Tax Schedule</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"
OnClick="@(() => showAddForm = !showAddForm)"
StartIcon="@Icons.Material.Filled.Add">
일정 추가
</MudButton>
</section>
@if (showAddForm)
{
<MudPaper Class="pa-4 mb-4" Elevation="1">
<MudText Typo="Typo.h6" Class="mb-3">새 신고 일정</MudText>
<MudGrid Spacing="2">
<MudItem xs="12" sm="6" md="4">
<MudAutocomplete T="Domain.Entities.Client" @bind-Value="selectedClient"
Label="고객 검색 *"
SearchFunc="SearchClients"
ToStringFunc="@(c => c == null ? "" : $"{c.Name} {c.CompanyName ?? ""}")"
Variant="Variant.Outlined" />
</MudItem>
<MudItem xs="12" sm="6" md="4">
<CommonCodeSelect @bind-Value="newFilingType" Group="FILING_TYPE" Label="신고 유형 *" />
</MudItem>
<MudItem xs="12" sm="6" md="4">
<MudDatePicker @bind-Date="newDueDate" Label="신고 기한 *" DateFormat="yyyy-MM-dd" />
</MudItem>
<MudItem xs="12">
<MudTextField T="string" @bind-Value="newMemo" Label="메모" Variant="Variant.Outlined" />
</MudItem>
</MudGrid>
<MudStack Row="true" Class="mt-3" Spacing="2">
<MudButton Variant="Variant.Filled" Color="Color.Primary" OnClick="AddFiling">저장</MudButton>
<MudButton Variant="Variant.Outlined" OnClick="@(() => showAddForm = false)">취소</MudButton>
</MudStack>
</MudPaper>
}
<MudPaper Class="admin-surface" Elevation="0">
<MudTabs Rounded="true" Elevation="0" Class="admin-tabs">
<MudTabPanel Text="신고 예정">
<FilingTable Filings="@pending" OnStatusChange="Reload" />
</MudTabPanel>
<MudTabPanel Text="신고 완료">
<FilingTable Filings="@filed" OnStatusChange="Reload" />
</MudTabPanel>
<MudTabPanel Text="기한 초과">
<FilingTable Filings="@overdue" OnStatusChange="Reload" />
</MudTabPanel>
</MudTabs>
</MudPaper>
@code {
private List<Domain.Entities.TaxFiling> pending = [];
private List<Domain.Entities.TaxFiling> filed = [];
private List<Domain.Entities.TaxFiling> overdue = [];
private bool showAddForm;
private Domain.Entities.Client? selectedClient;
private string newFilingType = "";
private DateTime? newDueDate = DateTime.Today.AddDays(30);
private string newMemo = "";
protected override async Task OnInitializedAsync() => await Reload();
protected override async Task OnParametersSetAsync()
{
}
private async Task Reload()
{
try
{
var all = (await FilingClient.GetUpcomingAsync(365)).ToList();
pending = all.Where(x => x.Status == "pending").ToList();
filed = all.Where(x => x.Status == "filed").ToList();
overdue = all.Where(x => x.Status == "overdue").ToList();
}
catch (Exception ex)
{
Snackbar.Add($"오류: {ex.Message}", Severity.Error);
}
}
private async Task<IEnumerable<Client>> SearchClients(string value)
{
try
{
var (items, _) = await ClientClient.GetPagedAsync(1, 100, search: value);
return items;
}
catch
{
return [];
}
}
private static string GetClientDisplayName(Client client)
=> !string.IsNullOrWhiteSpace(client.CompanyName)
? client.CompanyName
: !string.IsNullOrWhiteSpace(client.Name)
? client.Name
: $"Client #{client.Id}";
private async Task AddFiling()
{
try
{
if (selectedClient == null)
{
Snackbar.Add("고객을 선택하세요.", Severity.Warning);
return;
}
var filing = new TaxFiling
{
ClientId = selectedClient.Id,
FilingType = newFilingType,
DueDate = newDueDate?.ToUniversalTime() ?? DateTime.UtcNow,
Status = "pending",
Memo = string.IsNullOrWhiteSpace(newMemo) ? null : newMemo
};
var result = await FilingClient.CreateAsync(filing);
if (result != null)
{
showAddForm = false;
Snackbar.Add("신고 일정이 추가되었습니다.", Severity.Success);
await Reload();
}
else
{
Snackbar.Add("추가 실패", Severity.Error);
}
}
catch (Exception ex)
{
Snackbar.Add($"오류: {ex.Message}", Severity.Error);
}
}
}
@@ -0,0 +1,300 @@
@page "/admin/tax-profiles"
@using TaxBaik.Web.Services.AdminClients
@using TaxBaik.WasmClient.Components.Admin.Shared
@inject ITaxProfileBrowserClient TaxProfileClient
@inject IClientBrowserClient ClientClient
@inject ISnackbar Snackbar
@inject IDialogService DialogService
@attribute [Authorize]
<PageTitle>세무 프로필</PageTitle>
<section class="admin-page-hero">
<div>
<MudText Typo="Typo.caption" Class="admin-eyebrow">CRM & 세무관리</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" OnClick="PrepareCreate" StartIcon="@Icons.Material.Filled.Add" id="btn-add-profile">
새 프로필 추가
</MudButton>
</section>
<AdminDataPanel Loading="@(profiles == null)" SkeletonContent="@ProfileSkeleton">
@if (profiles == null)
{
}
else
{
<MudGrid Spacing="2" Class="mt-2">
<!-- Left: Dense Grid List -->
<MudItem XS="12" MD="8">
@if (profiles.Count == 0)
{
<MudAlert Severity="Severity.Info">세무 프로필이 없습니다.</MudAlert>
}
else
{
<MudDataGrid T="TaxProfile"
Items="@profiles"
Dense="true"
Hover="true"
Striped="true"
Virtualize="true"
RowsPerPage="30"
SelectedItem="@selectedProfile"
SelectedItemChanged="OnRowSelected"
Class="admin-grid">
<Columns>
<PropertyColumn Property="x => x.Id" Title="ID" Sortable="true" />
<TemplateColumn Title="고객">
<CellTemplate>
@if (clientMap.TryGetValue(context.Item.ClientId, out var clientName))
{
@clientName
}
</CellTemplate>
</TemplateColumn>
<PropertyColumn Property="x => x.BusinessType" Title="사업 유형" />
<TemplateColumn Title="위험도">
<CellTemplate>
<MudChip Size="Size.Small" Color="@GetRiskColor(context.Item.TaxRiskLevel)" Variant="Variant.Filled">
@context.Item.TaxRiskLevel
</MudChip>
</CellTemplate>
</TemplateColumn>
<TemplateColumn Title="다음 신고">
<CellTemplate>
@if (context.Item.NextFilingDueDate.HasValue)
{
@context.Item.NextFilingDueDate.Value.ToString("yyyy-MM-dd")
}
</CellTemplate>
</TemplateColumn>
<TemplateColumn Title="작업" Sortable="false">
<CellTemplate>
<MudIconButton Icon="@Icons.Material.Filled.Delete" Color="Color.Error" Size="Size.Small" OnClick="@(async () => await DeleteProfile(context.Item.Id))" />
</CellTemplate>
</TemplateColumn>
</Columns>
</MudDataGrid>
}
</MudItem>
<!-- Right: Detail Form Panel (Inline Editor) -->
<MudItem XS="12" MD="4">
<MudPaper Class="pa-4 admin-surface admin-editor-panel" Elevation="0" Style="border: 1px solid var(--border-color); min-height: 400px;">
<div class="d-flex align-center justify-space-between mb-4">
<MudText Typo="Typo.h6" Class="font-weight-bold">@(isEditMode ? "세무 프로필 수정" : "새 세무 프로필 추가")</MudText>
@if (isEditMode)
{
<MudButton Size="Size.Small" Variant="Variant.Outlined" Color="Color.Secondary" OnClick="PrepareCreate">
새로 작성
</MudButton>
}
</div>
<MudForm @ref="form">
<MudSelect T="int?" @bind-Value="profileForm.ClientId" Label="고객" Required="true" Variant="Variant.Outlined" FullWidth="@true" Class="mb-3" RequiredError="고객을 선택하세요." Disabled="@isEditMode">
@foreach (var client in clients)
{
<MudSelectItem Value="@((int?)client.Id)">@GetClientDisplayName(client)</MudSelectItem>
}
</MudSelect>
<CommonCodeSelect @bind-Value="profileForm.BusinessType" Group="BUSINESS_TYPE" Label="사업 유형" Class="mb-3" Required="true" />
<CommonCodeSelect @bind-Value="profileForm.TaxRiskLevel" Group="TAX_RISK_LEVEL" Label="위험도" Class="mb-3" />
<MudDatePicker @bind-Date="profileForm.NextFilingDueDate" Label="다음 신고 예정일" Variant="Variant.Outlined" FullWidth="@true" Class="mb-3" />
<MudTextField T="string" @bind-Value="profileForm.SpecialNotes" Label="특수 사항" Variant="Variant.Outlined" FullWidth="@true" Lines="3" Class="mb-4" />
<div class="d-flex justify-end gap-2">
@if (isEditMode)
{
<MudButton Variant="Variant.Outlined" Color="Color.Error" OnClick="@(async () => await DeleteProfile(selectedProfile?.Id ?? 0))">삭제</MudButton>
}
<MudButton Variant="Variant.Filled" Color="Color.Primary" OnClick="SaveProfile" id="btn-save-profile">저장</MudButton>
</div>
</MudForm>
</MudPaper>
</MudItem>
</MudGrid>
}
</AdminDataPanel>
@code {
[CascadingParameter]
private Task<AuthenticationState>? AuthStateTask { get; set; }
private List<TaxProfile>? profiles;
private List<Client> clients = [];
private Dictionary<int, string> clientMap = new();
private List<CommonCode> riskLevels = [];
private MudForm? form;
private bool isEditMode;
private TaxProfile? selectedProfile;
private TaxProfileForm profileForm = new();
private RenderFragment ProfileSkeleton => builder =>
{
builder.OpenComponent<AdminSkeletonRows>(0);
builder.AddAttribute(1, "Rows", 6);
builder.AddAttribute(2, "Columns", 4);
builder.CloseComponent();
};
protected override async Task OnInitializedAsync()
{
if (AuthStateTask != null)
{
var authState = await AuthStateTask;
if (authState.User.Identity?.IsAuthenticated == true)
{
await LoadData();
PrepareCreate();
}
}
}
private async Task LoadData()
{
try
{
profiles = await TaxProfileClient.GetAllAsync();
var (clientItems, _) = await ClientClient.GetPagedAsync(pageSize: 1000);
clients = clientItems.ToList();
clientMap = clients.ToDictionary(c => c.Id, GetClientDisplayName);
}
catch (Exception ex)
{
Snackbar.Add($"데이터 로드 실패: {ex.Message}", Severity.Error);
}
}
private void PrepareCreate()
{
selectedProfile = null;
isEditMode = false;
profileForm = new TaxProfileForm
{
ClientId = clients.FirstOrDefault()?.Id,
TaxRiskLevel = "normal",
NextFilingDueDate = DateTime.Today.AddMonths(1)
};
}
private void OnRowSelected(TaxProfile profile)
{
if (profile == null) return;
selectedProfile = profile;
isEditMode = true;
profileForm = new TaxProfileForm
{
ClientId = profile.ClientId,
BusinessType = profile.BusinessType ?? "",
TaxRiskLevel = profile.TaxRiskLevel,
NextFilingDueDate = profile.NextFilingDueDate,
SpecialNotes = profile.SpecialNotes
};
}
private async Task SaveProfile()
{
if (form != null)
{
await form.Validate();
if (!form.IsValid)
{
Snackbar.Add("고객을 선택하세요.", Severity.Warning);
return;
}
}
try
{
if (isEditMode && selectedProfile != null)
{
await TaxProfileClient.UpdateAsync(selectedProfile.Id, profileForm.BusinessType,
null, profileForm.NextFilingDueDate, profileForm.TaxRiskLevel);
Snackbar.Add("세무 프로필이 수정되었습니다.", Severity.Success);
}
else
{
if (!profileForm.ClientId.HasValue)
{
Snackbar.Add("고객을 선택하세요.", Severity.Warning);
return;
}
var newId = await TaxProfileClient.CreateAsync(
profileForm.ClientId.Value,
profileForm.BusinessType);
if (newId > 0)
{
await TaxProfileClient.UpdateAsync(
newId,
profileForm.BusinessType,
null,
profileForm.NextFilingDueDate,
profileForm.TaxRiskLevel);
Snackbar.Add("세무 프로필이 추가되었습니다.", Severity.Success);
}
}
PrepareCreate();
await LoadData();
}
catch (Exception ex)
{
Snackbar.Add($"저장 실패: {ex.Message}", Severity.Error);
}
}
private async Task DeleteProfile(int id)
{
var parameters = new DialogParameters();
parameters.Add("Title", "삭제 확인");
parameters.Add("Message", "이 세무 프로필을 삭제하시겠습니까?");
var dialog = await DialogService.ShowAsync<ConfirmDialog>("", parameters);
var result = await dialog.Result;
if (result?.Canceled ?? true)
return;
try
{
await TaxProfileClient.DeleteAsync(id);
Snackbar.Add("세무 프로필이 삭제되었습니다.", Severity.Success);
if (selectedProfile?.Id == id)
{
PrepareCreate();
}
await LoadData();
}
catch (Exception ex)
{
Snackbar.Add($"삭제 실패: {ex.Message}", Severity.Error);
}
}
private Color GetRiskColor(string riskLevel) => riskLevel switch
{
"high" => Color.Error,
"normal" => Color.Warning,
"low" => Color.Success,
_ => Color.Default
};
private static string GetClientDisplayName(Client client)
=> !string.IsNullOrWhiteSpace(client.CompanyName)
? client.CompanyName
: !string.IsNullOrWhiteSpace(client.Name)
? client.Name
: $"Client #{client.Id}";
private class TaxProfileForm
{
public int? ClientId { get; set; }
public string BusinessType { get; set; } = "";
public string TaxRiskLevel { get; set; } = "normal";
public DateTime? NextFilingDueDate { get; set; }
public string? SpecialNotes { get; set; }
}
}