import {createContext} from 'react';
import {SetState} from '@interfaces/generic';

import {HeaderProps, FooterProps, Step} from '../interfaces';

export type Data<TSteps extends Record<string, any>> = {
  [K in keyof TSteps]?: TSteps[K];
};

export interface StepperContextType<TSteps extends Record<string, any>> {
  currentIndex: number;
  goNext: () => void;
  goBack: () => void;
  goToStep: (id: number) => void;
  setHeaderProps: SetState<HeaderProps>;
  headerProps: HeaderProps;
  setFooterProps: SetState<FooterProps>;
  footerProps: FooterProps;
  data: Data<TSteps>;
  setData: SetState<Data<TSteps>>;
  totalStepsCount: number;
  steps: Step[];
  setIsVisibleModal: SetState<boolean>;
  isVisibleStepsModal: boolean;
  onClose: () => void;
}

export const StepperContext = createContext<
  StepperContextType<any> | undefined
>(undefined);
