import React from 'react' import { connect, ConnectedProps } from 'react-redux' import { t } from 'ttag' import { selectCenter } from '../actions/variables' import ConfigurationStep from './ConfigurationStep' import MethodButton from './MethodButton' import SpeciesChooser from './SpeciesChooser' import SeedZoneChooser from './SeedZoneChooser' import config from '../config' const connector = connect( ({ runConfiguration }: { runConfiguration: any }) => { const { objective, method, center } = runConfiguration return { objective, method, center } }, dispatch => { return { onCenterChange: (center: string) => { dispatch(selectCenter(center)) }, } }, ) type TransferStepProps = ConnectedProps & { number: number active: boolean } const TransferStep = ({ number, active, objective, method, center, onCenterChange }: TransferStepProps) => { if (!active) { let label if (method === 'seedzone') { label = t`Transfer limits based on seed zone, climatic center based on the selected location` if (center === 'zone') { label = t`Transfer limits and climatic center based on seed zone` } } else { label = t`Custom transfer limits, climatic center based on the selected location` } return (
{label}
) } let centerNode = null if (method === 'seedzone' && objective === 'sites') { centerNode = (
{t`Which should be used as the climatic center?`}
 
) } const hasFunctions = !!config.functions && config.functions.length > 0 return (
    {t`Custom`} {t`Zone`} {hasFunctions ? {t`Trait`} : null} {t`Function`}
{centerNode} {method === 'seedzone' || method === 'trait' ? : null}
{method === 'seedzone' ? : null} ) } export default connector(TransferStep)