@using FrontOffice.Main.Utilities
@using MudBlazor

<MudAutocomplete T="WeekDefinitionDto"
                 @bind-Value="_selectedWeek"
                 Label="@Label"
                 Placeholder="@Placeholder"
                 SearchFunc="SearchWeeksAsync"
                 ToStringFunc="@(w => w?.DropdownDisplay ?? string.Empty)"
                 Variant="@Variant"
                 Dense="@Dense"
                 Margin="@Margin"
                 Clearable="@Clearable"
                 ShowProgressIndicator="true"
                 ProgressIndicatorColor="Color.Primary"
                 AdornmentIcon="@Icons.Material.Filled.CalendarMonth"
                 AdornmentColor="Color.Primary"
                 Class="@Class"
                 Style="@Style">
    <ItemTemplate>
        <MudStack Spacing="0" Class="py-1">
            <MudStack Row="true" Justify="Justify.SpaceBetween" AlignItems="AlignItems.Center">
                <MudText Typo="Typo.body1">
                    @context.DisplayName
                    @if (context.IsCurrentWeek)
                    {
                        <MudChip T="string" Size="Size.Small" Color="Color.Primary" Class="ms-2">هفته جاری</MudChip>
                    }
                </MudText>
                <MudText Typo="Typo.caption" Class="mud-text-secondary">@context.PersianYear</MudText>
            </MudStack>
            <MudText Typo="Typo.caption" Class="mud-text-secondary">@context.DateRangeDisplay</MudText>
        </MudStack>
    </ItemTemplate>
    <NoItemsTemplate>
        <MudText Typo="Typo.body2" Class="pa-3">هفته‌ای یافت نشد</MudText>
    </NoItemsTemplate>
</MudAutocomplete>
