import React from 'react' import { connect } from 'react-redux' import { setLatitude, setLongitude } from '../actions/point' type PointChooserProps = { lat: string | number lon: string | number onBlur: (target: string, value: string) => any } type PointChooserState = { latValue: string | null lonValue: string | null } class PointChooser extends React.Component { constructor(props: any) { super(props) this.state = { latValue: null, lonValue: null } } render() { const { lat, lon, onBlur } = this.props const { latValue, lonValue } = this.state const flag = (window as any).waffle.flag_is_active('map-seedlots') return (
) } } export default connect( (state: any) => { const { point } = state.runConfiguration let lat = '' let lon = '' if (point !== null) { lat = point.y ? point.y.toFixed(4) : '' lon = point.x ? point.x.toFixed(4) : '' } return { lat, lon } }, (dispatch: (action: any) => any) => { return { onBlur: (type: string, value: string) => { const number = parseFloat(value) if (Number.isNaN(number)) { return } switch (type) { case 'lat': dispatch(setLatitude(number)) break case 'lon': default: dispatch(setLongitude(number)) break } }, } }, )(PointChooser)