import React, {Component, PropTypes} from 'react';
import {Row, Col, Form, Input, Button, Checkbox, Select, Icon} from 'antd';
import style from './style.less';
import {queryListAction} from '../../actions';

const FormItem = Form.Item;
const Option = Select.Option;

const FilterGroup = React.createClass({
	render() {
    const { getFieldProps } = this.props.form;
		return (
      <div className={style.filter}>
        <Form inline className={style.form} onSubmit={this.handleSubmit}>
          <Button className={style.button} type="primary" icon="plus" >创建您的{this.props.type.name}</Button>
          <Button className={style.button} type="primary" >操作</Button>
          <FormItem
            label="关键词"
            >
            <Input
              style={{width: 200}}
              type="text"
              placeholder="模糊查询关键词"
              {...getFieldProps('keyword')}
              />
          </FormItem>
          <div className="search-btn">
            <Button
              type="primary"
              htmlType="submit"
            >
              <Icon type="search"/> 搜索
            </Button>
          </div>
        </Form>
      </div>
    );
	},

  handleSubmit(e) {
    e.preventDefault();
    let values = this.props.form.getFieldsValue();
    this.props.dispatch(
      queryListAction(this.props.type, values)
    )
  }
});

export default Form.create()(FilterGroup);