@using Indotalent.Features.Pipeline.Campaign.Cqrs @using Indotalent.Features.Root.Shared @using MudBlazor @inject CampaignService CampaignService @inject IDialogService DialogService @inject ISnackbar Snackbar
Campaign Expenses @if (!ReadOnly) { Add Expense }
No Title Amount @if (!ReadOnly) { Actions } @expenseContext.AutoNumber @expenseContext.Title @expenseContext.Amount?.ToString("N0") @if (!ReadOnly) { }
@code { [Parameter] public string CampaignId { get; set; } = string.Empty; [Parameter] public List Items { get; set; } = new(); [Parameter] public CampaignLookupResponse Lookup { get; set; } = new(); [Parameter] public bool ReadOnly { get; set; } = false; [Parameter] public EventCallback OnChanged { get; set; } private async Task OnAddClick() { var p = new DialogParameters { ["CampaignId"] = CampaignId, ["Lookup"] = Lookup }; var d = await DialogService.ShowAsync<_ExpenseCreateForm>("Add Expense", p, new DialogOptions { MaxWidth = MaxWidth.Small, FullWidth = true }); var result = await d.Result; if (result != null && !result.Canceled) { await OnChanged.InvokeAsync(); } } private async Task OnEditClick(CampaignExpenseResponse item) { var p = new DialogParameters { ["Data"] = item, ["Lookup"] = Lookup }; var d = await DialogService.ShowAsync<_ExpenseUpdateForm>("Edit Expense", p, new DialogOptions { MaxWidth = MaxWidth.Small, FullWidth = true }); var result = await d.Result; if (result != null && !result.Canceled) { await OnChanged.InvokeAsync(); } } private async Task OnDeleteClick(CampaignExpenseResponse item) { var p = new DialogParameters { ["ContentText"] = $"Are you sure you want to delete expense {item.AutoNumber}?" }; var d = await DialogService.ShowAsync<_DeleteConfirmation>("Delete Confirmation", p, new DialogOptions { MaxWidth = MaxWidth.ExtraSmall, FullWidth = true }); var result = await d.Result; if (result != null && !result.Canceled) { if (await CampaignService.DeleteExpenseAsync(item.Id!)) { Snackbar.Add("Expense removed successfully", Severity.Success); await OnChanged.InvokeAsync(); } } } }