import { useDrawerLayer } from '@material-hu/components/layers/Drawers';

import {
  type ApplicationSource,
  type HiringPipelineWithCountResponse,
} from '../../../types';
import { AddCandidateDrawerContent } from '../components/AddCandidateDrawerContent';

type UseAddCandidateDrawerProps = {
  jobId?: number | null;
  stages: HiringPipelineWithCountResponse[];
  applicationSources: ApplicationSource[];
};

export const useAddCandidateDrawer = ({
  jobId,
  stages,
  applicationSources,
}: UseAddCandidateDrawerProps) => {
  const { openDrawer } = useDrawerLayer();

  const openAddCandidateDrawer = () => {
    openDrawer({
      content: (
        <AddCandidateDrawerContent
          jobId={jobId}
          stages={stages}
          applicationSources={applicationSources}
        />
      ),
      wrapperProps: { disableEscapeKeyDown: true },
    });
  };

  return { openAddCandidateDrawer };
};
