Skip to content

Commit

Permalink
Merge branch 'fix/payment_data_filled_event' of github.com:juspay/hyp…
Browse files Browse the repository at this point in the history
…erswitch-web into fix/payment_data_filled_event
  • Loading branch information
vsrivatsa-juspay committed Jul 4, 2024
2 parents 1834c46 + 7070155 commit 2c8571e
Show file tree
Hide file tree
Showing 6 changed files with 56 additions and 38 deletions.
14 changes: 14 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
## [0.71.11](https://github.com/juspay/hyperswitch-web/compare/v0.71.10...v0.71.11) (2024-07-02)


### Bug Fixes

* wallets on top for saved cards flow ([#469](https://github.com/juspay/hyperswitch-web/issues/469)) ([eaaccb0](https://github.com/juspay/hyperswitch-web/commit/eaaccb09427904dda4292bf2d692edecd940a76a))

## [0.71.10](https://github.com/juspay/hyperswitch-web/compare/v0.71.9...v0.71.10) (2024-07-02)


### Bug Fixes

* fixed the ui disparity for more payment methods text and use saved payment methods ([#466](https://github.com/juspay/hyperswitch-web/issues/466)) ([c7ca45c](https://github.com/juspay/hyperswitch-web/commit/c7ca45cb1f97aac865e9cfa146fbf92166c1f175))

## [0.71.9](https://github.com/juspay/hyperswitch-web/compare/v0.71.8...v0.71.9) (2024-07-01)


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.71.9",
"version": "0.71.11",
"main": "index.js",
"private": true,
"dependencies": {
Expand Down
3 changes: 1 addition & 2 deletions src/Components/SavedMethods.res
Original file line number Diff line number Diff line change
Expand Up @@ -296,11 +296,10 @@ let make = (
</RenderIf>
<RenderIf condition={!showFields}>
<div
className="Label flex flex-row gap-3 items-end cursor-pointer"
className="Label flex flex-row gap-3 items-end cursor-pointer mt-4"
style={
fontSize: "14px",
float: "left",
marginTop: "14px",
fontWeight: "500",
width: "fit-content",
color: themeObj.colorPrimary,
Expand Down
2 changes: 1 addition & 1 deletion src/PaymentElement.res
Original file line number Diff line number Diff line change
Expand Up @@ -391,7 +391,7 @@ let make = (~cardProps, ~expiryProps, ~cvcProps, ~paymentType: CardThemeType.mod
<RenderIf
condition={displaySavedPaymentMethods && savedMethods->Array.length > 0 && showFields}>
<div
className="Label flex flex-row gap-3 items-end cursor-pointer my-4"
className="Label flex flex-row gap-3 items-end cursor-pointer mt-4"
style={
fontSize: "14px",
float: "left",
Expand Down
69 changes: 37 additions & 32 deletions src/Utilities/PaymentUtils.res
Original file line number Diff line number Diff line change
Expand Up @@ -382,43 +382,48 @@ let sortCustomerMethodsBasedOnPriority = (
priorityArr: array<string>,
~displayDefaultSavedPaymentIcon=true,
) => {
let priorityArr = priorityArr->Array.length > 0 ? priorityArr : PaymentModeType.defaultOrder

let getPaymentMethod = (customerMethod: PaymentType.customerMethods) => {
if customerMethod.paymentMethod === "card" {
customerMethod.paymentMethod
} else {
switch customerMethod.paymentMethodType {
| Some(paymentMethodType) => paymentMethodType
| _ => customerMethod.paymentMethod
if priorityArr->Array.length === 0 {
sortArr
} else {
// * Need to discuss why this is used.
// let priorityArr = priorityArr->Array.length > 0 ? priorityArr : PaymentModeType.defaultOrder
let getPaymentMethod = (customerMethod: PaymentType.customerMethods) => {
if customerMethod.paymentMethod === "card" {
customerMethod.paymentMethod
} else {
switch customerMethod.paymentMethodType {
| Some(paymentMethodType) => paymentMethodType
| _ => customerMethod.paymentMethod
}
}
}
}

let getCustomerMethodPriority = (paymentMethod: string) => {
let priorityArrLength = priorityArr->Array.length
let index = priorityArr->Array.indexOf(paymentMethod)
let getCustomerMethodPriority = (paymentMethod: string) => {
let priorityArrLength = priorityArr->Array.length
let index = priorityArr->Array.indexOf(paymentMethod)

index === -1 ? priorityArrLength : index
}
index === -1 ? priorityArrLength : index
}

let handleCustomerMethodsSort = (
firstCustomerMethod: PaymentType.customerMethods,
secondCustomerMethod: PaymentType.customerMethods,
) => {
let firstPaymentMethod = firstCustomerMethod->getPaymentMethod
let secondPaymentMethod = secondCustomerMethod->getPaymentMethod

if (
displayDefaultSavedPaymentIcon &&
(firstCustomerMethod.defaultPaymentMethodSet || secondCustomerMethod.defaultPaymentMethodSet)
) {
firstCustomerMethod.defaultPaymentMethodSet ? -1 : 1
} else {
firstPaymentMethod->getCustomerMethodPriority - secondPaymentMethod->getCustomerMethodPriority
let handleCustomerMethodsSort = (
firstCustomerMethod: PaymentType.customerMethods,
secondCustomerMethod: PaymentType.customerMethods,
) => {
let firstPaymentMethod = firstCustomerMethod->getPaymentMethod
let secondPaymentMethod = secondCustomerMethod->getPaymentMethod

if (
displayDefaultSavedPaymentIcon &&
(firstCustomerMethod.defaultPaymentMethodSet ||
secondCustomerMethod.defaultPaymentMethodSet)
) {
firstCustomerMethod.defaultPaymentMethodSet ? -1 : 1
} else {
firstPaymentMethod->getCustomerMethodPriority -
secondPaymentMethod->getCustomerMethodPriority
}
}
}

sortArr->Belt.SortArray.stableSortBy(handleCustomerMethodsSort)
sortArr->Belt.SortArray.stableSortBy(handleCustomerMethodsSort)
}
}

0 comments on commit 2c8571e

Please sign in to comment.