import { Button, Group, Modal, Select, type ModalBaseProps } from "@mantine/core"; import { t } from "@/config/i18n"; import { useForm } from "@mantine/form"; import { IconCancel, IconDownload } from "@tabler/icons-react"; import { useGetForms } from "@/services/api"; import { useMemo } from "react"; export type ContractModalProps = ModalBaseProps & { handleSubmit: (id: number) => void; }; export type ContractDownloadInputs = { form_id: number; }; export function ContractModal({ opened, onClose, handleSubmit }: ContractModalProps) { const { data: allForms } = useGetForms(); const form = useForm({ initialValues: { form_id: null, }, validate: { form_id: (value) => !value ? `${t("a form", { capfirst: true })} ${t("is required")}` : null, }, }); const formSelect = useMemo(() => { if (!allForms) { return []; } return allForms?.map((form) => ({ value: String(form.id), label: `${form.season} ${form.name}`, })); }, [allForms]); return (