Add invite links

This commit is contained in:
2025-12-14 20:39:26 +07:00
parent d0b8eca600
commit 5db2f9c48d
11 changed files with 290 additions and 12 deletions

View File

@@ -9,21 +9,25 @@ interface AuthState {
isAuthenticated: boolean
isLoading: boolean
error: string | null
pendingInviteCode: string | null
login: (data: LoginData) => Promise<void>
register: (data: RegisterData) => Promise<void>
logout: () => void
clearError: () => void
setPendingInviteCode: (code: string | null) => void
consumePendingInviteCode: () => string | null
}
export const useAuthStore = create<AuthState>()(
persist(
(set) => ({
(set, get) => ({
user: null,
token: null,
isAuthenticated: false,
isLoading: false,
error: null,
pendingInviteCode: null,
login: async (data) => {
set({ isLoading: true, error: null })
@@ -77,6 +81,14 @@ export const useAuthStore = create<AuthState>()(
},
clearError: () => set({ error: null }),
setPendingInviteCode: (code) => set({ pendingInviteCode: code }),
consumePendingInviteCode: () => {
const code = get().pendingInviteCode
set({ pendingInviteCode: null })
return code
},
}),
{
name: 'auth-storage',
@@ -84,6 +96,7 @@ export const useAuthStore = create<AuthState>()(
user: state.user,
token: state.token,
isAuthenticated: state.isAuthenticated,
pendingInviteCode: state.pendingInviteCode,
}),
}
)