@using Indotalent.Features.Pipeline.Campaign.Cqrs @using Indotalent.Features.Root.Shared @using MudBlazor @inject CampaignService CampaignService @inject IDialogService DialogService @inject ISnackbar Snackbar
Campaign Budgets @if (!ReadOnly) { Add Budget }
No Title Amount @if (!ReadOnly) { Actions } @budgetContext.AutoNumber @budgetContext.Title @budgetContext.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<_BudgetCreateForm>("Add Budget", 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(CampaignBudgetResponse item) { var p = new DialogParameters { ["Data"] = item, ["Lookup"] = Lookup }; var d = await DialogService.ShowAsync<_BudgetUpdateForm>("Edit Budget", 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(CampaignBudgetResponse item) { var p = new DialogParameters { ["ContentText"] = $"Are you sure you want to delete budget {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.DeleteBudgetAsync(item.Id!)) { Snackbar.Add("Budget deleted successfully", Severity.Success); await OnChanged.InvokeAsync(); } } } }