refactor: rename getSidebarLinks to useSidebarLinks for improved clarity and consistency
This commit is contained in:
parent
34baf20b31
commit
35d0ca9e12
@ -12,7 +12,7 @@ import {
|
|||||||
SidebarMenuItem,
|
SidebarMenuItem,
|
||||||
useSidebar,
|
useSidebar,
|
||||||
} from '@/components/ui/sidebar';
|
} from '@/components/ui/sidebar';
|
||||||
import { getSidebarLinks } from '@/config/sidebar-config';
|
import { useSidebarLinks } from '@/config/sidebar-config';
|
||||||
import { LocaleLink } from '@/i18n/navigation';
|
import { LocaleLink } from '@/i18n/navigation';
|
||||||
import { authClient } from '@/lib/auth-client';
|
import { authClient } from '@/lib/auth-client';
|
||||||
import { Routes } from '@/routes';
|
import { Routes } from '@/routes';
|
||||||
@ -35,7 +35,7 @@ export function DashboardSidebar({
|
|||||||
const { state } = useSidebar();
|
const { state } = useSidebar();
|
||||||
// console.log('sidebar currentUser:', currentUser);
|
// console.log('sidebar currentUser:', currentUser);
|
||||||
|
|
||||||
const sidebarLinks = getSidebarLinks();
|
const sidebarLinks = useSidebarLinks();
|
||||||
const filteredSidebarLinks = sidebarLinks.filter((link) => {
|
const filteredSidebarLinks = sidebarLinks.filter((link) => {
|
||||||
if (link.authorizeOnly) {
|
if (link.authorizeOnly) {
|
||||||
return link.authorizeOnly.includes(currentUser?.role || '');
|
return link.authorizeOnly.includes(currentUser?.role || '');
|
||||||
|
@ -27,7 +27,7 @@ import { websiteConfig } from './website';
|
|||||||
*
|
*
|
||||||
* @returns The sidebar config with translated titles and descriptions
|
* @returns The sidebar config with translated titles and descriptions
|
||||||
*/
|
*/
|
||||||
export function getSidebarLinks(): NestedMenuItem[] {
|
export function useSidebarLinks(): NestedMenuItem[] {
|
||||||
const t = useTranslations('Dashboard');
|
const t = useTranslations('Dashboard');
|
||||||
|
|
||||||
// if is demo website, allow user to access admin and user pages, but data is fake
|
// if is demo website, allow user to access admin and user pages, but data is fake
|
||||||
|
Loading…
Reference in New Issue
Block a user