import React, { forwardRef } from 'react';
import { Modal, Form, Input } from 'antd';

const MinimumPurchase = forwardRef(options => {
  const [form] = Form.useForm();
  const handleCancel = () => {
    options.cancel(false);
  };
  const handleOk = async () => {
    const values = await form.validateFields();
    console.log('values :>> ', values);
  };

  return (
    <Modal
      visible={options.visible}
      title="修改最少购买数量"
      onOk={handleOk}
      maskClosable={false}
      destroyOnClose
      onCancel={handleCancel}
    >
      <Form
        name="basic"
        form={form}
        labelCol={{ span: 6 }}
        wrapperCol={{ span: 16 }}
        autoComplete="off"
      >
        <Form.Item
          label="最少购买/份"
          name="minPurchaseNum"
          rules={[{ required: true, message: '请输入最少购买数量!' }]}
        >
          <Input maxLength={6} type="number" />
        </Form.Item>
      </Form>
    </Modal>
  );
});

export default MinimumPurchase;
