woocommerce/plugins/woocommerce-admin/client/payments/payment-settings-banner.tsx

74 lines
1.8 KiB
TypeScript
Raw Normal View History

2022-04-20 04:28:31 +00:00
/**
* External dependencies
*/
import { Button } from '@wordpress/components';
2022-04-06 16:38:38 +00:00
import { __ } from '@wordpress/i18n';
import { getAdminLink } from '@woocommerce/settings';
import {
WCPayBanner,
WCPayBannerBody,
WCPayBannerFooter,
} from '@woocommerce/onboarding';
import { recordEvent } from '@woocommerce/tracks';
2022-04-20 04:28:31 +00:00
/**
* Internal dependencies
*/
2022-04-06 16:38:38 +00:00
import './payment-recommendations.scss';
import { getAdminSetting } from '~/utils/admin-settings';
import { usePaymentsBanner } from './use-payments-banner';
const recordTrack = () => {
recordEvent( 'settings_payments_banner_connect_click' );
};
2022-04-06 16:38:38 +00:00
const WCPaySettingBanner = () => {
const WC_PAY_SETUP_URL = getAdminLink(
'admin.php?wcpay-connect=1&_wpnonce=' +
getAdminSetting( 'wcpay_welcome_page_connect_nonce' )
);
const isWooPayEligible = getAdminSetting( 'isWooPayEligible' );
2022-04-06 16:38:38 +00:00
return (
<WCPayBanner>
<WCPayBannerBody
textPosition="right"
actionButton={
<Button
href={ WC_PAY_SETUP_URL }
isPrimary
onClick={ recordTrack }
>
{ __( 'Get started', 'woocommerce' ) }
2022-04-06 16:38:38 +00:00
</Button>
}
isWooPayEligible={ isWooPayEligible }
/>
<WCPayBannerFooter isWooPayEligible={ isWooPayEligible } />
</WCPayBanner>
2022-04-06 16:38:38 +00:00
);
};
2022-04-19 08:07:07 +00:00
const DefaultPaymentMethodsHeaderText = () => (
<>
<h2>{ __( 'Payment Methods', 'woocommerce' ) }</h2>
<div id="payment_gateways_options-description">
<p>
{ __(
'Installed payment methods are listed below and can be sorted to control their display order on the frontend.',
'woocommerce'
) }
</p>
</div>
</>
);
2022-04-20 07:29:29 +00:00
export const PaymentsBannerWrapper = () => {
const { hasFinishedResolution, shouldShowBanner } = usePaymentsBanner();
2022-04-19 08:07:07 +00:00
if ( hasFinishedResolution && shouldShowBanner ) {
return <WCPaySettingBanner />;
2022-04-19 08:07:07 +00:00
}
return <DefaultPaymentMethodsHeaderText />;
2022-04-19 08:07:07 +00:00
};