feat(F020): frontend infrastructure foundation
- 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>
This commit is contained in:
@@ -0,0 +1,36 @@
|
||||
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
|
||||
}
|
||||
Reference in New Issue
Block a user