import React, { useEffect } from 'react'
import { Form, Radio, Button, Modal } from 'antd'

const formItemLayout = {
  labelCol: {
    xs: { span: 24 },
    sm: { span: 6 },
  },
  wrapperCol: {
    xs: { span: 24 },
    sm: { span: 12 },
  },
}

const tailFormItemLayout = {
  wrapperCol: {
    xs: {
      span: 24,
      offset: 0,
    },
    sm: {
      span: 16,
      offset: 6,
    },
  },
}

const blockRadio = {
  display: 'block',
  height: '30px',
  lineHeight: '30px',
}

export default Form.create()(props => {

  const handleSubmit = e => {
    e.preventDefault()
    props.form.validateFields((err, values) => {
      if (!err) {
        props.onSubmit(values)
      }
    })
  }

  return (
    <Modal footer={null} maskClosable={false} onCancel={props.onCancel} visible={props.visible}>
      <Form {...formItemLayout} onSubmit={handleSubmit}>
        <Form.Item label="不通过原因">
          {
            props.form.getFieldDecorator('remark')(
              <Radio.Group>
                <Radio value="不认识的人的手机号" style={blockRadio}>不认识的人的手机号</Radio>
                <Radio value="其他原因需要沟通" style={blockRadio}>其他原因需要沟通</Radio>
              </Radio.Group>
            )
          }
        </Form.Item>
        <Form.Item {...tailFormItemLayout}>
          <Button type="primary" htmlType="submit">确定</Button>
          <Button onClick={props.onCancel} style={{ marginLeft: '48px' }}>取消</Button>
        </Form.Item>
      </Form>
    </Modal>
  )
})
