import { useIntl } from "react-intl"; import { ProForm, type ProFormInstance, ProFormText, } from "@ant-design/pro-components"; import { message } from "antd"; import { post } from "../../request"; import { useRef } from "react"; import type { IAiModelRequest, IAiModelResponse } from "../../api/ai"; interface IWidget { studioName?: string; onCreate?: Function; } const AiModelCreate = ({ studioName, onCreate }: IWidget) => { const intl = useIntl(); const formRef = useRef(undefined); return ( formRef={formRef} onFinish={async (values: IAiModelRequest) => { if (typeof studioName === "undefined") { return; } const url = `/v2/ai-model`; console.info("api request", url, values); const res = await post(url, values); console.info("api response", res); if (res.ok) { message.success(intl.formatMessage({ id: "flashes.success" })); if (typeof onCreate !== "undefined") { onCreate(); formRef.current?.resetFields(); } } else { message.error(res.message); } }} > ); }; export default AiModelCreate;