2021-09-21 19:33:44 +00:00
|
|
|
/**
|
|
|
|
* External dependencies
|
|
|
|
*/
|
|
|
|
import { __ } from '@wordpress/i18n';
|
|
|
|
import { recordEvent } from '@woocommerce/tracks';
|
|
|
|
import {
|
|
|
|
WCPayCard,
|
|
|
|
WCPayCardFooter,
|
|
|
|
WCPayCardBody,
|
2022-04-06 04:25:18 +00:00
|
|
|
WCPayBenefitCard,
|
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';
|
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-04-06 04:25:18 +00:00
|
|
|
<>
|
|
|
|
<WCPayCard>
|
|
|
|
<WCPayCardBody
|
|
|
|
heading={ 'Accept payments and manage your business.' }
|
|
|
|
onLinkClick={ () => {
|
|
|
|
recordEvent( 'tasklist_payment_learn_more' );
|
|
|
|
} }
|
|
|
|
>
|
2021-09-21 19:33:44 +00:00
|
|
|
<Action
|
|
|
|
id={ id }
|
|
|
|
hasSetup={ true }
|
|
|
|
needsSetup={ needsSetup }
|
|
|
|
isEnabled={ isEnabled }
|
|
|
|
isRecommended={ true }
|
|
|
|
isInstalled={ isInstalled }
|
|
|
|
hasPlugins={ true }
|
2022-04-06 04:25:18 +00:00
|
|
|
setupButtonText={
|
|
|
|
installed && needsSetup
|
|
|
|
? __( 'Finish setup', 'woocommerce' )
|
|
|
|
: __( 'Install', 'woocommerce' )
|
|
|
|
}
|
2021-09-21 19:33:44 +00:00
|
|
|
onSetupCallback={ onSetupCallback }
|
|
|
|
/>
|
2022-04-06 04:25:18 +00:00
|
|
|
</WCPayCardBody>
|
|
|
|
<WCPayCardFooter />
|
|
|
|
</WCPayCard>
|
|
|
|
<WCPayBenefitCard />
|
|
|
|
</>
|
2021-09-21 19:33:44 +00:00
|
|
|
);
|
|
|
|
};
|