@page "/thirdparty" @using Indotalent.Features.Thirdparty.Patient.Components @using Indotalent.Features.Thirdparty.PatientCategory.Components @using Indotalent.Features.Thirdparty.PatientContact.Components @using Indotalent.Features.Thirdparty.PatientGroup.Components @using Indotalent.Features.Thirdparty.Vendor.Components @using Indotalent.Features.Thirdparty.VendorCategory.Components @using Indotalent.Features.Thirdparty.VendorContact.Components @using Indotalent.Features.Thirdparty.VendorGroup.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, "patient-group" }, { 1, "patient-category" }, { 2, "patient" }, { 3, "patient-contact" }, { 4, "vendor-group" }, { 5, "vendor-category" }, { 6, "vendor" }, { 7, "vendor-contact" } }; 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($"/thirdparty?tab={tabName ?? "patient-group"}", replace: false); } }