Skip to content

Commit

Permalink
Fix validation when phoneNumber and State are empty.
Browse files Browse the repository at this point in the history
  • Loading branch information
jorgtz committed Jun 6, 2023
1 parent ce5b48c commit e78812e
Showing 1 changed file with 16 additions and 8 deletions.
24 changes: 16 additions & 8 deletions src/containers/billingInfo/Billing.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -738,18 +738,20 @@ const Billing = forwardRef<SessionHandleType, IBillingProps>(
}
}

if (
isPhoneRequired &&
!isPhoneHidden &&
validatePhoneNumber({
if (isPhoneRequired && !isPhoneHidden) {
const phoneValidation = validatePhoneNumber({
phoneNumber: phone,
customError: texts?.form?.phoneInput?.customError,
countryCode: phoneCountryCode.current,
})
) {

if (isLoading) {
setIsLoading(false)
}
return false

if (phoneValidation) {
return false
}
}

return true
Expand Down Expand Up @@ -1095,8 +1097,14 @@ const Billing = forwardRef<SessionHandleType, IBillingProps>(
isRegistering: !loggedUserFirstName && !storedToken.current,
})

const isExtraDataValid = checkExtraDataValid()
if (isExtraDataValid) {
if (config.isCheckoutAlwaysButtonEnabled) {
if (!checkBasicDataValid()) {
return
}
}

const isExtraDataValidErrors = checkExtraDataValid()
if (isExtraDataValidErrors) {
return
}

Expand Down

0 comments on commit e78812e

Please sign in to comment.