Files
Teamup/client/src/store/auth.ts
T

27 lines
755 B
TypeScript
Raw Normal View History

import { create } from 'zustand'
import { persist } from 'zustand/middleware'
interface AuthState {
token: string | null
memberId: string | null
organizationId: string | null
2026-06-09 15:15:35 +03:30
email: string | null
setAuth: (token: string, memberId: string, organizationId: string | null, email?: string | null) => void
logout: () => void
}
export const useAuth = create<AuthState>()(
persist(
(set) => ({
token: null,
memberId: null,
organizationId: null,
2026-06-09 15:15:35 +03:30
email: null,
setAuth: (token, memberId, organizationId, email = null) =>
set({ token, memberId, organizationId, email }),
logout: () => set({ token: null, memberId: null, organizationId: null, email: null }),
}),
{ name: 'teamup-auth' },
),
)