'use client';

import { createContext, useContext, type Dispatch, type SetStateAction } from 'react';
import type { CrewWidgetConfigItem } from '@/types/response/crew/widgetConfig';

type CrewWidgetConfigContextValue = {
	items: CrewWidgetConfigItem[];
	loading: boolean;
	saving: boolean;
	setSaving: Dispatch<SetStateAction<boolean>>;
	fetchList: () => void;
};

export const CrewWidgetConfigContext = createContext<CrewWidgetConfigContextValue>({
	items: [],
	loading: true,
	saving: false,
	setSaving: () => {},
	fetchList: () => {}
});

export function useCrewWidgetConfigContext() {
	return useContext(CrewWidgetConfigContext);
}