@page "/payroll"
@using Microsoft.AspNetCore.Authorization
@using Indotalent.Infrastructure.Authorization.Identity
@attribute [Authorize(Roles = $"{ApplicationRoles.Admin},{ApplicationRoles.Member}")]
@using Indotalent.Features.Payroll.Deduction.Components
@using Indotalent.Features.Payroll.Grade
@using Indotalent.Features.Payroll.Grade.Components
@using Indotalent.Features.Payroll.Income
@using Indotalent.Features.Payroll.Deduction
@using Indotalent.Features.Payroll.Income.Components
@using Indotalent.Features.Payroll.Payrolls
@using Indotalent.Features.Payroll.Payrolls.Components
@using MudBlazor
@inject NavigationManager NavigationManager
@code {
private int _activeTabIndex = 0;
protected override void OnInitialized()
{
var uri = NavigationManager.ToAbsoluteUri(NavigationManager.Uri);
if (Microsoft.AspNetCore.WebUtilities.QueryHelpers.ParseQuery(uri.Query).TryGetValue("tab", out var tabValue))
{
_activeTabIndex = tabValue.ToString().ToLower() switch
{
"process" => 0,
"grade" => 1,
"income" => 2,
"deduction" => 3,
_ => 0
};
}
}
private void OnTabChanged(int index)
{
_activeTabIndex = index;
string tabName = index switch
{
0 => "process",
1 => "grade",
2 => "income",
3 => "deduction",
_ => "process"
};
NavigationManager.NavigateTo($"/payroll?tab={tabName}", replace: false);
}
}