Skip to content

Commit

Permalink
Merge branch 'main' into width-issue
Browse files Browse the repository at this point in the history
  • Loading branch information
PritishBudhiraja authored Jun 3, 2024
2 parents 20eb852 + 1522250 commit 3814700
Show file tree
Hide file tree
Showing 8 changed files with 32 additions and 1,346 deletions.
14 changes: 14 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
## [0.58.2](https://github.com/juspay/hyperswitch-web/compare/v0.58.1...v0.58.2) (2024-06-03)


### Bug Fixes

* remove postal code check ([#412](https://github.com/juspay/hyperswitch-web/issues/412)) ([13b9625](https://github.com/juspay/hyperswitch-web/commit/13b962581e8243d99f070b2fc7e2ab4edc180e49))

## [0.58.1](https://github.com/juspay/hyperswitch-web/compare/v0.58.0...v0.58.1) (2024-06-03)


### Bug Fixes

* 3ds netcetra paymentloader ([#414](https://github.com/juspay/hyperswitch-web/issues/414)) ([3ffe27a](https://github.com/juspay/hyperswitch-web/commit/3ffe27a1ce4ded6888b4c983fc37a4da59042aef))

# [0.58.0](https://github.com/juspay/hyperswitch-web/compare/v0.57.3...v0.58.0) (2024-05-31)


Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "orca-payment-page",
"version": "0.58.0",
"version": "0.58.2",
"main": "index.js",
"private": true,
"dependencies": {
Expand Down
36 changes: 6 additions & 30 deletions src/Components/AddressPaymentInput.res
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ let make = (~paymentType, ~className="") => {
let cityRef = React.useRef(Nullable.null)
let postalRef = React.useRef(Nullable.null)

let (postalCodes, setPostalCodes) = React.useState(_ => [PostalCodeType.defaultPostalCode])
let (stateJson, setStatesJson) = React.useState(_ => None)
let (showOtherFileds, setShowOtherFields) = React.useState(_ => false)

Expand All @@ -68,17 +67,14 @@ let make = (~paymentType, ~className="") => {
let checkPostalValidity = (
postal: RecoilAtomTypes.field,
setPostal: (RecoilAtomTypes.field => RecoilAtomTypes.field) => unit,
regex,
) => {
if RegExp.test(regex->RegExp.fromString, postal.value) && postal.value !== "" && regex !== "" {
if postal.value !== "" {
setPostal(prev => {
...prev,
isValid: Some(true),
errorString: "",
})
} else if (
regex !== "" && !RegExp.test(regex->RegExp.fromString, postal.value) && postal.value !== ""
) {
} else {
setPostal(prev => {
...prev,
isValid: Some(false),
Expand All @@ -89,17 +85,6 @@ let make = (~paymentType, ~className="") => {

React.useEffect0(() => {
open Promise
// Dynamically import/download Postal codes and states JSON
PostalCodeType.importPostalCode("./../PostalCodes.bs.js")
->then(res => {
setPostalCodes(_ => res.default)
resolve()
})
->catch(_ => {
setPostalCodes(_ => [PostalCodeType.defaultPostalCode])
resolve()
})
->ignore
importStates("./../States.json")
->then(res => {
setStatesJson(_ => Some(res.states))
Expand All @@ -114,12 +99,6 @@ let make = (~paymentType, ~className="") => {
None
})

let regex = CardUtils.postalRegex(
postalCodes,
~country={getCountryCode(country.value).isoAlpha2},
(),
)

let onPostalChange = ev => {
let val = ReactEvent.Form.target(ev)["value"]

Expand All @@ -128,20 +107,17 @@ let make = (~paymentType, ~className="") => {
value: val,
errorString: "",
})
if regex !== "" && RegExp.test(regex->RegExp.fromString, val) {
CardUtils.blurRef(postalRef)
}
}

let onPostalBlur = ev => {
let val = ReactEvent.Focus.target(ev)["value"]
if regex !== "" && RegExp.test(regex->RegExp.fromString, val) && val !== "" {
if val !== "" {
setPostalCode(prev => {
...prev,
isValid: Some(true),
errorString: "",
})
} else if regex !== "" && !RegExp.test(regex->RegExp.fromString, val) && val !== "" {
} else {
setPostalCode(prev => {
...prev,
isValid: Some(false),
Expand All @@ -151,9 +127,9 @@ let make = (~paymentType, ~className="") => {
}

React.useEffect(() => {
checkPostalValidity(postalCode, setPostalCode, regex)
checkPostalValidity(postalCode, setPostalCode)
None
}, (regex, country.value))
}, country.value)

React.useEffect(() => {
setState(prev => {
Expand Down
15 changes: 1 addition & 14 deletions src/Components/DynamicFields.res
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ let make = (
"postal_code",
logger,
)
let (postalCodes, setPostalCodes) = React.useState(_ => [PostalCodeType.defaultPostalCode])

let (currency, setCurrency) = Recoil.useLoggedRecoilState(userCurrency, "currency", logger)
let line1Ref = React.useRef(Nullable.null)
let line2Ref = React.useRef(Nullable.null)
Expand Down Expand Up @@ -215,17 +215,6 @@ let make = (

React.useEffect0(() => {
open Promise
// Dynamically import/download Postal codes and states JSON
PostalCodeType.importPostalCode("./../PostalCodes.bs.js")
->then(res => {
setPostalCodes(_ => res.default)
resolve()
})
->catch(_ => {
setPostalCodes(_ => [PostalCodeType.defaultPostalCode])
resolve()
})
->ignore
AddressPaymentInput.importStates("./../States.json")
->then(res => {
setStatesJson(_ => Some(res.states))
Expand All @@ -240,8 +229,6 @@ let make = (
None
})

let _regex = CardUtils.postalRegex(postalCodes, ~country={getCountryCode(country).isoAlpha2}, ())

let onPostalChange = ev => {
let val = ReactEvent.Form.target(ev)["value"]

Expand Down
32 changes: 3 additions & 29 deletions src/Payment.res
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,6 @@ let make = (~paymentMode, ~integrateError, ~logger) => {
cardBrand->getCardType
}, [cardBrand])

let (postalCodes, setPostalCodes) = React.useState(_ => [PostalCodeType.defaultPostalCode])

React.useEffect(() => {
let obj = getobjFromCardPattern(cardBrand)
let cvcLength = obj.maxCVCLenth
Expand All @@ -111,23 +109,6 @@ let make = (~paymentMode, ~integrateError, ~logger) => {
None
}, (cvcNumber, cardNumber))

React.useEffect0(() => {
open Promise
if paymentMode->getPaymentMode == Card {
PostalCodeType.importPostalCode("./PostalCodes.bs.js")
->then(res => {
setPostalCodes(_ => res.default)
resolve()
})
->catch(_ => {
setPostalCodes(_ => [PostalCodeType.defaultPostalCode])
resolve()
})
->ignore
}
None
})

let changeCardNumber = ev => {
let val = ReactEvent.Form.target(ev)["value"]
logInputChangeInfo("cardNumber", logger)
Expand Down Expand Up @@ -175,10 +156,6 @@ let make = (~paymentMode, ~integrateError, ~logger) => {
let changeZipCode = ev => {
let val = ReactEvent.Form.target(ev)["value"]
logInputChangeInfo("zipCode", logger)
let regex = postalRegex(postalCodes, ())
if regex !== "" && RegExp.test(regex->RegExp.fromString, val) {
blurRef(zipRef)
}
setZipCode(_ => val)
}

Expand Down Expand Up @@ -235,13 +212,10 @@ let make = (~paymentMode, ~integrateError, ~logger) => {

let handleZipBlur = ev => {
let zipCode = ReactEvent.Focus.target(ev)["value"]
let regex = postalRegex(postalCodes, ())
if RegExp.test(regex->RegExp.fromString, zipCode) || regex == "" {
setIsZipValid(_ => Some(true))
} else if zipCode->String.length == 0 {
setIsZipValid(_ => None)
} else {
if zipCode === "" {
setIsZipValid(_ => Some(false))
} else {
setIsZipValid(_ => Some(true))
}
}

Expand Down
Loading

0 comments on commit 3814700

Please sign in to comment.