2021-10-26 08:40:35 +00:00
|
|
|
/**
|
|
|
|
* External dependencies
|
|
|
|
*/
|
|
|
|
import { Button } from '@wordpress/components';
|
|
|
|
import { __ } from '@wordpress/i18n';
|
|
|
|
import apiFetch from '@wordpress/api-fetch';
|
|
|
|
import { useDispatch } from '@wordpress/data';
|
|
|
|
import { useState } from '@wordpress/element';
|
|
|
|
import { WC_ADMIN_NAMESPACE } from '@woocommerce/data';
|
|
|
|
import { Link } from '@woocommerce/components';
|
2022-02-21 02:34:25 +00:00
|
|
|
import interpolateComponents from '@automattic/interpolate-components';
|
2021-10-26 08:40:35 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Internal dependencies
|
|
|
|
*/
|
|
|
|
import TimerImage from './timer.svg';
|
2022-04-27 14:36:39 +00:00
|
|
|
import { WC_ASSET_URL } from '../../utils/admin-settings';
|
2021-10-26 08:40:35 +00:00
|
|
|
|
|
|
|
const connect = ( createNotice, setIsBusy ) => {
|
|
|
|
const errorMessage = __(
|
|
|
|
'There was an error connecting to WooCommerce Payments. Please try again or connect later in store settings.',
|
2022-03-30 09:00:04 +00:00
|
|
|
'woocommerce'
|
2021-10-26 08:40:35 +00:00
|
|
|
);
|
|
|
|
setIsBusy( true );
|
|
|
|
apiFetch( {
|
|
|
|
path: WC_ADMIN_NAMESPACE + '/plugins/connect-wcpay',
|
|
|
|
method: 'POST',
|
|
|
|
} )
|
|
|
|
.then( ( response ) => {
|
|
|
|
window.location = response.connectUrl;
|
|
|
|
} )
|
|
|
|
.catch( () => {
|
|
|
|
createNotice( 'error', errorMessage );
|
|
|
|
setIsBusy( false );
|
|
|
|
} );
|
|
|
|
};
|
|
|
|
|
|
|
|
const WoocommercePaymentsHeader = ( { task, trackClick } ) => {
|
|
|
|
const { createNotice } = useDispatch( 'core/notices' );
|
|
|
|
const [ isBusy, setIsBusy ] = useState( false );
|
|
|
|
const onClick = () => {
|
|
|
|
trackClick();
|
|
|
|
connect( createNotice, setIsBusy );
|
|
|
|
};
|
|
|
|
|
|
|
|
return (
|
|
|
|
<div className="woocommerce-task-header__contents-container">
|
2022-04-27 14:36:39 +00:00
|
|
|
<img
|
|
|
|
alt={ __( 'Payment illustration', 'woocommerce' ) }
|
|
|
|
src={
|
|
|
|
WC_ASSET_URL + 'images/task_list/payment-illustration.png'
|
|
|
|
}
|
|
|
|
className="svg-background"
|
|
|
|
/>
|
2021-10-26 08:40:35 +00:00
|
|
|
<div className="woocommerce-task-header__contents">
|
2022-03-30 09:00:04 +00:00
|
|
|
<h1>{ __( "It's time to get paid", 'woocommerce' ) }</h1>
|
2021-10-26 08:40:35 +00:00
|
|
|
<p>
|
|
|
|
{ __(
|
|
|
|
"You're only one step away from getting paid. Verify your business details to start managing transactions with WooCommerce Payments.",
|
2022-03-30 09:00:04 +00:00
|
|
|
'woocommerce'
|
2021-10-26 08:40:35 +00:00
|
|
|
) }
|
|
|
|
</p>
|
|
|
|
<p>
|
|
|
|
{ interpolateComponents( {
|
|
|
|
mixedString: __(
|
|
|
|
'By clicking "Verify Details", you agree to the {{link}}Terms of Service{{/link}}',
|
2022-03-30 09:00:04 +00:00
|
|
|
'woocommerce'
|
2021-10-26 08:40:35 +00:00
|
|
|
),
|
|
|
|
components: {
|
|
|
|
link: (
|
|
|
|
<Link
|
|
|
|
href="https://wordpress.com/tos/"
|
|
|
|
target="_blank"
|
|
|
|
type="external"
|
|
|
|
rel="noreferrer"
|
|
|
|
/>
|
|
|
|
),
|
|
|
|
},
|
|
|
|
} ) }
|
|
|
|
</p>
|
|
|
|
<Button
|
|
|
|
isSecondary={ task.isComplete }
|
|
|
|
isPrimary={ ! task.isComplete }
|
|
|
|
isBusy={ isBusy }
|
|
|
|
disabled={ isBusy }
|
|
|
|
onClick={ onClick }
|
|
|
|
>
|
2022-03-30 09:00:04 +00:00
|
|
|
{ __( 'Verify details', 'woocommerce' ) }
|
2021-10-26 08:40:35 +00:00
|
|
|
</Button>
|
|
|
|
<p className="woocommerce-task-header__timer">
|
|
|
|
<img src={ TimerImage } alt="Timer" />{ ' ' }
|
2022-07-08 10:37:30 +00:00
|
|
|
<span>{ __( '2 minutes', 'woocommerce' ) }</span>
|
2021-10-26 08:40:35 +00:00
|
|
|
</p>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
};
|
|
|
|
|
|
|
|
export default WoocommercePaymentsHeader;
|