Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 | 2x 2x 2x 2x 2x 2x 2x 2x 2x | import { __ } from '@wordpress/i18n';
import {
getRegistrationErrorCode,
getRegistrationErrorDescription,
} from '../../../helpers/get-connect-screen-error-message';
import useProductCheckoutWorkflow from '../../../hooks/use-product-checkout-workflow';
import useConnection from '../../use-connection';
import ConnectScreenRequiredPlanVisual from './visual';
import type { Props } from './types';
/**
* The Connection Screen Visual component for consumers that require a Plan.
*
* @param {Props} props - The properties.
* @return {import('react').ReactNode} The `ConnectScreenForRequiredPlan` component.
*/
function ConnectScreenRequiredPlan( {
title = __(
'Over 5 million WordPress sites are faster and more secure',
'jetpack-connection-js'
),
autoTrigger = false,
buttonLabel = __( 'Set up Jetpack', 'jetpack-connection-js' ),
apiRoot,
apiNonce,
registrationNonce,
from,
redirectUri,
children,
priceBefore,
priceAfter,
pricingIcon,
pricingTitle,
pricingCurrencyCode = 'USD',
wpcomProductSlug,
siteProductAvailabilityHandler,
logo,
rna = false,
}: Props ) {
const {
handleRegisterSite,
siteIsRegistering,
userIsConnecting,
registrationError,
isOfflineMode,
} = useConnection( {
registrationNonce,
redirectUri,
apiRoot,
apiNonce,
autoTrigger,
from,
} );
const productSlug = wpcomProductSlug ? wpcomProductSlug : '';
const {
run: handleCheckoutWorkflow,
hasCheckoutStarted,
checkoutError,
} = useProductCheckoutWorkflow( {
productSlug,
redirectUrl: redirectUri,
siteProductAvailabilityHandler,
from,
} );
const displayButtonError = Boolean( registrationError || checkoutError );
const buttonIsLoading = siteIsRegistering || userIsConnecting || hasCheckoutStarted;
const handleButtonClick = productSlug ? handleCheckoutWorkflow : handleRegisterSite;
const errorCode = getRegistrationErrorCode( registrationError );
const errorDescription = getRegistrationErrorDescription( registrationError );
return (
<ConnectScreenRequiredPlanVisual
title={ title }
buttonLabel={ buttonLabel }
priceBefore={ priceBefore }
priceAfter={ priceAfter }
pricingIcon={ pricingIcon }
pricingTitle={ pricingTitle }
pricingCurrencyCode={ pricingCurrencyCode }
handleButtonClick={ handleButtonClick }
displayButtonError={ displayButtonError }
errorCode={ errorCode }
errorDescription={ errorDescription }
buttonIsLoading={ buttonIsLoading }
logo={ logo }
isOfflineMode={ isOfflineMode }
rna={ rna }
>
{ children }
</ConnectScreenRequiredPlanVisual>
);
}
export default ConnectScreenRequiredPlan;
|