import {ModalForm,ProForm} from '@ant-design/pro-components';import {ProFormText} from '@ant-design/pro-components';
import {FormattedMessage, useIntl} from '@umijs/max';
import {postContainerImageCreateContainerImage} from "@/services/resource/ContainerImage";
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.ContainerImage>;

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

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

    return (
      <ModalForm<API.ContainerImage>
        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) => {
        postContainerImageCreateContainerImage(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="name" label={<FormattedMessage id="resource.container_image.table.list.name" defaultMessage="$$$"/>} placeholder={`${intl.formatMessage({id: 'common.please_input', defaultMessage: '$$$'})}${intl.formatMessage({id: 'resource.container_image.table.list.name', defaultMessage: '$$$'})}`} required={true}
                      rules={[
                      {
                        required: true,
                        message: (
                          <FormattedMessage
                            id="resource.container_image.table.rule.required.name"
                            defaultMessage="name is required"
                          />
                        ),
                      },
                    ]}
                  />
<ProFormText width="md" name="version" label={<FormattedMessage id="resource.container_image.table.list.version" defaultMessage="$$$"/>} placeholder={`${intl.formatMessage({id: 'common.please_input', defaultMessage: '$$$'})}${intl.formatMessage({id: 'resource.container_image.table.list.version', defaultMessage: '$$$'})}`} required={true}
                      rules={[
                      {
                        required: true,
                        message: (
                          <FormattedMessage
                            id="resource.container_image.table.rule.required.version"
                            defaultMessage="version is required"
                          />
                        ),
                      },
                    ]}
                  />
<ProFormText width="md" name="path" label={<FormattedMessage id="resource.container_image.table.list.path" defaultMessage="$$$"/>} placeholder={`${intl.formatMessage({id: 'common.please_input', defaultMessage: '$$$'})}${intl.formatMessage({id: 'resource.container_image.table.list.path', defaultMessage: '$$$'})}`} required={false}/>
<ProFormText width="md" name="startCode" label={<FormattedMessage id="resource.container_image.table.list.startCode" defaultMessage="$$$"/>} placeholder={`${intl.formatMessage({id: 'common.please_input', defaultMessage: '$$$'})}${intl.formatMessage({id: 'resource.container_image.table.list.startCode', defaultMessage: '$$$'})}`} required={false}/>
<ProFormText width="md" name="type" label={<FormattedMessage id="resource.container_image.table.list.type" defaultMessage="$$$"/>} placeholder={`${intl.formatMessage({id: 'common.please_input', defaultMessage: '$$$'})}${intl.formatMessage({id: 'resource.container_image.table.list.type', defaultMessage: '$$$'})}`} required={false}/>
<ProFormText width="md" name="remark" label={<FormattedMessage id="resource.container_image.table.list.remark" defaultMessage="$$$"/>} placeholder={`${intl.formatMessage({id: 'common.please_input', defaultMessage: '$$$'})}${intl.formatMessage({id: 'resource.container_image.table.list.remark', defaultMessage: '$$$'})}`} required={false}/>
</ProForm.Group>
</ModalForm>)}
export default CreateForm;
