@page "/discount-shop"
@page "/discount-orders"
@page "/discount-sales-reports"
@attribute [Authorize(Roles = "Administrator")]

<div>
    <MudText Typo="Typo.h5" Class="mb-3">سفارشات فروشگاه تخفیفی</MudText>

    <MudTabs Elevation="0" Rounded="true" Border="true" ApplyEffectsToContainer="true"
             PanelClass="pt-4" @bind-ActivePanelIndex="_activeTab">
        <MudTabPanel Text="سفارشات" Icon="@Icons.Material.Filled.ReceiptLong">
            <DiscountOrdersMainPage />
        </MudTabPanel>
        <MudTabPanel Text="گزارش فروش" Icon="@Icons.Material.Filled.BarChart">
            <SalesReports />
        </MudTabPanel>
    </MudTabs>
</div>

@code {
    private int _activeTab;

    protected override void OnInitialized()
    {
        var uri = Navigation.ToBaseRelativePath(Navigation.Uri).ToLowerInvariant().TrimEnd('/');
        _activeTab = uri switch
        {
            "discount-sales-reports" => 1,
            _ => 0
        };
    }
}
