From c30558f8d772e54d7bf68aaff89d52dad89e73e9 Mon Sep 17 00:00:00 2001 From: Pritish Budhiraja Date: Thu, 26 Sep 2024 17:35:32 +0530 Subject: [PATCH] feat: customMessageForCardTerms prop added (#705) --- src/Components/SaveDetailsCheckbox.res | 4 +++- src/Components/Terms.res | 26 +++++++++++++------------- src/Types/PaymentType.res | 4 ++++ 3 files changed, 20 insertions(+), 14 deletions(-) diff --git a/src/Components/SaveDetailsCheckbox.res b/src/Components/SaveDetailsCheckbox.res index 838fe86c8..d94ce2d07 100644 --- a/src/Components/SaveDetailsCheckbox.res +++ b/src/Components/SaveDetailsCheckbox.res @@ -2,7 +2,7 @@ let make = (~isChecked, ~setIsChecked) => { let {themeObj} = Recoil.useRecoilValueFromAtom(RecoilAtoms.configAtom) let showFields = Recoil.useRecoilValueFromAtom(RecoilAtoms.showCardFieldsAtom) - let {business} = Recoil.useRecoilValueFromAtom(RecoilAtoms.optionAtom) + let {business, customMessageForCardTerms} = Recoil.useRecoilValueFromAtom(RecoilAtoms.optionAtom) let css = `.container { display: flex; @@ -50,6 +50,8 @@ let make = (~isChecked, ~setIsChecked) => { let saveCardCheckboxLabel = if showFields { localeString.saveCardDetails + } else if customMessageForCardTerms->String.length > 0 { + customMessageForCardTerms } else { localeString.cardTerms(business.name) } diff --git a/src/Components/Terms.res b/src/Components/Terms.res index 524d74bac..44b21ba37 100644 --- a/src/Components/Terms.res +++ b/src/Components/Terms.res @@ -1,18 +1,18 @@ -open PaymentModeType -open PaymentType - @react.component -let make = (~mode) => { - let {localeString, themeObj} = Recoil.useRecoilValueFromAtom(RecoilAtoms.configAtom) - let options = Recoil.useRecoilValueFromAtom(RecoilAtoms.optionAtom) +let make = (~mode: PaymentModeType.payment) => { + open RecoilAtoms + let {localeString, themeObj} = Recoil.useRecoilValueFromAtom(configAtom) + let {customMessageForCardTerms, business, terms} = Recoil.useRecoilValueFromAtom(optionAtom) + let cardTermsValue = + customMessageForCardTerms->String.length > 0 + ? customMessageForCardTerms + : localeString.cardTerms(business.name) + let terms = switch mode { - | ACHBankDebit => ( - localeString.achBankDebitTerms(options.business.name), - options.terms.usBankAccount, - ) - | SepaBankDebit => (localeString.sepaDebitTerms(options.business.name), options.terms.sepaDebit) - | BecsBankDebit => (localeString.becsDebitTerms, options.terms.auBecsDebit) - | Card => (localeString.cardTerms(options.business.name), options.terms.card) + | ACHBankDebit => (localeString.achBankDebitTerms(business.name), terms.usBankAccount) + | SepaBankDebit => (localeString.sepaDebitTerms(business.name), terms.sepaDebit) + | BecsBankDebit => (localeString.becsDebitTerms, terms.auBecsDebit) + | Card => (cardTermsValue, terms.card) | _ => ("", Auto) } let (termsText, showTerm) = terms diff --git a/src/Types/PaymentType.res b/src/Types/PaymentType.res index 5eb0d9065..29c0b522a 100644 --- a/src/Types/PaymentType.res +++ b/src/Types/PaymentType.res @@ -172,6 +172,7 @@ type options = { hideExpiredPaymentMethods: bool, displayDefaultSavedPaymentIcon: bool, hideCardNicknameField: bool, + customMessageForCardTerms: string, } let defaultCardDetails = { scheme: None, @@ -310,6 +311,7 @@ let defaultOptions = { hideExpiredPaymentMethods: false, displayDefaultSavedPaymentIcon: true, hideCardNicknameField: false, + customMessageForCardTerms: "", } let getLayout = (str, logger) => { switch str { @@ -1009,6 +1011,7 @@ let itemToObjMapper = (dict, logger) => { "branding", "displayDefaultSavedPaymentIcon", "hideCardNicknameField", + "customMessageForCardTerms", ], dict, "options", @@ -1053,6 +1056,7 @@ let itemToObjMapper = (dict, logger) => { hideExpiredPaymentMethods: getBool(dict, "hideExpiredPaymentMethods", false), displayDefaultSavedPaymentIcon: getBool(dict, "displayDefaultSavedPaymentIcon", true), hideCardNicknameField: getBool(dict, "hideCardNicknameField", false), + customMessageForCardTerms: getString(dict, "customMessageForCardTerms", ""), } }