import React from 'react'; import { Input, Form, Icon, Select } from 'antd'; import { SelectValue } from 'antd/lib/select'; import { PROPOSAL_CATEGORY, CATEGORY_UI } from 'api/constants'; import { ProposalDraft } from 'types'; import { getCreateErrors } from 'modules/create/utils'; import { typedKeys } from 'utils/ts'; interface State extends Partial { title: string; brief: string; category?: PROPOSAL_CATEGORY; target: string; } interface Props { initialState?: Partial; updateForm(form: Partial): void; } export default class CreateFlowBasics extends React.Component { constructor(props: Props) { super(props); this.state = { title: '', brief: '', category: undefined, target: '', ...(props.initialState || {}), }; } handleInputChange = ( event: React.ChangeEvent, ) => { const { value, name } = event.currentTarget; this.setState({ [name]: value } as any, () => { this.props.updateForm(this.state); }); }; handleCategoryChange = (value: SelectValue) => { this.setState({ category: value as PROPOSAL_CATEGORY }, () => { this.props.updateForm(this.state); }); }; render() { const { title, brief, category, target } = this.state; const errors = getCreateErrors(this.state, true); return (
); } }