talos-access / frontend /src /store /authStore.ts
Greg
Claude Sonnet 4.6
feat(purge): admin sees amber banner after data purge with dismiss action
309c40b
Raw History Blame Contribute Delete
863 Bytes
import { create } from 'zustand'
import { persist } from 'zustand/middleware'
interface AuthState {
token: string | null
user: {
id: number
account_id: number
email: string
name: string
lastname: string
role: string
plan: string
organization_name?: string
self_checkin_enabled: boolean
checkin_mode: string
permissions: string[]
account_purged_at?: string | null
} | null
setAuth: (token: string, user: AuthState['user']) => void
clearAuth: () => void
isAuthenticated: () => boolean
}
export const useAuthStore = create<AuthState>()(
persist(
(set, get) => ({
token: null,
user: null,
setAuth: (token, user) => set({ token, user }),
clearAuth: () => set({ token: null, user: null }),
isAuthenticated: () => !!get().token,
}),
{ name: 'talos-auth' },
),
)