import { PageActionType } from '@/config/types'; import useSubmitLock from '@/hooks/use-submit-lock'; import { FormDrawer } from '@gpustack/core-ui'; import React, { useRef } from 'react'; import { FormData, BenchmarkListItem as ListItem } from '../config/types'; import BenchmarkForm from '../forms'; type AddModalProps = { title: string; action: PageActionType; open: boolean; currentData?: ListItem; // Used when action is EDIT clusterList?: Global.BaseOption[]; profilesOptions?: Global.BaseOption[]; datasetList?: Global.BaseOption[]; onOk: (values: FormData) => void; onCancel: () => void; }; const AddBenchmark: React.FC = ({ title, action, open, currentData, clusterList, profilesOptions = [], datasetList = [], onOk, onCancel }) => { const form = useRef(null); const { loading, guard, run, release } = useSubmitLock(); const handleSubmit = () => { guard(() => form.current?.submit()); }; const handleOk = async (data: FormData) => { await run(() => onOk({ ...data }) ); }; const handleCancel = () => { form.current?.resetFields(); onCancel(); }; return ( ); }; export default AddBenchmark;