-
Notifications
You must be signed in to change notification settings - Fork 108
feat: unified view for saved and more payment methods screen #1194
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from 8 commits
13253ad
656a1b5
958bb4b
94d440a
cdcd4c0
e39c251
32df8c4
9dc62be
1f47f30
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,20 @@ | ||||||||||
| @react.component | ||||||||||
| let make = (~displayMergedSavedMethods, ~dropDownOptionsDetails, ~showMore, ~setShowMore) => { | ||||||||||
| let {themeObj} = Recoil.useRecoilValueFromAtom(RecoilAtoms.configAtom) | ||||||||||
|
|
||||||||||
| <RenderIf condition={displayMergedSavedMethods && dropDownOptionsDetails->Array.length > 0}> | ||||||||||
| <div | ||||||||||
| className="Label flex flex-row gap-1 items-end cursor-pointer mt-3 text-[14px] font-medium float-left w-fit" | ||||||||||
| style={ | ||||||||||
| color: themeObj.colorPrimary, | ||||||||||
| } | ||||||||||
| onClick={_ => { | ||||||||||
| setShowMore(_ => !showMore) | ||||||||||
| }}> | ||||||||||
|
||||||||||
| onClick={_ => { | |
| setShowMore(_ => !showMore) | |
| }}> | |
| onClick={_ => setShowMore(prev => !prev) }> |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -60,6 +60,7 @@ let make = (~cardProps, ~expiryProps, ~cvcProps, ~paymentType: CardThemeType.mod | |
| }, (clickToPayConfig, isClickToPayAuthenticateError)) | ||
|
|
||
| let layoutClass = CardUtils.getLayoutClass(layout) | ||
| let displayMergedSavedMethods = layoutClass.savedMethodsLayout.displayMergedSavedMethods | ||
|
|
||
| let (getVisaCards, closeComponentIfSavedMethodsAreEmpty) = ClickToPayHook.useClickToPay( | ||
| ~areClickToPayUIScriptsLoaded, | ||
|
|
@@ -278,6 +279,9 @@ let make = (~cardProps, ~expiryProps, ~cvcProps, ~paymentType: CardThemeType.mod | |
| }, [selectedOption]) | ||
| useSubmitPaymentData(submitCallback) | ||
| React.useEffect(() => { | ||
| if displayMergedSavedMethods { | ||
| setShowPaymentMethodsScreen(_ => selectedOption != "saved_methods") | ||
| } | ||
| setSelectedOption(prev => | ||
| selectedOption !== "" | ||
| ? prev | ||
|
|
@@ -402,6 +406,19 @@ let make = (~cardProps, ~expiryProps, ~cvcProps, ~paymentType: CardThemeType.mod | |
| </RenderIf> | ||
| }} | ||
| </SessionPaymentWrapper> | ||
| | SavedMethods => | ||
| <SavedMethods | ||
| paymentToken | ||
| setPaymentToken | ||
| savedMethods | ||
| loadSavedCards | ||
| cvcProps | ||
| sessions | ||
| isClickToPayAuthenticateError | ||
| setIsClickToPayAuthenticateError | ||
| getVisaCards | ||
| closeComponentIfSavedMethodsAreEmpty | ||
| /> | ||
| | _ => | ||
| <ReusableReactSuspense loaderComponent={loader()} componentName="PaymentMethodsWrapperLazy"> | ||
| <PaymentMethodsWrapperLazy paymentMethodName=selectedOption /> | ||
|
|
@@ -450,15 +467,18 @@ let make = (~cardProps, ~expiryProps, ~cvcProps, ~paymentType: CardThemeType.mod | |
| </div> | ||
| </RenderIf> | ||
| {if clickToPayConfig.isReady->Option.isNone { | ||
| if areClickToPayUIScriptsLoaded { | ||
| if displayMergedSavedMethods { | ||
| <PaymentElementShimmer /> | ||
| } else if areClickToPayUIScriptsLoaded { | ||
| <ClickToPayHelpers.SrcLoader /> | ||
| } else { | ||
| <PaymentElementShimmer.SavedPaymentCardShimmer /> | ||
| } | ||
| } else { | ||
| <RenderIf | ||
| condition={!showPaymentMethodsScreen && | ||
| (displaySavedPaymentMethods || isShowPaymentMethodsDependingOnClickToPay)}> | ||
| (displaySavedPaymentMethods || isShowPaymentMethodsDependingOnClickToPay) && | ||
| !displayMergedSavedMethods}> | ||
| <SavedMethods | ||
| paymentToken | ||
| setPaymentToken | ||
|
|
@@ -475,7 +495,7 @@ let make = (~cardProps, ~expiryProps, ~cvcProps, ~paymentType: CardThemeType.mod | |
| }} | ||
| <RenderIf | ||
| condition={(paymentOptions->Array.length > 0 || walletOptions->Array.length > 0) && | ||
| showPaymentMethodsScreen && | ||
| (showPaymentMethodsScreen || displayMergedSavedMethods) && | ||
| clickToPayConfig.isReady->Option.isSome}> | ||
| <div | ||
| className="flex flex-col place-items-center" | ||
|
|
@@ -510,7 +530,9 @@ let make = (~cardProps, ~expiryProps, ~cvcProps, ~paymentType: CardThemeType.mod | |
| </RenderIf> | ||
| <RenderIf | ||
| condition={((displaySavedPaymentMethods && savedMethods->Array.length > 0) || | ||
| isShowPaymentMethodsDependingOnClickToPay) && showPaymentMethodsScreen}> | ||
| isShowPaymentMethodsDependingOnClickToPay) && | ||
|
||
| showPaymentMethodsScreen && | ||
| !displayMergedSavedMethods}> | ||
| <div | ||
| className="Label flex flex-row gap-3 items-end cursor-pointer mt-4" | ||
| style={ | ||
|
|
@@ -542,7 +564,8 @@ let make = (~cardProps, ~expiryProps, ~cvcProps, ~paymentType: CardThemeType.mod | |
| </RenderIf> | ||
| | _ => | ||
| <RenderIf | ||
| condition={!displaySavedPaymentMethods && | ||
| condition={(!displaySavedPaymentMethods || | ||
|
||
| (displayMergedSavedMethods && savedMethods->Array.length == 0)) && | ||
| paymentOptions->Array.length == 0 && | ||
| walletOptions->Array.length == 0}> | ||
| <PaymentElementShimmer /> | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Try to simplify this condition for better readability.