import React from 'react'; import { Form, Input } from 'antd'; import { CCRDraft } from 'types'; import { getCCRErrors } from 'modules/ccr/utils'; interface OwnProps { ccrId: number; initialState?: Partial; updateForm(form: Partial): void; } type Props = OwnProps; interface State extends Partial { title: string; brief: string; target: string; } class CCRFlowBasics extends React.Component { constructor(props: Props) { super(props); this.state = { title: '', brief: '', target: '', ...(props.initialState || {}), }; } render() { const { title, brief, target } = this.state; const errors = getCCRErrors(this.state, true); // Don't show target error at zero since it defaults to that // Error just shows up at the end to prevent submission if (target === '0') { errors.target = undefined; } return (
); } private handleInputChange = ( event: React.ChangeEvent, ) => { const { value, name } = event.currentTarget; this.setState({ [name]: value } as any, () => { this.props.updateForm(this.state); }); }; } export default CCRFlowBasics;