import {ModalForm,ProForm} from '@ant-design/pro-components';import {ProFormText} from '@ant-design/pro-components';import {ProFormDateTimePicker} from '@ant-design/pro-components';
import {FormattedMessage, useIntl} from '@umijs/max';
import {putActionDetectionUpdateActionDetection} 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 UpdateFormProps = {
      updateModalOpen: boolean;
      handleModal: () => void;
      values: Partial<API.ActionDetection>;
      reload: any;
    };
const UpdateForm: React.FC<UpdateFormProps> = (props) => {

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

  return (
    <ModalForm<API.ActionDetection>
      title={intl.formatMessage({
        id: 'common.modal.table.update.title',
        defaultMessage: '$$$',
      })}
      open={props.updateModalOpen}
      form={form}
      autoFocusFirstInput
      modalProps={{
        destroyOnClose: true,
        onCancel: () => props.handleModal(),
      }}
      submitTimeout={2000}
      onFinish={async (values) => {
        putActionDetectionUpdateActionDetection(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="id" label="id" disabled={true} initialValue={props.values.id}/>
<ProFormText width="md" name="source" label={<FormattedMessage id="analysis.action_detection.table.list.source" defaultMessage="$$$"/>} placeholder="请输入视频来源" required={false} initialValue={props.values.source} disabled={false}/>
<ProFormText width="md" name="configFile" label={<FormattedMessage id="analysis.action_detection.table.list.configFile" defaultMessage="$$$"/>} placeholder="请输入配置文件路径" required={false} initialValue={props.values.configFile} disabled={false}/>
<ProFormText width="md" name="type" label={<FormattedMessage id="analysis.action_detection.table.list.type" defaultMessage="$$$"/>} placeholder="请输入类型" required={false} initialValue={props.values.type} disabled={false}/>
<ProFormText width="md" name="remark" label={<FormattedMessage id="analysis.action_detection.table.list.remark" defaultMessage="$$$"/>} placeholder="请输入备注" required={false} initialValue={props.values.remark} disabled={false}/>
<ProFormDateTimePicker width="md" name="createTime" label={<FormattedMessage id="analysis.action_detection.table.list.createTime" defaultMessage="$$$"/>} placeholder="请输入创建时间" required={false} initialValue={props.values.createTime} disabled={true}/>
<ProFormDateTimePicker width="md" name="updateTime" label={<FormattedMessage id="analysis.action_detection.table.list.updateTime" defaultMessage="$$$"/>} placeholder="请输入更新时间" required={false} initialValue={props.values.updateTime} disabled={true}/>
</ProForm.Group>
</ModalForm>)}
export default UpdateForm;
