import { FC } from 'react';

import { Step } from 'src/types/forms';

import FormFooter from './FormFooter';

export type FormSubmitProps = {
  steps: number;
  handleBack: () => void;
  currentStep: number;
  formFilled?: boolean;
  stepsList?: Step[];
  isSubmitting?: boolean;
  disabledContinue?: boolean;
};

export const FormSubmit: FC<FormSubmitProps> = props => {
  const {
    steps,
    handleBack,
    currentStep,
    formFilled = false,
    stepsList = [],
    isSubmitting = false,
    disabledContinue,
  } = props;

  const goBackStepper = () => {
    handleBack();
  };

  return (
    <>
      {(!formFilled || steps > 1) && (
        <FormFooter
          currentStep={currentStep}
          steps={steps}
          handleBack={goBackStepper}
          stepsList={stepsList}
          isSubmitting={isSubmitting}
          formFilled={formFilled}
          disabledContinue={disabledContinue}
        />
      )}
    </>
  );
};

export default FormSubmit;
