2021-09-21 19:33:44 +00:00
|
|
|
/**
|
|
|
|
* External dependencies
|
|
|
|
*/
|
|
|
|
import { __ } from '@wordpress/i18n';
|
|
|
|
import {
|
2022-07-06 06:20:11 +00:00
|
|
|
WCPayBanner,
|
|
|
|
WCPayBannerFooter,
|
|
|
|
WCPayBannerBody,
|
|
|
|
WCPayBenefits,
|
|
|
|
WCPayBannerImageCut,
|
2021-09-21 19:33:44 +00:00
|
|
|
} from '@woocommerce/onboarding';
|
2022-02-28 19:40:45 +00:00
|
|
|
import { useDispatch } from '@wordpress/data';
|
2021-09-21 19:33:44 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Internal dependencies
|
|
|
|
*/
|
|
|
|
|
|
|
|
import { Action } from '../Action';
|
2022-02-28 19:40:45 +00:00
|
|
|
import { connectWcpay } from './utils';
|
2022-07-06 06:20:11 +00:00
|
|
|
import './suggestion.scss';
|
2021-09-21 19:33:44 +00:00
|
|
|
|
|
|
|
export const Suggestion = ( { paymentGateway, onSetupCallback = null } ) => {
|
|
|
|
const {
|
|
|
|
id,
|
|
|
|
needsSetup,
|
|
|
|
installed,
|
|
|
|
enabled: isEnabled,
|
|
|
|
installed: isInstalled,
|
|
|
|
} = paymentGateway;
|
|
|
|
|
2022-02-28 19:40:45 +00:00
|
|
|
const { createNotice } = useDispatch( 'core/notices' );
|
|
|
|
// When the WC Pay is installed and onSetupCallback is null
|
|
|
|
// Overwrite onSetupCallback to redirect to the setup page
|
|
|
|
// when the user clicks on the "Finish setup" button.
|
|
|
|
// WC Pay doesn't need to be configured in WCA.
|
|
|
|
// It should be configured in its onboarding flow.
|
|
|
|
if ( installed && onSetupCallback === null ) {
|
|
|
|
onSetupCallback = () => {
|
|
|
|
connectWcpay( createNotice );
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2021-09-21 19:33:44 +00:00
|
|
|
return (
|
2022-07-06 06:20:11 +00:00
|
|
|
<div className="woocommerce-wcpay-suggestion">
|
|
|
|
<WCPayBanner>
|
|
|
|
<WCPayBannerBody
|
|
|
|
textPosition="left"
|
|
|
|
actionButton={
|
|
|
|
<Action
|
|
|
|
id={ id }
|
|
|
|
hasSetup={ true }
|
|
|
|
needsSetup={ needsSetup }
|
|
|
|
isEnabled={ isEnabled }
|
|
|
|
isRecommended={ true }
|
|
|
|
isInstalled={ isInstalled }
|
|
|
|
hasPlugins={ true }
|
|
|
|
setupButtonText={ __(
|
|
|
|
'Get started',
|
|
|
|
'woocommerce'
|
|
|
|
) }
|
|
|
|
onSetupCallback={ onSetupCallback }
|
|
|
|
/>
|
|
|
|
}
|
|
|
|
bannerImage={ <WCPayBannerImageCut /> }
|
|
|
|
/>
|
|
|
|
<WCPayBannerFooter />
|
|
|
|
</WCPayBanner>
|
|
|
|
<WCPayBenefits />
|
|
|
|
</div>
|
2021-09-21 19:33:44 +00:00
|
|
|
);
|
|
|
|
};
|