import { useEffect } from 'react';

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

import AssignTemplateDrawerShell from './components/AssignTemplateDrawerShell';

type Props = {
  registerOpen: (fn: () => void) => void;
};

const AssignTemplateDrawerController = ({ registerOpen }: Props) => {
  const { openDrawer } = useDrawerLayer();

  useEffect(() => {
    registerOpen(() => {
      openDrawer({ content: <AssignTemplateDrawerShell /> });
    });
  }, [openDrawer, registerOpen]);

  return null;
};

export default AssignTemplateDrawerController;
