@using Indotalent.Features.Thirdparty.Customer @using Indotalent.Features.Thirdparty.Customer.Cqrs @using MudBlazor @using Features.Root.Shared @inject CustomerService CustomerService @inject IDialogService DialogService @inject ISnackbar Snackbar
Customer Contacts @if (!ReadOnly) { Add Contact }
Name Job Title Contact Info Description @if (!ReadOnly) { Actions }
@context.Name @context.AutoNumber
@context.JobTitle
@context.EmailAddress @context.PhoneNumber
@context.Description @if (!ReadOnly) { }
@code { [Parameter] public string CustomerId { get; set; } = string.Empty; [Parameter] public List Contacts { get; set; } = new(); [Parameter] public bool ReadOnly { get; set; } = false; [Parameter] public EventCallback OnChanged { get; set; } private async Task OnAddClick() { var parameters = new DialogParameters { ["CustomerId"] = CustomerId }; var options = new DialogOptions { MaxWidth = MaxWidth.Small, FullWidth = true, CloseButton = true }; var dialog = await DialogService.ShowAsync<_CustomerContactCreateForm>("Add Customer Contact", parameters, options); var result = await dialog.Result; if (result != null && !result.Canceled) await OnChanged.InvokeAsync(); } private async Task OnEditClick(CustomerContactItemResponse item) { var parameters = new DialogParameters { ["Data"] = item }; var options = new DialogOptions { MaxWidth = MaxWidth.Small, FullWidth = true, CloseButton = true }; var dialog = await DialogService.ShowAsync<_CustomerContactUpdateForm>("Edit Customer Contact", parameters, options); var result = await dialog.Result; if (result != null && !result.Canceled) await OnChanged.InvokeAsync(); } private async Task OnDeleteClick(CustomerContactItemResponse item) { var parameters = new DialogParameters { ["ContentText"] = $"Are you sure you want to remove {item.Name} from contacts?" }; 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 CustomerService.DeleteCustomerContactAsync(item.Id!); if (success) { Snackbar.Add("Contact removed successfully", Severity.Success); await OnChanged.InvokeAsync(); } } } }