35323f2b2c
- 대시보드: KPI 카드 (이번달 문의, 신규 문의, 포스트 수) - 블로그 관리: 목록/작성/수정 페이지 - 문의 관리: 목록 및 상태 변경 - 설정: 사이트 연락처 정보 - 인증: Cookie 기반 8시간 세션 Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
79 lines
2.8 KiB
Plaintext
79 lines
2.8 KiB
Plaintext
@page "/blog"
|
|
@using TaxBaik.Application.Services
|
|
@using TaxBaik.Domain.Interfaces
|
|
@attribute [Authorize]
|
|
@inject IBlogPostRepository BlogRepository
|
|
@inject DialogService DialogService
|
|
@inject Snackbar Snackbar
|
|
|
|
<PageTitle>블로그 관리</PageTitle>
|
|
|
|
<div class="mb-4 d-flex justify-content-between align-items-center">
|
|
<MudText Typo="Typo.h5">📝 블로그 관리</MudText>
|
|
<MudButton Variant="Variant.Filled" Color="Color.Primary"
|
|
Href="/taxbaik/admin/blog/create">새 포스트</MudButton>
|
|
</div>
|
|
|
|
<MudDataGrid Items="@posts" Striped="true" Hoverable="true" Loading="@isLoading">
|
|
<Columns>
|
|
<PropertyColumn Property="x => x.Title" Title="제목" />
|
|
<PropertyColumn Property="x => x.IsPublished" Title="발행">
|
|
<CellTemplate Context="cell">
|
|
<MudCheckBox @bind-Checked="@cell.Item.IsPublished"
|
|
@onchange="@((bool val) => TogglePublish(cell.Item.Id, val))" />
|
|
</CellTemplate>
|
|
</PropertyColumn>
|
|
<PropertyColumn Property="x => x.ViewCount" Title="조회수" />
|
|
<PropertyColumn Property="x => x.CreatedAt" Title="작성일" Format="yyyy-MM-dd" />
|
|
<TemplateColumn>
|
|
<CellTemplate Context="cell">
|
|
<MudButtonGroup>
|
|
<MudButton Variant="Variant.Text" Color="Color.Primary"
|
|
Href="@($"/taxbaik/admin/blog/{cell.Item.Id}/edit")">수정</MudButton>
|
|
<MudButton Variant="Variant.Text" Color="Color.Error"
|
|
@onclick="@((e) => DeletePost(cell.Item.Id))">삭제</MudButton>
|
|
</MudButtonGroup>
|
|
</CellTemplate>
|
|
</TemplateColumn>
|
|
</Columns>
|
|
</MudDataGrid>
|
|
|
|
@code {
|
|
private List<Domain.Entities.BlogPost> posts = [];
|
|
private bool isLoading = true;
|
|
|
|
protected override async Task OnInitializedAsync()
|
|
{
|
|
await LoadPosts();
|
|
}
|
|
|
|
private async Task LoadPosts()
|
|
{
|
|
isLoading = true;
|
|
var (items, total) = await BlogRepository.GetPagedAsync(1, 100);
|
|
posts = items.ToList();
|
|
isLoading = false;
|
|
}
|
|
|
|
private async Task TogglePublish(int postId, bool isPublished)
|
|
{
|
|
// TODO: Update publish status via service
|
|
Snackbar.Add("발행 상태가 변경되었습니다.", Severity.Success);
|
|
}
|
|
|
|
private async Task DeletePost(int postId)
|
|
{
|
|
var confirmed = await DialogService.ShowAsync<ConfirmDialog>(
|
|
"포스트 삭제", new DialogParameters { },
|
|
new DialogOptions { MaxWidth = MaxWidth.ExtraSmall });
|
|
|
|
var result = await confirmed.Result;
|
|
if (!result.Canceled)
|
|
{
|
|
// TODO: Delete via repository
|
|
await LoadPosts();
|
|
Snackbar.Add("포스트가 삭제되었습니다.", Severity.Success);
|
|
}
|
|
}
|
|
}
|