app-context.ts 592 B

123456789101112131415161718192021222324252627
  1. 'use client'
  2. import { createContext, useContext } from 'use-context-selector'
  3. import type { App } from '@/types/app'
  4. import type { UserProfileResponse } from '@/models/common'
  5. export type AppContextValue = {
  6. apps: App[]
  7. mutateApps: () => void
  8. userProfile: UserProfileResponse
  9. mutateUserProfile: () => void
  10. }
  11. const AppContext = createContext<AppContextValue>({
  12. apps: [],
  13. mutateApps: () => { },
  14. userProfile: {
  15. id: '',
  16. name: '',
  17. email: '',
  18. },
  19. mutateUserProfile: () => { },
  20. })
  21. export const useAppContext = () => useContext(AppContext)
  22. export default AppContext