using Blazorise; using FoodsharingSiegen.Contracts.Enums; using FoodsharingSiegen.Server.BaseClasses; using Microsoft.AspNetCore.Components; namespace FoodsharingSiegen.Server.Dialogs { public partial class ProspectSortDialog : FsBase { [Parameter] public ProspectSortOption CurrentSort { get; set; } = ProspectSortOption.NameAscending; [Parameter] public Func? OnSortSelected { get; set; } public static async Task ShowAsync(IModalService modalService, ProspectSortOption currentSort, Func onSortSelected) { await modalService.Show("Sortieren", p => { p.Add(nameof(CurrentSort), currentSort); p.Add(nameof(OnSortSelected), onSortSelected); }, new ModalInstanceOptions { Size = ModalSize.Small, }); } private Color GetSortButtonColor(ProspectSortOption option) { return CurrentSort == option ? Color.Success : Color.Secondary; } private async Task SelectAsync(ProspectSortOption option) { if (OnSortSelected != null) await OnSortSelected(option); await ModalService.Hide(); } } }