From 4953f7a861ed40ebe2c59b139aa06f9b822f8e67 Mon Sep 17 00:00:00 2001 From: Pritish Budhiraja Date: Mon, 27 May 2024 15:08:20 +0530 Subject: [PATCH] fix: blik code hyphen removal (#401) Co-authored-by: Pritish Budhiraja <1805317@kiit.ac.in> --- src/Payments/PaymentMethodsWrapper.res | 3 +-- src/Utilities/DynamicFieldsUtils.res | 2 +- src/Utilities/Utils.res | 2 ++ 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/Payments/PaymentMethodsWrapper.res b/src/Payments/PaymentMethodsWrapper.res index 63089b91a..38b3bff28 100644 --- a/src/Payments/PaymentMethodsWrapper.res +++ b/src/Payments/PaymentMethodsWrapper.res @@ -33,7 +33,6 @@ let make = (~paymentType: CardThemeType.mode, ~paymentMethodName: string) => { let (country, _) = Recoil.useRecoilState(userCountry) let (selectedBank, _) = Recoil.useRecoilState(userBank) let setFieldComplete = Recoil.useSetRecoilState(fieldsComplete) - let cleanBlik = str => str->String.replaceRegExp(%re("/-/g"), "") let cleanPhoneNumber = str => str->String.replaceRegExp(%re("/\s/g"), "") let (requiredFieldsBody, setRequiredFieldsBody) = React.useState(_ => Dict.make()) @@ -79,7 +78,7 @@ let make = (~paymentType: CardThemeType.mode, ~paymentMethodName: string) => { ~fullName=fullName.value, ~email=email.value, ~bank=bank.hyperSwitch, - ~blikCode=blikCode.value->cleanBlik, + ~blikCode=blikCode.value->removeHyphen, ~phoneNumber=cleanPhoneNumber( phoneNumber.countryCode->Option.getOr("") ++ phoneNumber.value, ), diff --git a/src/Utilities/DynamicFieldsUtils.res b/src/Utilities/DynamicFieldsUtils.res index 8477c2cdb..207f95b2f 100644 --- a/src/Utilities/DynamicFieldsUtils.res +++ b/src/Utilities/DynamicFieldsUtils.res @@ -408,7 +408,7 @@ let useRequiredFieldsBody = ( | AddressCity => city.value | AddressPincode => postalCode.value | AddressState => state.value - | BlikCode => blikCode.value + | BlikCode => blikCode.value->Utils.removeHyphen | PhoneNumber => phone.value | Currency(_) => currency | Country => country diff --git a/src/Utilities/Utils.res b/src/Utilities/Utils.res index 35531437c..96371e03b 100644 --- a/src/Utilities/Utils.res +++ b/src/Utilities/Utils.res @@ -1278,3 +1278,5 @@ let getStateNameFromStateCodeAndCountry = (list: JSON.t, stateCode: string, coun | None => stateCode } } + +let removeHyphen = str => str->String.replaceRegExp(%re("/-/g"), "")