2022-01-12 06:46:33 +00:00
|
|
|
/**
|
|
|
|
* External dependencies
|
|
|
|
*/
|
2024-04-24 18:41:40 +00:00
|
|
|
import { Button } from '@wordpress/components';
|
2023-06-16 14:32:58 +00:00
|
|
|
import { useState } from '@wordpress/element';
|
2024-04-24 18:41:40 +00:00
|
|
|
import { WCPayConnectCard } from '@woocommerce/onboarding';
|
2022-01-12 06:46:33 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Internal dependencies
|
|
|
|
*/
|
2023-06-16 14:32:58 +00:00
|
|
|
import { getAdminSetting } from '~/utils/admin-settings';
|
|
|
|
import sanitizeHTML from '~/lib/sanitize-html';
|
|
|
|
import ExitSurveyModal from './exit-survey-modal';
|
2022-01-12 06:46:33 +00:00
|
|
|
import strings from './strings';
|
|
|
|
|
2023-06-16 14:32:58 +00:00
|
|
|
interface Props {
|
|
|
|
isSubmitted: boolean;
|
|
|
|
handleSetup: () => void;
|
|
|
|
}
|
|
|
|
|
|
|
|
const Banner: React.FC< Props > = ( { isSubmitted, handleSetup } ) => {
|
|
|
|
const { first_name } = getAdminSetting( 'currentUserData', {} );
|
2023-06-19 13:23:33 +00:00
|
|
|
const { description, cta_label, tc_url } = getAdminSetting(
|
2023-06-16 14:32:58 +00:00
|
|
|
'wcpayWelcomePageIncentive'
|
|
|
|
);
|
|
|
|
|
|
|
|
const [ isNoThanksClicked, setNoThanksClicked ] = useState( false );
|
|
|
|
const [ isExitSurveyModalOpen, setExitSurveyModalOpen ] = useState( false );
|
|
|
|
|
2023-08-08 02:17:59 +00:00
|
|
|
const isWooPayEligible = getAdminSetting( 'isWooPayEligible' );
|
2024-04-24 18:41:40 +00:00
|
|
|
const wccomSettings = getAdminSetting( 'wccomHelper', {} );
|
2023-08-08 02:17:59 +00:00
|
|
|
|
2023-06-16 14:32:58 +00:00
|
|
|
const handleNoThanks = () => {
|
|
|
|
setNoThanksClicked( true );
|
|
|
|
setExitSurveyModalOpen( true );
|
|
|
|
};
|
|
|
|
|
2022-01-12 06:46:33 +00:00
|
|
|
return (
|
2024-04-24 18:41:40 +00:00
|
|
|
<>
|
|
|
|
<WCPayConnectCard
|
|
|
|
actionButton={
|
|
|
|
<div className="woopayments-welcome-page__offer">
|
|
|
|
<div className="woopayments-welcome-page__offer-pill">
|
|
|
|
{ strings.limitedTimeOffer }
|
|
|
|
</div>
|
|
|
|
<h2
|
|
|
|
dangerouslySetInnerHTML={ sanitizeHTML(
|
|
|
|
description +
|
|
|
|
'<span class="tos-asterix">*</span>'
|
|
|
|
) }
|
|
|
|
/>
|
|
|
|
<Button
|
|
|
|
variant="primary"
|
|
|
|
isBusy={ isSubmitted }
|
|
|
|
disabled={ isSubmitted }
|
|
|
|
onClick={ handleSetup }
|
|
|
|
>
|
|
|
|
{ cta_label }
|
|
|
|
</Button>
|
|
|
|
<Button
|
|
|
|
variant="tertiary"
|
|
|
|
isBusy={
|
|
|
|
isNoThanksClicked && isExitSurveyModalOpen
|
|
|
|
}
|
|
|
|
disabled={
|
|
|
|
isNoThanksClicked && isExitSurveyModalOpen
|
|
|
|
}
|
|
|
|
onClick={ handleNoThanks }
|
|
|
|
>
|
|
|
|
{ strings.noThanks }
|
|
|
|
</Button>
|
|
|
|
<p>{ strings.TosAndPp }</p>
|
|
|
|
<p>{ strings.termsAndConditions( tc_url ) }</p>
|
|
|
|
</div>
|
|
|
|
}
|
|
|
|
firstName={ first_name }
|
|
|
|
businessCountry={ wccomSettings?.storeCountry ?? '' }
|
|
|
|
isWooPayEligible={ isWooPayEligible }
|
|
|
|
showNotice={ true }
|
|
|
|
/>
|
2023-06-16 14:32:58 +00:00
|
|
|
{ isExitSurveyModalOpen && (
|
|
|
|
<ExitSurveyModal
|
|
|
|
setExitSurveyModalOpen={ setExitSurveyModalOpen }
|
|
|
|
/>
|
|
|
|
) }
|
2024-04-24 18:41:40 +00:00
|
|
|
</>
|
2022-01-12 06:46:33 +00:00
|
|
|
);
|
|
|
|
};
|
|
|
|
|
|
|
|
export default Banner;
|