/* tslint:disable:jsx-no-lambda */ import * as React from 'react'; import { connect } from 'react-redux' import { resetForm, destroyForm } from '../actions' import { updateJobField, updateVehicleField, EXAMPLE_FORM_KEY, } from './example-actions' import { FormHandler, FormModel, Location } from '../interfaces' import { Column, Text, Header, DateTimeInput, Form, FormGroup, AddressInput, PhoneInput, NumberInput, // FormBox, // THESE FORM COMPONENTS NEED TO BE BROUGHT ONTO THE NEW SYSTEM // RadioButton, // RadioGroup, Select, TextInput, Button, } from '../web' import { formatDateForInput } from '../validators' const mockLocation = { address: { streets: [ '2 Upland Crescent', 'Leeds', ], locality: 'Leeds', town: 'Leeds', country: 'GBR', postcode: 'LS8 2TB', }, position: { coordinates: [ -1.509331, 53.820307, ], type: 'Point', }, } const mockDate = '2017-06-14T15:11:55.170Z' const mockPhoneNumber = '07790054721' interface FormExampleProps { job: any resetForm: (formName: string) => any destroyForm: (formName: string) => any vehicles: any[] selectedVehicle: any updateJobField: FormHandler updateVehicleField: FormHandler } export class _FormExample extends React.Component { public onSubmit = (formData: FormModel) => console.log('FORM DATA IS VALID', formData) public render() { console.log('render form example', this.props) const { vehicles, job, selectedVehicle, resetForm, destroyForm } = this.props return (
A demo form
< FormGroup label="Enter a date" > {/* THE ADDRESS INPUT ISN'T READY YET - DISPLAY ONLY */}
) } } const mapDispatchToProps = { resetForm, destroyForm, updateJobField, updateVehicleField, } const mapStateToProps = (state: any) => ({ job: state.example.job, vehicles: state.example.vehicles, selectedVehicle: state.example.selectedVehicle, }) export const FormExample = connect(mapStateToProps, mapDispatchToProps)(_FormExample) /* tslint:enable:jsx-no-lambda */