File size: 1,537 Bytes
1e92f2d | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 | import { Card } from '@automattic/components';
import { Component } from 'react';
import SiteSelector from 'calypso/components/site-selector';
import StepWrapper from 'calypso/signup/step-wrapper';
import SitePickerSubmit from './site-picker-submit';
import './style.scss';
class SitePicker extends Component {
state = {
siteSlug: null,
};
handleSiteSelect = ( siteSlug ) => {
this.setState( {
siteSlug,
} );
};
filterSites = ( site ) => {
const isWPCOMSimpleSite = ! site.jetpack && ! site.is_a4a_client;
const isWPCOMSite =
( isWPCOMSimpleSite || site.is_wpcom_atomic ) && ! site.is_wpcom_staging_site;
return site.capabilities?.manage_options && isWPCOMSite && ! site.options?.is_domain_only;
};
renderScreen() {
return (
<Card className="site-picker__wrapper">
<SiteSelector filter={ this.filterSites } onSiteSelect={ this.handleSiteSelect } />
</Card>
);
}
render() {
if ( this.state.siteSlug ) {
const { stepSectionName, stepName, goToStep } = this.props;
return (
<SitePickerSubmit
siteSlug={ this.state.siteSlug }
stepSectionName={ stepSectionName }
stepName={ stepName }
goToStep={ goToStep }
/>
);
}
return (
<StepWrapper
flowName={ this.props.flowName }
stepName={ this.props.stepName }
positionInFlow={ this.props.positionInFlow }
fallbackHeaderText={ this.props.headerText }
fallbackSubHeaderText={ this.props.subHeaderText }
stepContent={ this.renderScreen() }
/>
);
}
}
export default SitePicker;
|