Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 | 17x 21x 29x | import { create } from 'zustand'
/**
* POST /auth/login returns no user payload beyond {status, message}, so
* useLogin seeds this store with just the submitted email as a provisional
* value. GET /auth/me (see useSyncAuthIdentity) confirms/corrects it with
* the real name right after — including after a page refresh, where this
* store starts out empty again. Consumers should still degrade gracefully
* (name can be briefly null) rather than assume it's always populated.
*/
interface AuthIdentity {
avatarUrl?: string | null
id: string | null
email: string
name: string | null
}
interface AuthIdentityState {
identity: AuthIdentity | null
setIdentity: (identity: AuthIdentity) => void
clearIdentity: () => void
}
export const useAuthIdentityStore = create<AuthIdentityState>((set) => ({
identity: null,
setIdentity: (identity) => set({ identity }),
clearIdentity: () => set({ identity: null }),
}))
|