Disable the Connect-button during login

This commit is contained in:
Philipp Stracker 2024-12-06 14:37:48 +01:00
parent 3174bc158f
commit 4f3c4e6f3d
No known key found for this signature in database

View file

@ -2,6 +2,7 @@ import { Button } from '@wordpress/components';
import classNames from 'classnames'; import classNames from 'classnames';
import { CommonHooks } from '../../../../data';
import { openSignup } from '../../../ReusableComponents/Icons'; import { openSignup } from '../../../ReusableComponents/Icons';
import { import {
useProductionConnection, useProductionConnection,
@ -14,11 +15,13 @@ const ConnectionButton = ( {
variant = 'primary', variant = 'primary',
showIcon = true, showIcon = true,
} ) => { } ) => {
const { isBusy } = CommonHooks.useBusyState();
const { handleSandboxConnect } = useSandboxConnection(); const { handleSandboxConnect } = useSandboxConnection();
const { handleProductionConnect } = useProductionConnection(); const { handleProductionConnect } = useProductionConnection();
const className = classNames( 'ppcp-r-connection-button', { const className = classNames( 'ppcp-r-connection-button', {
'sandbox-mode': isSandbox, 'sandbox-mode': isSandbox,
'live-mode': ! isSandbox, 'live-mode': ! isSandbox,
'ppcp--is-loading': isBusy,
} ); } );
const handleConnectClick = async () => { const handleConnectClick = async () => {
@ -35,6 +38,7 @@ const ConnectionButton = ( {
variant={ variant } variant={ variant }
icon={ showIcon ? openSignup : null } icon={ showIcon ? openSignup : null }
onClick={ handleConnectClick } onClick={ handleConnectClick }
disabled={ isBusy }
> >
<span className="button-title">{ title }</span> <span className="button-title">{ title }</span>
</Button> </Button>