/** * Profile Context * * React context for profile data. */ import { createContext, useContext } from 'react'; import type { ProfileContextValue } from './types'; const defaultContext: ProfileContextValue = { profiles: [], primaryProfile: null, isLoading: false, error: null, refetch: async () => {}, updateProfile: async () => { throw new Error('ProfileProvider not mounted'); }, isUpdating: false, getProfileByType: () => null, isDevMode: false, }; export const ProfileContext = createContext(defaultContext); /** * Hook to access profile data and operations. * * Must be used within a ProfileProvider or ProfileProviderWithDevBridge. * * @example * ```tsx * function ProfileBadge() { * const { profiles, primaryProfile, isLoading } = useProfile(); * * if (isLoading) return ; * if (!primaryProfile) return null; * * return ( * * {primaryProfile.displayName} - {primaryProfile.completionPercentage}% * * ); * } * ``` */ export function useProfile(): ProfileContextValue { return useContext(ProfileContext); }