Skip to content

Commit

Permalink
refactor so inquiry variations are easier to read +
Browse files Browse the repository at this point in the history
+ rename dispute reason variable for clarity
  • Loading branch information
Rua Haszard committed Sep 25, 2023
1 parent 8e28971 commit fd803e1
Showing 1 changed file with 20 additions and 16 deletions.
36 changes: 20 additions & 16 deletions client/payment-details/dispute-details/dispute-notice.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,26 +25,30 @@ const DisputeNotice: React.FC< DisputeNoticeProps > = ( {
dispute,
isUrgent,
} ) => {
const clientClaim =
const shopperDisputeReason =
reasons[ dispute.reason ]?.claim ??
__(
'The cardholder claims this is an unrecognized charge.',
'woocommerce-payments'
);

const noticeText = isInquiry( dispute )
? /* translators: <a> link to dispute inquiry documentation. %s is the clients claim for the dispute, eg "The cardholder claims this is an unrecognized charge." */
__(
// eslint-disable-next-line max-len
'<strong>%s</strong> You can challenge their claim if you believe it’s invalid. Not responding will result in an automatic loss. <a>Learn more</a>',
'woocommerce-payments'
)
: /* translators: <a> link to dispute documentation. %s is the clients claim for the dispute, eg "The cardholder claims this is an unrecognized charge." */
__(
// eslint-disable-next-line max-len
'<strong>%s</strong> Challenge the dispute if you believe the claim is invalid, or accept to forfeit the funds and pay the dispute fee. Non-response will result in an automatic loss. <a>Learn more about responding to disputes</a>',
'woocommerce-payments'
);
/* translators: <a> link to dispute documentation. %s is the clients claim for the dispute, eg "The cardholder claims this is an unrecognized charge." */
let noticeText = __(
'<strong>%s</strong> Challenge the dispute if you believe the claim is invalid, ' +
'or accept to forfeit the funds and pay the dispute fee. ' +
'Non-response will result in an automatic loss. <a>Learn more about responding to disputes</a>',
'woocommerce-payments'
);
let learnMoreDocsUrl = 'https://woocommerce.com/document/woopayments/fraud-and-disputes/managing-disputes/#section-3';

if ( isInquiry( dispute ) ) {
/* translators: <a> link to dispute inquiry documentation. %s is the clients claim for the dispute, eg "The cardholder claims this is an unrecognized charge." */
noticeText = __(
'<strong>%s</strong> You can challenge their claim if you believe it’s invalid. ' +
'Not responding will result in an automatic loss. <a>Learn more</a>',
'woocommerce-payments'
)
}

return (
<InlineNotice
Expand All @@ -53,13 +57,13 @@ const DisputeNotice: React.FC< DisputeNoticeProps > = ( {
className="dispute-notice"
isDismissible={ false }
>
{ createInterpolateElement( sprintf( noticeText, clientClaim ), {
{ createInterpolateElement( sprintf( noticeText, shopperDisputeReason ), {
a: (
// eslint-disable-next-line jsx-a11y/anchor-has-content
<a
target="_blank"
rel="noopener noreferrer"
href="https://woocommerce.com/document/woopayments/fraud-and-disputes/managing-disputes/#section-3"
href={ learnMoreDocsUrl }
/>
),
strong: <strong />,
Expand Down

0 comments on commit fd803e1

Please sign in to comment.