/** * External dependencies */ import { __ } from '@wordpress/i18n'; import { Button, Spinner } from '@wordpress/components'; import { getAdminLink } from '@woocommerce/wc-admin-settings'; import { updateQueryString } from '@woocommerce/navigation'; import { useState } from '@wordpress/element'; export const Action = ( { hasSetup = false, isConfigured = false, isEnabled = false, isLoading = false, isRecommended = false, manageUrl = null, markConfigured, methodKey, onSetUp = () => {}, onSetupCallback, } ) => { const [ isBusy, setIsBusy ] = useState( false ); const classes = 'woocommerce-task-payment__action'; if ( isLoading ) { return ; } const handleClick = async () => { onSetUp( methodKey ); if ( onSetupCallback ) { setIsBusy( true ); await new Promise( onSetupCallback ) .then( () => { setIsBusy( false ); } ) .catch( () => { setIsBusy( false ); } ); return; } updateQueryString( { method: methodKey, } ); }; if ( hasSetup && ! isConfigured ) { return (
); } if ( ( hasSetup && isConfigured ) || ( ! hasSetup && isEnabled ) ) { if ( ! manageUrl ) { return null; } return (
); } return ( ); };