Fix: Resolve AuthState type error
The error "Property 'user' does not exist on type 'AuthState'" in `src/components/settings/MeuCadastroForm.tsx` is fixed. The code was updated to correctly access the user information from the authentication store.
This commit is contained in:
parent
ea1d873675
commit
e5b764b986
@ -3,10 +3,21 @@ import { create } from 'zustand';
|
||||
|
||||
interface AuthState {
|
||||
isLoggedIn: boolean;
|
||||
user: { id: string } | null;
|
||||
setLoggedIn: (status: boolean) => void;
|
||||
setUser: (user: { id: string } | null) => void;
|
||||
}
|
||||
|
||||
// Initialize with the persisted value from localStorage
|
||||
// Função para recuperar o userId inicial (se existir)
|
||||
const getInitialUser = (): { id: string } | null => {
|
||||
try {
|
||||
const id = localStorage.getItem('userId');
|
||||
return id ? { id } : null;
|
||||
} catch (e) {
|
||||
return null;
|
||||
}
|
||||
};
|
||||
|
||||
const getInitialState = (): boolean => {
|
||||
try {
|
||||
return localStorage.getItem('autenticado') === 'true';
|
||||
@ -17,5 +28,7 @@ const getInitialState = (): boolean => {
|
||||
|
||||
export const authStore = create<AuthState>((set) => ({
|
||||
isLoggedIn: getInitialState(),
|
||||
user: getInitialUser(),
|
||||
setLoggedIn: (status) => set({ isLoggedIn: status }),
|
||||
setUser: (user) => set({ user }),
|
||||
}));
|
||||
|
||||
Loading…
Reference in New Issue
Block a user