From bc992df2d6df409bb192dd8cf7c0c31c03d43ddd Mon Sep 17 00:00:00 2001 From: Pritish Budhiraja <1805317@kiit.ac.in> Date: Fri, 26 Apr 2024 11:53:22 +0530 Subject: [PATCH] fix: country code multiple same code fix --- src/Components/PhoneNumberPaymentInput.res | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/Components/PhoneNumberPaymentInput.res b/src/Components/PhoneNumberPaymentInput.res index 57d213811..6c106b22d 100644 --- a/src/Components/PhoneNumberPaymentInput.res +++ b/src/Components/PhoneNumberPaymentInput.res @@ -30,7 +30,7 @@ let make = () => { let phoneNumberOptionsValue: DropdownField.optionType = { label: `${countryFlag} ${countryName} ${phoneNumberCode}`, displayValue: `${countryFlag} ${phoneNumberCode}`, - value: phoneNumberCode, + value: `${countryFlag}#${phoneNumberCode}`, } acc->Array.push(phoneNumberOptionsValue) acc @@ -51,12 +51,13 @@ let make = () => { ->getString("phone_number_code", "") let (valueDropDown, setValueDropDown) = React.useState(_ => defaultCountryCodeFilteredValue) + let getCountryCodeSplitValue = val => val->String.split("#")->Array.get(1)->Option.getOr("") let changePhone = ev => { let val: string = ReactEvent.Form.target(ev)["value"]->String.replaceRegExp(%re("/\+D+/g"), "") setPhone(prev => { ...prev, - countryCode: valueDropDown, + countryCode: valueDropDown->getCountryCodeSplitValue, value: val, }) } @@ -64,7 +65,7 @@ let make = () => { React.useEffect(() => { setPhone(prev => { ...prev, - countryCode: valueDropDown, + countryCode: valueDropDown->getCountryCodeSplitValue, }) None }, [valueDropDown])