@using TIAM.Entities.Products @using TIAM.Entities.Transfers @using TIAM.Entities.Drivers @using TIAM.Entities.Users @using TIAM.Models.Dtos.Users @using TIAM.Services @using TIAMSharedUI.Shared.Components.Grids @using TIAMWebApp.Shared.Application.Interfaces @using TIAMWebApp.Shared.Application.Services @using TIAMWebApp.Shared.Application.Utility @using TIAM.Core.Loggers @using AyCode.Core.Loggers @using AyCode.Services.Loggers @using AyCode.Core @inject IServiceProviderDataService ServiceProviderDataService @inject IEnumerable LogWriters @inject AdminSignalRClient AdminSignalRClient @inject IWizardProcessor WizardProcessor @inject IUserDataService UserDataService

User not found, type another email please

@{ if (ShowNestedRows) { } } @{ var transfer2 = (UserProductMapping)UserEditFormContext.EditModel; } @transfer2.UserId @{ var a = UserEditFormContext.GetEditor("UserId"); } @* Select user *@ Select user @UserEditFormContext.GetEditor("Permissions") @code { [Parameter] public bool KeyboardNavigationEnabled { get; set; } [Parameter] public IProductRelation ParentData { get; set; } = null!; [Parameter] public int GetAllTag { get; set; } = SignalRTags.GetAllUserProductMappings; [Parameter] public bool ShowNestedRows { get; set; } = false; [Parameter] public Guid? ContextId { get; set; } private Guid[] ContextIds = new Guid[0]; private LoggerClient _logger; List _availableProducts; private UserProductMappingDriverGrid _driverGrid; private UserProductMapping tempProductMapping; bool PopupVisible { get; set; } private DxMaskedInput emailInput; private DxButton button1; private ElementReference errorMessage; private string errorCss = "display: none;"; private List FoundUsers { get; set; } = new List(); private string Email { get; set; } = "email@email.com"; string EmailMask { get; set; } = @"(\w|[.-])+@(\w|-)+\.(\w|-){2,4}"; UserModelDto ChosenUser = null; protected override void OnParametersSet() { if (ContextId != null) { ContextIds = new Guid[1]; ContextIds[0] = (Guid)ContextId; } base.OnParametersSet(); } protected override async Task OnInitializedAsync() { _logger = new LoggerClient(LogWriters.ToArray()); //_logger.Info($"DetailGridData: {_detailGridData.Count}"); } void CustomizeEditModel(GridCustomizeEditModelEventArgs e) { if (!e.IsNew) return; UserProductMapping newUPM = (UserProductMapping)e.EditModel; newUPM.ProductId = (Guid)ContextId!; var newProductMapping = new UserProductMapping { Id = Guid.NewGuid(), ProductId = (Guid)ContextId, Permissions = 2 }; //e.EditModel = newProductMapping; } async Task EditModelSaving(GridEditModelSavingEventArgs e) { if (e.IsNew) _logger.Info("New orderData added"); else _logger.Info("orderData updated"); await UpdateDataAsync(); } async Task DataItemDeleting(GridDataItemDeletingEventArgs e) { _logger.Info("orderData deleted"); } async Task UpdateDataAsync() { //refresh grid _logger.Info("orderData grid refreshed"); } async Task FindUser() { var userModelDto = await UserDataService.GetUserByEmailAsync(Email); if (userModelDto != null) { ChosenUser = userModelDto; FoundUsers.Add(ChosenUser); emailInput.Enabled = false; button1.Visible = false; } else { emailInput.Value = "email@email.com"; errorCss = "display: block"; } } void CancelCreateClick() { PopupVisible = false; } void SelectDriverPopupClosed() { //cancel clicked } void SelectDriverPopupClosing(PopupClosingEventArgs args) { //myModel = new TransferWizardModel(); } public async Task SubmitForm(object result) { _logger.Info($"Submitted nested form: {result.GetType().FullName}"); } public async Task ShowPopup(UserProductMapping emptyProductMapping) { tempProductMapping = emptyProductMapping; PopupVisible = true; } private async Task OnUserSelected(Guid userId) { // Logic after the user is selected await Task.Run(() => Console.WriteLine($"Selected User ID: {userId}")); } private async Task OnRowClick(GridRowClickEventArgs e) { await SelectUser((Guid)e.Grid.GetRowValue(e.VisibleIndex, "Id")); } private async Task SelectUser(Guid id) { PopupVisible = false; tempProductMapping.UserId = id; await OnUserSelected(id); } void Grid_CustomizeElement(GridCustomizeElementEventArgs e) { if (e.ElementType == GridElementType.DataRow && (int)e.Grid.GetRowValue(e.VisibleIndex, "Permissions") == 1) { e.Style="display: none"; } // else if (e.ElementType == GridElementType.HeaderCell) // { // e.Style = "background-color: rgba(0, 0, 0, 0.08); font-style=bold"; // } } }