import {useContext} from 'react';

import {StepperContext, StepperContextType} from '../context/StepperContext';

export function useStepper<TSteps extends Record<string, any>>() {
  const context = useContext(StepperContext) as
    | StepperContextType<TSteps>
    | undefined;
  if (!context) {
    throw new Error('useStepper must be used inside StepperContext.Provider');
  }
  return context;
}
