3b45b0c121
- src/lib/constants.ts: centralized route paths, labels, thresholds - src/lib/utils.ts: formatting, color helpers, math utils - src/hooks/: useProperties, useMatches, useFutureSignals, useNeeds - src/components/scores/MatchScoreRing - src/components/data-quality/DataQualityBar - src/components/future-signals/SignalTypeBadge - src/components/cards/SourceTypeBadge - src/provider/AuthProvider (placeholder, swappable) - main.tsx: AuthProvider + centralized stale time Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
37 lines
1.1 KiB
TypeScript
37 lines
1.1 KiB
TypeScript
import { createContext, useContext, type ReactNode } from 'react'
|
|
import { useSessionStore } from '../stores/sessionStore'
|
|
import type { MockUser } from '../stores/sessionStore'
|
|
|
|
// Placeholder AuthContext — swap for real auth (Supabase, Auth0, etc.) later.
|
|
// All call sites use this context; no component imports sessionStore directly.
|
|
|
|
interface AuthContextValue {
|
|
user: MockUser | null
|
|
isAuthenticated: boolean
|
|
isLoading: boolean
|
|
login: (user: MockUser) => void
|
|
logout: () => void
|
|
}
|
|
|
|
const AuthContext = createContext<AuthContextValue | null>(null)
|
|
|
|
export function AuthProvider({ children }: { children: ReactNode }) {
|
|
const { currentUser, isAuthenticated, login, logout } = useSessionStore()
|
|
|
|
const value: AuthContextValue = {
|
|
user: currentUser,
|
|
isAuthenticated,
|
|
isLoading: false, // always resolved in mock mode
|
|
login,
|
|
logout,
|
|
}
|
|
|
|
return <AuthContext.Provider value={value}>{children}</AuthContext.Provider>
|
|
}
|
|
|
|
export function useAuth(): AuthContextValue {
|
|
const ctx = useContext(AuthContext)
|
|
if (!ctx) throw new Error('useAuth must be used within AuthProvider')
|
|
return ctx
|
|
}
|