2026-06-09 12:25:19 +03:30
|
|
|
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
|
2026-06-09 12:25:19 +03:30
|
|
|
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 }),
|
2026-06-09 12:25:19 +03:30
|
|
|
}),
|
|
|
|
|
{ name: 'teamup-auth' },
|
|
|
|
|
),
|
|
|
|
|
)
|