Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions content/modals/GB/short_term_xo.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
"useV5Design": "true",
"apr": "{apr}",
"preapproved": "false",
"showPreapprovedBadge": "false",
"variables": {
"transaction_amount": "${eval(transaction_amount ? transaction_amount : '-')}",
"qualifying_offer": "${eval(CREDIT_OFFERS_DS.qualifying_offer ? CREDIT_OFFERS_DS.qualifying_offer : 'false')}",
Expand Down
1 change: 1 addition & 0 deletions content/modals/US/v2_short_term_xo.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
"apr": "{apr}",
"useV5Design": "true",
"preapproved": "false",
"showPreapprovedBadge": "false",
"variables": {
"transaction_amount": "${eval(transaction_amount ? transaction_amount : '-')}",
"qualifying_offer": "${eval(CREDIT_OFFERS_DS.qualifying_offer ? CREDIT_OFFERS_DS.qualifying_offer : 'false')}",
Expand Down
2 changes: 2 additions & 0 deletions src/components/modal/v2/parts/BodyContent.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ const BodyContent = () => {
document.documentElement.className = `${documentClassName} v5Design`;
}
const isPreapproved = productMeta?.preapproved;
const shouldShowPreapprovedBadge = productMeta?.showPreapprovedBadge;
const preapprovalHeadline = content?.preapproval?.preapprovalHeadline;
const preapprovalSubHeadline = content?.preapproval?.preapprovalSubHeadline;
const preapprovalLabel = content?.preapproval?.preapprovalLabel;
Expand Down Expand Up @@ -154,6 +155,7 @@ const BodyContent = () => {
preapprovalLabel={preapprovalLabel}
// toggles preapproval content
isPreapproved={isPreapproved ?? 'false'}
shouldShowPreapprovedBadge={shouldShowPreapprovedBadge ?? 'false'}
/>
) : (
<Header
Expand Down
17 changes: 10 additions & 7 deletions src/components/modal/v2/parts/CheckoutHeader.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ const CheckoutHeader = ({
preapprovalHeadline,
preapprovalSubHeadline,
preapprovalLabel,
isPreapproved = 'false'
isPreapproved = 'false',
shouldShowPreapprovedBadge = 'false'
}) => {
const { country } = useServerData();
const [, handleClose] = useTransitionState();
Expand All @@ -33,6 +34,9 @@ const CheckoutHeader = ({
// Used to specifically target styles to a specific country
const countryClassName = country?.toLowerCase();

// Only show preapproved badge if user is preapproved AND in the treatment group
const showPreapprovalContent = isPreapproved === 'true' && shouldShowPreapprovedBadge === 'true';

// IMPORTANT: These elements cannot be nested inside of other elements.
// They are using very precise CSS position sticky rules that require this
// specific adjacent DOM structure
Expand Down Expand Up @@ -72,22 +76,22 @@ const CheckoutHeader = ({
// id used for aria-labelleby on modal container element
id="header__headline"
className={
isPreapproved === 'true'
showPreapprovalContent
? `headline-${countryClassName}-preapproved`
: `headline-${countryClassName}`
}
// eslint-disable-next-line react/no-danger
dangerouslySetInnerHTML={{ __html: isPreapproved === 'true' ? preapprovalHeadline : headline }}
dangerouslySetInnerHTML={{ __html: showPreapprovalContent ? preapprovalHeadline : headline }}
/>
{isPreapproved === 'true' ? (
{showPreapprovalContent ? (
<span className={`preapproved-label ${countryClassName}`}>{preapprovalLabel}</span>
) : (
''
)}
</div>
{isQualifying === 'true' && qualifyingSubheadline !== '' ? (
<p className={`subheadline_p subheadline-${countryClassName} qualifying checkout`}>
{isPreapproved === 'true'
{showPreapprovalContent
? preapprovalSubHeadline
: qualifyingSubheadline.replace(/(\s?EUR)/g, ' €')}
</p>
Expand All @@ -96,8 +100,7 @@ const CheckoutHeader = ({
className={`subheadline_p subheadline-${countryClassName} checkout`}
// eslint-disable-next-line react/no-danger
dangerouslySetInnerHTML={{
__html:
currencyFormat(isPreapproved === 'true' ? preapprovalSubHeadline : subheadline) ?? ''
__html: currencyFormat(showPreapprovalContent ? preapprovalSubHeadline : subheadline) ?? ''
}}
/>
)}
Expand Down
6 changes: 4 additions & 2 deletions src/components/modal/v2/parts/views/ShortTerm/Content.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export const ShortTerm = ({
learnMoreLink,
cta
},
productMeta: { qualifying, periodicPayment, useV4Design, useV5Design, preapproved },
productMeta: { qualifying, periodicPayment, useV4Design, useV5Design, preapproved, showPreapprovedBadge },
openProductList,
useNewCheckoutDesign,
use5Dot1Design
Expand All @@ -35,6 +35,8 @@ export const ShortTerm = ({
const isQualifying = qualifying === 'true';

const isPreapproved = preapproved === 'true';
const shouldShowPreapprovedBadge = showPreapprovedBadge === 'true';
const showPreapprovalContent = isPreapproved && shouldShowPreapprovedBadge;

const preapprovalDisclaimerHeadline = preapproval?.preapprovalDisclaimerHeadline;
const preapprovalDisclaimerBody = preapproval?.preapprovalDisclaimerBody;
Expand Down Expand Up @@ -143,7 +145,7 @@ export const ShortTerm = ({
))}
</div>
</div>
{isPreapproved && (
{showPreapprovalContent && (
<PreapprovalDisclaimer
preapprovalDisclaimerBody={preapprovalDisclaimerBody}
preapprovalDisclaimerHeadline={preapprovalDisclaimerHeadline}
Expand Down
Loading