@using TaxBaik.Domain.Entities
@using TaxBaik.Web.Services.AdminClients
@inject ICommonCodeBrowserClient CommonCodeClient
@if (!string.IsNullOrWhiteSpace(Placeholder))
{
@Placeholder
}
@foreach (var item in items)
{
@item.CodeName
}
@code {
[Parameter] public string? Value { get; set; }
[Parameter] public EventCallback ValueChanged { get; set; }
[Parameter] public string Group { get; set; } = string.Empty;
[Parameter] public string Label { get; set; } = string.Empty;
[Parameter] public Variant Variant { get; set; } = Variant.Outlined;
[Parameter] public bool FullWidth { get; set; } = true;
[Parameter] public string? Class { get; set; }
[Parameter] public bool Required { get; set; }
[Parameter] public bool Clearable { get; set; }
[Parameter] public bool Disabled { get; set; }
[Parameter] public string? Placeholder { get; set; }
private List items = [];
protected override async Task OnParametersSetAsync()
{
var normalizedGroup = Group?.Trim() ?? string.Empty;
if (!string.Equals(normalizedGroup, _loadedGroup, StringComparison.OrdinalIgnoreCase))
{
_loadedGroup = normalizedGroup;
items = string.IsNullOrWhiteSpace(normalizedGroup)
? []
: (await CommonCodeClient.GetByGroupAsync(normalizedGroup))
.OrderBy(x => x.SortOrder)
.ThenBy(x => x.CodeName)
.ToList();
}
}
private string? _loadedGroup;
}