/**
* External dependencies
*/
import React, { useEffect } from 'react';
import { registerPlugin } from '@wordpress/plugins';
import {
WooOnboardingTaskListItem,
WooOnboardingTask,
} from '@woocommerce/onboarding';
import { PLUGINS_STORE_NAME } from '@woocommerce/data';
import { useDispatch } from '@wordpress/data';
import { Spinner } from '@woocommerce/components';
/**
* Internal dependencies
*/
import { installActivateAndConnectWcpay } from './PaymentGatewaySuggestions/components/WCPay';
const WoocommercePaymentsTaskItem = () => {
const { installAndActivatePlugins } = useDispatch( PLUGINS_STORE_NAME );
const { createNotice } = useDispatch( 'core/notices' );
return (
{ ( { defaultTaskItem: DefaultTaskItem } ) => (
{
return new Promise( ( resolve, reject ) => {
return installActivateAndConnectWcpay(
reject,
createNotice,
installAndActivatePlugins
);
} );
} }
/>
) }
);
};
registerPlugin( 'woocommerce-admin-task-wcpay', {
scope: 'woocommerce-tasks',
render: WoocommercePaymentsTaskItem,
} );
const ReadyWcPay = () => {
const { installAndActivatePlugins } = useDispatch( PLUGINS_STORE_NAME );
const { createNotice } = useDispatch( 'core/notices' );
useEffect( () => {
new Promise( ( resolve, reject ) => {
return installActivateAndConnectWcpay(
reject,
createNotice,
installAndActivatePlugins
);
} );
}, [ createNotice, installAndActivatePlugins ] );
return (
Preparing payment settings...
);
};
// shows up at http://host/wp-admin/admin.php?page=wc-admin&task=woocommerce-payments which is the default url for woocommerce-payments task
const WoocommercePaymentsTaskPage = () => (
);
registerPlugin( 'woocommerce-admin-task-wcpay-page', {
scope: 'woocommerce-tasks',
render: WoocommercePaymentsTaskPage,
} );