@using Indotalent.ConfigBackEnd.Extensions @using Indotalent.Features.Thirdparty.CustomerGroup @using Indotalent.Features.Thirdparty.CustomerGroup.Cqrs @using Indotalent.Shared.Utils @using MudBlazor @inject CustomerGroupService CustomerGroupService @inject ISnackbar Snackbar @(ReadOnly ? "Customer Group Details" : "Edit Customer Group") @(ReadOnly ? "Viewing customer segment specification." : "Modify existing segment information.") Group Name Description Audit History Created At@DateTimeExtensions.ToString(_model.CreatedAt) Created By@(!string.IsNullOrEmpty(_model.CreatedBy) ? _model.CreatedBy : "System") Last Updated At@DateTimeExtensions.ToString(_model.UpdatedAt) Last Updated By@(!string.IsNullOrEmpty(_model.UpdatedBy) ? _model.UpdatedBy : "System") @(ReadOnly ? "Back to List" : "Cancel") @if (!ReadOnly) { @if (_processing) { Updating... } else { Save Changes } } @code { [Parameter] public UpdateCustomerGroupRequest Data { get; set; } = new(); [Parameter] public bool ReadOnly { get; set; } = false; [Parameter] public EventCallback OnCancel { get; set; } [Parameter] public EventCallback OnSuccess { get; set; } private MudForm _form = default!; private UpdateCustomerGroupValidator _validator = new(); private UpdateCustomerGroupRequest _model = new(); private bool _processing = false; protected override void OnInitialized() { _model = Data; } private async Task Submit() { if (ReadOnly) return; await _form.Validate(); if (!_form.IsValid) return; _processing = true; try { var response = await CustomerGroupService.UpdateCustomerGroupAsync(_model); await Task.Delay(500); if (response != null && response.IsSuccess) { Snackbar.Add("Customer group updated successfully", Severity.Success); await OnSuccess.InvokeAsync(); } } finally { _processing = false; } } }