'use client' import { createContext, useContext, useContextSelector } from 'use-context-selector' import type { App } from '@/types/app' import type { UserProfileResponse } from '@/models/common' import { createRef, FC, PropsWithChildren } from 'react' export const useSelector = (selector: (value: AppContextValue) => T): T => useContextSelector(AppContext, selector); export type AppContextValue = { apps: App[] mutateApps: () => void userProfile: UserProfileResponse mutateUserProfile: () => void pageContainerRef: React.RefObject, useSelector: typeof useSelector, } const AppContext = createContext({ apps: [], mutateApps: () => { }, userProfile: { id: '', name: '', email: '', }, mutateUserProfile: () => { }, pageContainerRef: createRef(), useSelector, }) export type AppContextProviderProps = PropsWithChildren<{ value: Omit }> export const AppContextProvider: FC = ({ value, children }) => ( {children} ) export const useAppContext = () => useContext(AppContext) export default AppContext