Skip to content

Commit

Permalink
feat: customMessageForCardTerms prop added (#705)
Browse files Browse the repository at this point in the history
  • Loading branch information
PritishBudhiraja authored Sep 26, 2024
1 parent 1e3c9b9 commit c30558f
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 14 deletions.
4 changes: 3 additions & 1 deletion src/Components/SaveDetailsCheckbox.res
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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)
}
Expand Down
26 changes: 13 additions & 13 deletions src/Components/Terms.res
Original file line number Diff line number Diff line change
@@ -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
Expand Down
4 changes: 4 additions & 0 deletions src/Types/PaymentType.res
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,7 @@ type options = {
hideExpiredPaymentMethods: bool,
displayDefaultSavedPaymentIcon: bool,
hideCardNicknameField: bool,
customMessageForCardTerms: string,
}
let defaultCardDetails = {
scheme: None,
Expand Down Expand Up @@ -310,6 +311,7 @@ let defaultOptions = {
hideExpiredPaymentMethods: false,
displayDefaultSavedPaymentIcon: true,
hideCardNicknameField: false,
customMessageForCardTerms: "",
}
let getLayout = (str, logger) => {
switch str {
Expand Down Expand Up @@ -1009,6 +1011,7 @@ let itemToObjMapper = (dict, logger) => {
"branding",
"displayDefaultSavedPaymentIcon",
"hideCardNicknameField",
"customMessageForCardTerms",
],
dict,
"options",
Expand Down Expand Up @@ -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", ""),
}
}

Expand Down

0 comments on commit c30558f

Please sign in to comment.