@page "/sales"
@using Indotalent.Features.Sales.CreditNote.Components
@using Indotalent.Features.Sales.DeliveryOrder.Components
@using Indotalent.Features.Sales.DeliveryReport.Components
@using Indotalent.Features.Sales.Invoice.Components
@using Indotalent.Features.Sales.InvoiceReport.Components
@using Indotalent.Features.Sales.PaymentReceive.Components
@using Indotalent.Features.Sales.PaymentReceiveReport.Components
@using Indotalent.Features.Sales.SalesOrder.Components
@using Indotalent.Features.Sales.SalesQuotation.Components
@using Indotalent.Features.Sales.SalesReport.Components
@using Indotalent.Features.Sales.SalesReturn.Components
@using Indotalent.Features.Sales.SalesReturnReport.Components
@using Microsoft.AspNetCore.Authorization
@using Indotalent.Infrastructure.Authorization.Identity
@using MudBlazor
@inject NavigationManager NavigationManager
@attribute [Authorize(Roles = $"{ApplicationRoles.Admin},{ApplicationRoles.Member}")]
@code {
private int _activeTabIndex = 0;
private readonly Dictionary _tabMapping = new()
{
{ 0, "quotation" },
{ 1, "order" },
{ 2, "delivery" },
{ 3, "return" },
{ 4, "invoice" },
{ 5, "credit-note" },
{ 6, "payment" },
{ 7, "report-sales" },
{ 8, "report-delivery" },
{ 9, "report-return" },
{ 10, "report-invoice" },
{ 11, "report-payment" }
};
protected override void OnInitialized()
{
var uri = NavigationManager.ToAbsoluteUri(NavigationManager.Uri);
if (Microsoft.AspNetCore.WebUtilities.QueryHelpers.ParseQuery(uri.Query).TryGetValue("tab", out var tabValue))
{
var tabStr = tabValue.ToString().ToLower();
var match = _tabMapping.FirstOrDefault(x => x.Value == tabStr);
_activeTabIndex = match.Value != null ? match.Key : 0;
}
}
private void OnTabChanged(int index)
{
_activeTabIndex = index;
_tabMapping.TryGetValue(index, out var tabName);
NavigationManager.NavigateTo($"/sales?tab={tabName ?? "quotation"}", replace: false);
}
}