@using System.Linq.Expressions @using AyCode.Core.Extensions @using AyCode.Core.Helpers @using AyCode.Core.Loggers @using AyCode.Services.Loggers @using AyCode.Services.SignalRs @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 DxTextBox TextField; TransferDestination Result; ILogger _logger; readonly List _destinations = []; private string _address = string.Empty; private string _validationMessage = string.Empty; private TransferDestination? _selectedDestination; public TransferDestination? SelectedDestination { get => _selectedDestination; set { if (_selectedDestination == value) return; _selectedDestination = value; SetNewDestination(value?.AddressString ?? string.Empty); } } protected override void OnParametersSet() { // StateHasChanged(); } protected override Task OnInitializedAsync() { _logger = new LoggerClient(LogWriters.ToArray()); if (ProductId.IsNullOrEmpty()) _adminSignalRClient.GetTransferDestinationsAsync(_destinations, GetTransferDestinationsCallback()).Forget(); else _adminSignalRClient.GetPublicTransferDestinationsAsync(_destinations, ProductId.Value, GetTransferDestinationsCallback()).Forget(); return Task.CompletedTask; Action GetTransferDestinationsCallback() { return () => { SelectedDestination = ProductId.IsNullOrEmpty() ? _destinations.FirstOrDefault() : _destinations.FirstOrDefault(x => x.ProductId == ProductId); }; } } // 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; // } }