@page "/leave" @using Microsoft.AspNetCore.Authorization @using Indotalent.Infrastructure.Authorization.Identity @attribute [Authorize(Roles = $"{ApplicationRoles.Admin},{ApplicationRoles.Member}")] @using Indotalent.Features.Leave.LeaveBalance.Components @using Indotalent.Features.Leave.LeaveCategory @using Indotalent.Features.Leave.LeaveCategory.Components @using Indotalent.Features.Leave.LeaveRequest @using Indotalent.Features.Leave.LeaveBalance @using Indotalent.Features.Leave.LeaveRequest.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 { "request" => 0, "category" => 1, "balance" => 2, _ => 0 }; } } private void OnTabChanged(int index) { _activeTabIndex = index; string tabName = index switch { 0 => "request", 1 => "category", 2 => "balance", _ => "request" }; NavigationManager.NavigateTo($"/leave?tab={tabName}", replace: false); } }