@using Indotalent.Features.Pipeline.SalesRepresentative @using Indotalent.Features.Pipeline.SalesRepresentative.Cqrs @using Indotalent.Shared.Utils @using MudBlazor @inject SalesRepresentativeService SalesRepresentativeService @inject ISnackbar Snackbar
Add New Representative Register a new sales representative and assign them to a team.
Basic Information Representative Name Sales Team @foreach (var item in _lookupData.SalesTeams) { @item.Name } Job Title Employee Number Contact Details Phone Number Email Address Description / Notes
Cancel @if (_processing) { Processing... } else { Create Representative }
@code { [Parameter] public EventCallback OnCancel { get; set; } [Parameter] public EventCallback OnSuccess { get; set; } private MudForm _form = default!; private CreateSalesRepresentativeValidator _validator = new(); private CreateSalesRepresentativeRequest _model = new(); private LookupSalesRepresentativeResponse _lookupData = new(); private bool _processing = false; protected override async Task OnInitializedAsync() { var response = await SalesRepresentativeService.GetSalesRepresentativeLookupAsync(); if (response != null && response.IsSuccess) { _lookupData = response.Value!; } } private async Task Submit() { await _form.Validate(); if (!_form.IsValid) return; _processing = true; try { var response = await SalesRepresentativeService.CreateSalesRepresentativeAsync(_model); await Task.Delay(500); if (response != null && response.IsSuccess) { Snackbar.Add("Representative created successfully", Severity.Success); await OnSuccess.InvokeAsync(); } } finally { _processing = false; } } }