minor bugfixing
This commit is contained in:
parent
9e7c3b2aa7
commit
41aa0fdd46
2 changed files with 25 additions and 0 deletions
|
|
@ -30,10 +30,12 @@ export function useCurrentUser() {
|
|||
setUser(data);
|
||||
// Cache user data in localStorage for privilege checkers
|
||||
localStorage.setItem('currentUser', JSON.stringify(data));
|
||||
console.log('✅ User data stored in localStorage:', data);
|
||||
} catch (error) {
|
||||
setUser(null);
|
||||
// Clear cached user data on error
|
||||
localStorage.removeItem('currentUser');
|
||||
console.error('❌ Failed to fetch user data:', error);
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -4,12 +4,35 @@ import styles from './HomeStyles/Home.module.css'
|
|||
|
||||
import Sidebar from '../../components/Sidebar';
|
||||
import PageManager from '../../components/PageManager';
|
||||
import { useCurrentUser } from '../../hooks/useUsers';
|
||||
|
||||
|
||||
|
||||
function Home () {
|
||||
// Ensure user data is loaded and cached in localStorage for privilege checks
|
||||
const { user, isLoading: userLoading, error: userError } = useCurrentUser();
|
||||
|
||||
// Show loading state while user data is being fetched
|
||||
if (userLoading) {
|
||||
return (
|
||||
<div className={styles.homeContainer}>
|
||||
<div className={styles.loadingContainer}>
|
||||
Lade Benutzerdaten...
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
// Show error state if user data failed to load
|
||||
if (userError) {
|
||||
return (
|
||||
<div className={styles.homeContainer}>
|
||||
<div className={styles.errorContainer}>
|
||||
Fehler beim Laden der Benutzerdaten: {userError}
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
// Loading component
|
||||
const LoadingComponent = () => (
|
||||
|
|
|
|||
Loading…
Reference in a new issue