import { Card, Button, FormInputValidation, FormLabel, ExternalLink } from '@automattic/components'; import { localizeUrl } from '@automattic/i18n-utils'; import { localize } from 'i18n-calypso'; import { isEmpty } from 'lodash'; import PropTypes from 'prop-types'; import { Component } from 'react'; import { connect } from 'react-redux'; import FormTextInput from 'calypso/components/forms/form-text-input'; import StepWrapper from 'calypso/signup/step-wrapper'; import { submitSignupStep } from 'calypso/state/signup/progress/actions'; import './style.scss'; class CloneDestinationStep extends Component { static propTypes = { flowName: PropTypes.string, goToNextStep: PropTypes.func.isRequired, positionInFlow: PropTypes.number, stepName: PropTypes.string, signupDependencies: PropTypes.object, }; state = { form: { destinationSiteName: '', destinationSiteUrl: '', }, formErrors: { destinationSiteName: false, destinationSiteUrl: false, }, }; handleFieldChange = ( { target: { name, value } } ) => this.setState( { form: Object.assign( {}, this.state.form, { [ name ]: value } ), formErrors: { ...this.state.formErrors, [ name ]: false }, } ); goToNextStep = () => { const { translate } = this.props; const { form: { destinationSiteName, destinationSiteUrl }, } = this.state; const errors = Object.assign( ! destinationSiteName && { destinationSiteName: translate( 'Please provide a name for your site.' ), }, ! destinationSiteUrl && { destinationSiteUrl: translate( 'Please provide the destination URL.' ), } ); if ( isEmpty( errors ) ) { this.props.submitSignupStep( { stepName: this.props.stepName }, { destinationSiteName, destinationSiteUrl } ); this.props.goToNextStep(); } else { this.setState( { formErrors: errors } ); } }; renderStepContent() { const { translate } = this.props; const { formErrors } = this.state; return ( Destination site title { formErrors.destinationSiteName && ( ) } Destination site URL { formErrors.destinationSiteUrl && ( ) }

{ translate( 'By continuing, you agree to our {{TOS /}}', { components: { TOS: ( { translate( 'Terms of Service.' ) } ), }, } ) }

); } render() { const { flowName, stepName, positionInFlow, translate } = this.props; const headerText = translate( 'Getting started' ); const subHeaderText = translate( "Let's get started. What would you like to name your destination site and where is it located?" ); return ( ); } } export default connect( null, { submitSignupStep } )( localize( CloneDestinationStep ) );