This commit is contained in:
DrSmoothl committed 2026-10-12 15:43:34 +08:00
1 parent effeb66554
commit 7c0519f75f
977 files changed
+198426 -158324

No files matched your search

+14 -16
View File
@@ -6,27 +6,25 @@ import { createContext, useContext, type ReactNode } from 'react';
* complete logout after page-local state has been cleared.
*/
export interface SessionValue {
status: string;
/** Invoked by AppLayout's logout handler after it has scrubbed its own state. */
onLogoutComplete: () => void;
/** Replays the first-run wizard without changing persisted account state. */
restartOnboarding: () => void;
status: string;
/** Invoked by AppLayout's logout handler after it has scrubbed its own state. */
onLogoutComplete: () => void;
/** Replays the first-run wizard without changing persisted account state. */
restartOnboarding: () => void;
}
const SessionContext = createContext<SessionValue | null>(null);
export function SessionProvider({
value,
children,
}: {
value: SessionValue;
children: ReactNode;
}) {
return <SessionContext.Provider value={value}>{children}</SessionContext.Provider>;
export function SessionProvider({ value, children }: { value: SessionValue; children: ReactNode }) {
return <SessionContext.Provider value={value}>{children}</SessionContext.Provider>;
}
export function useSession(): SessionValue {
const v = useContext(SessionContext);
if (!v) throw new Error('useSession must be used inside <SessionProvider>');
return v;
const v = useContext(SessionContext);
if (!v) {
throw new Error('useSession must be used inside <SessionProvider>');
}
return v;
}