diff --git a/Schaad.Accounting.UI/Components/Pages/Controls/AccountSelector.razor b/Schaad.Accounting.UI/Components/Pages/Controls/AccountSelector.razor
index dcbef09..37fa8b1 100644
--- a/Schaad.Accounting.UI/Components/Pages/Controls/AccountSelector.razor
+++ b/Schaad.Accounting.UI/Components/Pages/Controls/AccountSelector.razor
@@ -1,7 +1,9 @@
-
\ No newline at end of file
+
\ No newline at end of file
diff --git a/Schaad.Accounting.UI/Components/Pages/Controls/AccountSelector.razor.cs b/Schaad.Accounting.UI/Components/Pages/Controls/AccountSelector.razor.cs
index 900ff6c..8fac290 100644
--- a/Schaad.Accounting.UI/Components/Pages/Controls/AccountSelector.razor.cs
+++ b/Schaad.Accounting.UI/Components/Pages/Controls/AccountSelector.razor.cs
@@ -1,7 +1,8 @@
using Microsoft.AspNetCore.Components;
+using Microsoft.FluentUI.AspNetCore.Components;
using Schaad.Accounting.Models;
-namespace Schaad.Accounting.UI.Components.Pages.Controls;
+namespace Schaad.Accounting.UI.Components.Pages.Controls;
public partial class AccountSelector : ComponentBase
{
@@ -10,10 +11,25 @@ public partial class AccountSelector : ComponentBase
[Parameter] public required IReadOnlyList Accounts { get; set; }
[Parameter] public EventCallback AccountIdChanged { get; set; }
+
+ private Account? SelectedAccount { get; set; }
- private async Task OnInputChanged(ChangeEventArgs e)
+ protected override void OnInitialized()
{
- AccountId = e.Value?.ToString();
+ SelectedAccount = Accounts.FirstOrDefault(account => account.Id == AccountId);
+ }
+
+ private async Task OnSearchAsync(OptionsSearchEventArgs e)
+ {
+ e.Items = Accounts.Where(i => i.Name.Contains(e.Text, StringComparison.OrdinalIgnoreCase))
+ .OrderBy(i => i.Name);
+ await Task.CompletedTask;
+ }
+
+ public async Task OnSelectedChanged(IEnumerable? s)
+ {
+ SelectedAccount = s?.FirstOrDefault();
+ AccountId = SelectedAccount?.Id;
await AccountIdChanged.InvokeAsync(AccountId);
}
}
\ No newline at end of file