From 4198ace098b32bfecb810e99db966f62833b2428 Mon Sep 17 00:00:00 2001 From: Praful Koppalkar <126236898+prafulkoppalkar@users.noreply.github.com> Date: Mon, 5 Feb 2024 20:00:20 +0530 Subject: [PATCH] fix: HS-1111: invalid country options (#141) --- src/Payments/PaymentMethodsRecord.res | 6 +++++- src/Utilities/DynamicFieldsUtils.res | 4 ++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/Payments/PaymentMethodsRecord.res b/src/Payments/PaymentMethodsRecord.res index c1a7352d1..9badeadb1 100644 --- a/src/Payments/PaymentMethodsRecord.res +++ b/src/Payments/PaymentMethodsRecord.res @@ -529,7 +529,11 @@ let getPaymentMethodsFieldTypeFromDict = dict => { switch options->Belt.Array.get(0)->Belt.Option.getWithDefault("") { | "" => None | "ALL" => AddressCountry(Country.country->Js.Array2.map(item => item.countryName)) - | _ => AddressCountry(options) + | _ => AddressCountry( + Country.country + ->Js.Array2.filter(item => options->Js.Array2.includes(item.isoAlpha2)) + ->Js.Array2.map(item => item.countryName), + ) } } | _ => None diff --git a/src/Utilities/DynamicFieldsUtils.res b/src/Utilities/DynamicFieldsUtils.res index e6b822ddc..1b9e24f5e 100644 --- a/src/Utilities/DynamicFieldsUtils.res +++ b/src/Utilities/DynamicFieldsUtils.res @@ -547,10 +547,10 @@ let combineCountryAndPostal = arr => { acc->Js.Array2.concat( switch item { | AddressCountry(val) => val - | _ => [""] + | _ => [] }, ) - }, [""]) + }, []) if hasCountryAndPostal { arr->Js.Array2.push(CountryAndPincode(options))->ignore