Add invite links
This commit is contained in:
@@ -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,
|
||||
}),
|
||||
}
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user