context.tsx 642 B

123456789101112131415161718192021222324
  1. 'use client';
  2. import { createContext, useContext, type Dispatch, type SetStateAction } from 'react';
  3. import type { CrewWidgetConfigItem } from '@/types/response/crew/widgetConfig';
  4. export type CrewWidgetConfigContextValue = {
  5. items: CrewWidgetConfigItem[];
  6. loading: boolean;
  7. saving: boolean;
  8. setSaving: Dispatch<SetStateAction<boolean>>;
  9. fetchList: () => void;
  10. };
  11. export const CrewWidgetConfigContext = createContext<CrewWidgetConfigContextValue>({
  12. items: [],
  13. loading: true,
  14. saving: false,
  15. setSaving: () => {},
  16. fetchList: () => {}
  17. });
  18. export function useCrewWidgetConfigContext() {
  19. return useContext(CrewWidgetConfigContext);
  20. }