Download apps/web/src/stores/authStore.ts from myagent10101/codesync-collaborative-platform: direct link, hf CLI and curl.
- Browser
- Download file 994 Bytes
-
https://huggingface.co/myagent10101/codesync-collaborative-platform/resolve/main/apps/web/src/stores/authStore.ts
- Command line
-
hf download hf://myagent10101/codesync-collaborative-platform/apps/web/src/stores/authStore.ts
-
curl -L -o authStore.ts https://huggingface.co/myagent10101/codesync-collaborative-platform/resolve/main/apps/web/src/stores/authStore.ts
994 Bytes
| import { create } from 'zustand'; | |
| import { persist } from 'zustand/middleware'; | |
| import type { User, AuthTokens } from '../types'; | |
| interface AuthState { | |
| user: User | null; | |
| tokens: AuthTokens | null; | |
| isAuthenticated: boolean; | |
| isLoading: boolean; | |
| setAuth: (user: User, tokens: AuthTokens) => void; | |
| setTokens: (tokens: AuthTokens) => void; | |
| logout: () => void; | |
| setLoading: (loading: boolean) => void; | |
| } | |
| export const useAuthStore = create<AuthState>()( | |
| persist( | |
| (set) => ({ | |
| user: null, tokens: null, isAuthenticated: false, isLoading: true, | |
| setAuth: (user, tokens) => set({ user, tokens, isAuthenticated: true, isLoading: false }), | |
| setTokens: (tokens) => set({ tokens }), | |
| logout: () => set({ user: null, tokens: null, isAuthenticated: false }), | |
| setLoading: (isLoading) => set({ isLoading }), | |
| }), | |
| { name: 'codesync-auth', partialize: (state) => ({ user: state.user, tokens: state.tokens, isAuthenticated: state.isAuthenticated }) } | |
| ) | |
| ); | |