Skip to content

Commit

Permalink
fix: comments addressed
Browse files Browse the repository at this point in the history
  • Loading branch information
PritishBudhiraja committed Jun 14, 2024
1 parent d3e7896 commit d9c4234
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions src/PaymentElement.res
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,17 @@ let make = (~cardProps, ~expiryProps, ~cvcProps, ~paymentType: CardThemeType.mod
let defaultPaymentMethod =
savedPaymentMethods->Array.find(savedCard => savedCard.defaultPaymentMethodSet)

let savedCardsWithoutDefaultPaymentMethod = savedPaymentMethods->Array.filter(savedCard => {
!savedCard.defaultPaymentMethodSet
})
let sortSavedPaymentMethods = arr =>
arr->Array.toSorted((a, b) =>
compareLogic(Date.fromString(a.lastUsedAt), Date.fromString(b.lastUsedAt))
)

let savedCardsWithoutDefaultPaymentMethod =
savedPaymentMethods
->Array.filter(savedCard => {
!savedCard.defaultPaymentMethodSet
})
->sortSavedPaymentMethods

let finalSavedPaymentMethods = if optionAtomValue.displayDefaultSavedPaymentIcon {
switch defaultPaymentMethod {
Expand All @@ -67,9 +75,7 @@ let make = (~cardProps, ~expiryProps, ~cvcProps, ~paymentType: CardThemeType.mod
| None => savedCardsWithoutDefaultPaymentMethod
}
} else {
savedPaymentMethods->Array.toSorted((a, b) =>
compareLogic(Date.fromString(a.lastUsedAt), Date.fromString(b.lastUsedAt))
)
savedPaymentMethods->sortSavedPaymentMethods
}

setSavedMethods(_ => finalSavedPaymentMethods)
Expand Down

0 comments on commit d9c4234

Please sign in to comment.