import React from 'react' import { connect, ConnectedProps } from 'react-redux' import { t } from 'ttag' import { selectZone } from '../actions/zones' import { getZoneLabel } from '../utils' const connector = connect( ({ runConfiguration }: { runConfiguration: any }) => { const { method, species, point, zones } = runConfiguration const { selected, matched, isFetchingZones } = zones const pointIsValid = point !== null && point.x !== null && point.y !== null && point.x !== '' && point.y !== '' return { zones: matched, species, selected, method, pointIsValid, isFetchingZones, } }, (dispatch: (event: any) => any) => { return { onZoneChange: (zone: string) => { dispatch(selectZone(zone)) }, } }, ) const SeedZoneChooser = ({ method, selected, zones, pointIsValid, isFetchingZones, onZoneChange, }: ConnectedProps) => { if (method !== 'seedzone') { return null } const noZoneLabel = pointIsValid ? t`No zones at this location...` : t`Select a location...` let content = (
) if (zones.length) { content = (
) } return (
{t`Select zone`}
{content}
) } export default connector(SeedZoneChooser)