@using System.Linq.Expressions @using AyCode.Core.Extensions @using AyCode.Core.Loggers @using AyCode.Services.Loggers @using TIAM.Core.Loggers @using TIAM.Entities.Products @using TIAM.Entities.Transfers @using TIAM.Services @using TIAMSharedUI.Pages @using TIAMSharedUI.Pages.Components @using TIAMSharedUI.Pages.User.SysAdmins @using TIAMWebApp.Shared.Application.Interfaces @using TIAMWebApp.Shared.Application.Services @using TIAMWebApp.Shared.Application.Utility @inject IEnumerable LogWriters @inject AdminSignalRClient _adminSignalRClient @inject ITransferDataService TransferDataService @using TIAMWebApp.Shared.Application.Services @inject GooglePlacesService GooglePlacesService @* Validate Address

@ValidationMessage

*@

Selected address: @Address

@*

@GetSelectedItemDescription()

*@ @* *@ @code { [Parameter] public EventCallback OnSliderChanged { get; set; } [Parameter] public string TextValue { get; set; } = ""; [Parameter] public string CssClass { get; set; } = ""; [Parameter] public Guid? ProductId { get; set; } public List Destinations = new List(); public DxTextBox TextField; TransferDestination Result; ILogger _logger; IEnumerable Data { get; set; } private string Address { get; set; } private string ValidationMessage { get; set; } private TransferDestination _selectedDestination; public TransferDestination SelectedDestination { get => _selectedDestination; set { if (_selectedDestination != value) { _selectedDestination = value; SetNewDestination(value.AddressString!); } } } protected override void OnParametersSet() { // StateHasChanged(); } protected override async Task OnInitializedAsync() { _logger = new LoggerClient(LogWriters.ToArray()); Data = await _adminSignalRClient.GetAllAsync>(SignalRTags.GetAllTransferDestinations); Guid? productAddressId = Guid.Empty; if (!ProductId.IsNullOrEmpty()) { var currentProduct = await _adminSignalRClient.GetByIdAsync(SignalRTags.GetProductById, ProductId); if (currentProduct != null) { if (!currentProduct.Profile.AddressId.IsNullOrEmpty()) { productAddressId = currentProduct.Profile.AddressId; } } } _logger.Debug($"List length: {Data.Count().ToString()}"); if (Data.Any(x => x.AddressId == (Guid)productAddressId)) { SelectedDestination = Data.Where(x => x.AddressId == (Guid)productAddressId).FirstOrDefault()!; } else { SelectedDestination = Data.FirstOrDefault(); } } // RenderFragment GetSelectedItemDescription() // { // if (SelectedDestination != null) // { // SetNewDestination(SelectedDestination); // return @ // Selected Item: ( // @GetFieldDescription(nameof(TransferDestination.Name), SelectedDestination.Name), // @GetFieldDescription(nameof(TransferDestination.AddressString), SelectedDestination.AddressString), // @GetFieldDescription(nameof(TransferDestination.Description), SelectedDestination.Description) // ) // ; // } // return @Selected Item: null; // } public void OnSelectedAddressChanged(string address) { Address = address; OnSliderChanged.InvokeAsync(address); } public void SetNewDestination(string address) { Address = address; OnSliderChanged.InvokeAsync(address); } // RenderFragment GetFieldDescription(string fieldName, object value) // { // return @@fieldName: @value; // } }