Skip to content

Commit

Permalink
refactor: array.reduce refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
Vrishab Srivatsa committed Mar 20, 2024
1 parent 855e773 commit f781880
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/Utilities/DynamicFieldsUtils.res
Original file line number Diff line number Diff line change
Expand Up @@ -162,9 +162,9 @@ let useRequiredFieldsEmptyAndValid = (
setAreRequiredFieldsValid(_ => areRequiredFieldsValid)

let areRequiredFieldsEmpty =
fieldsArrWithBillingAddress->Js.Array2.reduce((acc, paymentMethodFields) => {
fieldsArrWithBillingAddress->Array.reduce(false, (acc, paymentMethodFields: PaymentMethodsRecord.paymentMethodsFields) => {
acc ||
switch paymentMethodFields {
switch (paymentMethodFields) {
| Email => email.value === ""
| FullName => fullName.value === ""
| Country => country === "" && countryNames->Array.length > 0
Expand Down Expand Up @@ -198,7 +198,7 @@ let useRequiredFieldsEmptyAndValid = (
month === "" || year === "" || cvcNumber === ""
| _ => false
}
}, false)
})
setAreRequiredFieldsEmpty(_ => areRequiredFieldsEmpty)
None
}, (
Expand Down

0 comments on commit f781880

Please sign in to comment.