import React from 'react';
import { Button, Input, Form } from 'antd';
import styles from './Start.less';

const FormItem = Form.Item;

function Start({ dispatch, form, loading }) {
  const { getFieldDecorator, validateFields } = form;
  return (
    <Form className={styles.form}>
      <h3 className={styles.title}>在 Template 上添加一个项目</h3>
      <FormItem>
        {getFieldDecorator('url', {
          initialValue: 'https://github.com/dvajs/dva-example-user-dashboard/',
          rules: [{ type: 'string',
            required: true,
            pattern: /^https?:\/\/(www\.)?github\.com\/([\w-]+)\/([\w-]+)\/?/,
            message: 'url must be valid github url',
          }],
        })(<Input className={styles.input} placeholder="请填写脚手架的 GitHub 地址" />)}
      </FormItem>
      <FormItem style={{ marginTop: 55 }}>
        <Button
          type="primary"
          size="large"
          loading={loading.models.contribute}
          onClick={() => validateFields(['url'], { force: true }, (err, values) => {
            if (!err) {
              dispatch({ type: 'contribute/validateRepo', payload: values.url });
            }
          })}
        >
          添加项目
        </Button>
      </FormItem>
    </Form>
  );
}

export default Form.create()(Start);

@@ -229,16 +229,222 @@
 = form;%0A
+  const onSubmit = () =%3E %7B%0A    validateFields(%5B'url'%5D, %7B force: true %7D, (err, values) =%3E %7B%0A      if (!err) %7B%0A        dispatch(%7B type: 'contribute/validateRepo', payload: values.url %7D);%0A      %7D%0A    %7D);%0A  %7D;%0A
   return
@@ -446,16 +446,16 @@
 eturn (%0A
-
     %3CFor
@@ -692,16 +692,28 @@
 ules: %5B%7B
+%0A           
  type: '
@@ -1033,10 +1033,10 @@
 op: 
-55
+60
  %7D%7D%3E
@@ -1169,206 +1169,16 @@
 ck=%7B
-() =%3E validateFields(%5B'url'%5D, %7B force: true %7D, (err, values) =%3E %7B%0A            if (!err) %7B%0A              dispatch(%7B type: 'contribute/validateRepo', payload: values.url %7D);%0A            %7D%0A          %7D)
+onSubmit
 %7D%0A  

update code style