@using Indotalent.ConfigBackEnd.Extensions @using Indotalent.Features.Sales.SalesQuotation @using Indotalent.Features.Sales.SalesQuotation.Cqrs @using MudBlazor @using Indotalent.Features.Root.Shared @inject SalesQuotationService SalesQuotationService @inject IDialogService DialogService @inject ISnackbar Snackbar
Quotation Items @if (!ReadOnly) { Add Item }
Product Unit Price Quantity Total @if (!ReadOnly) { Actions } @context.ProductName @context.UnitPrice?.ToString("N2") @context.Quantity @context.Total?.ToString("N2") @if (!ReadOnly) { }
@code { [Parameter] public string SalesQuotationId { get; set; } = string.Empty; [Parameter] public List Items { get; set; } = new(); [Parameter] public bool ReadOnly { get; set; } = false; [Parameter] public EventCallback OnChanged { get; set; } private async Task OnAddClick() { var parameters = new DialogParameters { ["SalesQuotationId"] = SalesQuotationId }; var options = new DialogOptions { MaxWidth = MaxWidth.Small, FullWidth = true, CloseButton = true }; var dialog = await DialogService.ShowAsync<_SalesQuotationItemCreateForm>("Add Item", parameters, options); var result = await dialog.Result; if (result != null && !result.Canceled) await OnChanged.InvokeAsync(); } private async Task OnEditClick(SalesQuotationItemResponse item) { var parameters = new DialogParameters { ["Data"] = item }; var options = new DialogOptions { MaxWidth = MaxWidth.Small, FullWidth = true, CloseButton = true }; var dialog = await DialogService.ShowAsync<_SalesQuotationItemUpdateForm>("Edit Item", parameters, options); var result = await dialog.Result; if (result != null && !result.Canceled) await OnChanged.InvokeAsync(); } private async Task OnDeleteClick(SalesQuotationItemResponse item) { var parameters = new DialogParameters { ["ContentText"] = $"Are you sure you want to remove this item?" }; var dialog = await DialogService.ShowAsync<_DeleteConfirmation>("Delete Confirmation", parameters, new DialogOptions { MaxWidth = MaxWidth.ExtraSmall, FullWidth = true }); var result = await dialog.Result; if (result != null && !result.Canceled) { var success = await SalesQuotationService.DeleteSalesQuotationItemAsync(item.Id!); if (success) { Snackbar.Add("Removed successfully", Severity.Success); await OnChanged.InvokeAsync(); } } } }