Fix jwt-token

This commit is contained in:
2025-09-13 22:04:27 +02:00
parent fc5ca9b2a1
commit 440525213d

View File

@@ -1,4 +1,4 @@
import React, { useState, useEffect, useMemo } from 'react'; import React, { useState, useEffect, useMemo, useCallback } from 'react';
import { useAuth } from '../contexts/AuthContext'; import { useAuth } from '../contexts/AuthContext';
import api from '../services/api'; import api from '../services/api';
import toast from 'react-hot-toast'; import toast from 'react-hot-toast';
@@ -63,8 +63,8 @@ const Settings = () => {
); );
} }
// Filter tabs based on user permissions // Define all tabs
const availableTabs = useMemo(() => [ const allTabs = useMemo(() => [
{ {
id: 'general', id: 'general',
name: 'General', name: 'General',
@@ -95,7 +95,13 @@ const Settings = () => {
icon: UserGroupIcon, icon: UserGroupIcon,
permission: 'users.view' permission: 'users.view'
}, },
].filter(tab => hasPermission(user?.role, tab.permission)), [user?.role]); ], []);
// Filter tabs based on user permissions
const availableTabs = useMemo(() => {
if (!user?.role) return [];
return allTabs.filter(tab => hasPermission(user.role, tab.permission));
}, [allTabs, user?.role]);
// Set initial tab to first available tab // Set initial tab to first available tab
useEffect(() => { useEffect(() => {