import { useCallback, useRef } from 'react';

import { type Option } from '@material-hu/components/composed-components/RadioGroup/types';

export type AssignTemplateFormData = {
  collaborators: Option[];
  startDate: Date | null;
  templateId: string | null;
  templateName: string;
  repeatTemplate: boolean;
  includeHolidays: boolean;
};

export const useAssignTemplateDrawer = () => {
  const openRef = useRef<(() => void) | null>(null);

  const registerOpen = useCallback((fn: () => void) => {
    openRef.current = fn;
  }, []);

  const showAssignTemplateDrawer = useCallback(() => {
    openRef.current?.();
  }, []);

  return { showAssignTemplateDrawer, registerOpen };
};
