import {ModalForm,ProForm} from '@ant-design/pro-components';import {ProFormText} from '@ant-design/pro-components';
import {FormattedMessage, useIntl} from '@umijs/max';
import {postActionDetectionCreateActionDetection} from "@/services/analysis/ActionDetection";
import React, {useState} from 'react';
import {Button, Form, message} from 'antd';
export type FormValueType = {
        target?: string;
        template?: string;
        type?: string;
        time?: string;
        frequency?: string;
      } & Partial<API.ActionDetection>;

      export type CreateFormProps = {
        createModalOpen: boolean;
        handleModal: ()=>void;
        values: Partial<API.ActionDetection>;
        reload: any;
      };
const CreateForm: React.FC<CreateFormProps> = (props) => {

    const intl = useIntl();
    const [form] = Form.useForm<API.ActionDetection>();

    return (
      <ModalForm<API.ActionDetection>
        title={intl.formatMessage({
          id: 'common.modal.table.create.title',
          defaultMessage: '$$$',
        })}
        open={props.createModalOpen}
        form={form}
        autoFocusFirstInput
        modalProps={{
          destroyOnClose: true,
          onCancel: () => props.handleModal(),
        }}
        submitTimeout={2000}
        onFinish={async (values) => {
        postActionDetectionCreateActionDetection(values).then(()=>{
          message.success(intl.formatMessage({id: 'common.success', defaultMessage: '$$$'}))
          props.reload()
        }).catch(()=>{
          message.error(intl.formatMessage({id: 'common.failure', defaultMessage: '$$$'}))
        })
        props.handleModal();
        return true;
      }}
      >

<ProForm.Group>
<ProFormText width="md" name="source" label={<FormattedMessage id="analysis.action_detection.table.list.source" defaultMessage="$$$"/>} placeholder="请输入视频来源" required={false}/>
<ProFormText width="md" name="configFile" label={<FormattedMessage id="analysis.action_detection.table.list.configFile" defaultMessage="$$$"/>} placeholder="请输入配置文件路径" required={false}/>
<ProFormText width="md" name="type" label={<FormattedMessage id="analysis.action_detection.table.list.type" defaultMessage="$$$"/>} placeholder="请输入类型" required={false}/>
<ProFormText width="md" name="remark" label={<FormattedMessage id="analysis.action_detection.table.list.remark" defaultMessage="$$$"/>} placeholder="请输入备注" required={false}/>
</ProForm.Group>
</ModalForm>)}
export default CreateForm;
