@using Indotalent.Features.Pipeline.SalesTeam @using Indotalent.Features.Pipeline.SalesTeam.Cqrs @using MudBlazor @using Features.Root.Shared @inject SalesTeamService SalesTeamService @inject IDialogService DialogService @inject ISnackbar Snackbar
Team Representatives @if (!ReadOnly) { Add Representative }
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 SalesTeamId { get; set; } = string.Empty; [Parameter] public List Representatives { get; set; } = new(); [Parameter] public bool ReadOnly { get; set; } = false; [Parameter] public EventCallback OnChanged { get; set; } private async Task OnAddClick() { var parameters = new DialogParameters { ["SalesTeamId"] = SalesTeamId }; var options = new DialogOptions { MaxWidth = MaxWidth.Small, FullWidth = true, CloseButton = true }; var dialog = await DialogService.ShowAsync<_SalesRepresentativeCreateForm>("Add Team Representative", parameters, options); var result = await dialog.Result; if (result != null && !result.Canceled) await OnChanged.InvokeAsync(); } private async Task OnEditClick(SalesRepresentativeItemResponse item) { var parameters = new DialogParameters { ["Data"] = item }; var options = new DialogOptions { MaxWidth = MaxWidth.Small, FullWidth = true, CloseButton = true }; var dialog = await DialogService.ShowAsync<_SalesRepresentativeUpdateForm>("Edit Representative", parameters, options); var result = await dialog.Result; if (result != null && !result.Canceled) await OnChanged.InvokeAsync(); } private async Task OnDeleteClick(SalesRepresentativeItemResponse item) { var parameters = new DialogParameters { ["ContentText"] = $"Are you sure you want to remove {item.Name} from this team?" }; 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 SalesTeamService.DeleteSalesTeamRepresentativeAsync(item.Id!); if (success) { Snackbar.Add("Representative removed successfully", Severity.Success); await OnChanged.InvokeAsync(); } } } }