-
Notifications
You must be signed in to change notification settings - Fork 105
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
chore: [IOBP-316] Add return to origin page after payment flow completion #5399
Conversation
Codecov ReportAttention:
Additional details and impacted files@@ Coverage Diff @@
## master #5399 +/- ##
==========================================
- Coverage 47.46% 47.44% -0.02%
==========================================
Files 1604 1604
Lines 33600 33613 +13
Branches 8204 8205 +1
==========================================
+ Hits 15948 15949 +1
- Misses 17594 17606 +12
Partials 58 58
Continue to review full report in Codecov by Sentry.
|
@@ -56,6 +60,10 @@ const WalletPaymentOutcomeScreen = () => { | |||
|
|||
const handleClose = () => { | |||
navigation.popToTop(); | |||
if (paymentStartRoute) { | |||
navigation.navigate(paymentStartRoute); |
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.
What if I need to navigate to a sub-route?
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.
You're right, in this way, we cannot handle a sub-route. I changed the implementation and now the action walletPaymentInitState
accepts an object with the root
navigator and screen
param. In this way, it's possible to navigate anywhere after the payment flow closes.
What do you think? 2102d66
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.
I think the best way is to save all the current route info, like we are currently doing in the payment sagas:
const currentRouteName = NavigationService.getCurrentRouteName();
const currentRouteKey = NavigationService.getCurrentRouteKey();
if (currentRouteName !== undefined && currentRouteKey !== undefined) {
yield* put(
paymentInitializeEntrypointRoute({
name: currentRouteName,
key: currentRouteKey
})
);
}
In this way we will be able to save the information on the route directly within the saga and not from the component that starts the payment flow.
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.
I like it, this is way better! Addressed into 832a611
const currentRouteName = NavigationService.getCurrentRouteName(); | ||
const currentRouteKey = NavigationService.getCurrentRouteKey(); | ||
const startRoute = | ||
currentRouteKey && currentRouteName | ||
? { | ||
routeName: currentRouteName, | ||
routeKey: currentRouteKey | ||
} | ||
: undefined; |
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.
What do you think about using fp-ts here?
const currentRouteName = NavigationService.getCurrentRouteName(); | |
const currentRouteKey = NavigationService.getCurrentRouteKey(); | |
const startRoute = | |
currentRouteKey && currentRouteName | |
? { | |
routeName: currentRouteName, | |
routeKey: currentRouteKey | |
} | |
: undefined; | |
const startRoute = pipe( | |
sequenceS(O.Monad)({ | |
routeName: O.fromNullable(NavigationService.getCurrentRouteName()), | |
routeKey: O.fromNullable(NavigationService.getCurrentRouteKey()) | |
}), | |
O.toUndefined | |
); |
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.
That's cool! Addressed into 5ca24f7
if (paymentStartRoute) { | ||
navigation.navigate(paymentStartRoute.routeName as keyof AppParamsList, { | ||
screen: | ||
paymentStartRoute.routeKey as keyof NavigatorScreenParams<AppParamsList>["screen"] |
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.
I believe this type casting is better done inside the store; what do you think?
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.
Yes, maybe it could be more type-safe. Addressed into 5ca24f7
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.
LGTM!
Short description
This PR implements a new feature that allows users to automatically navigate back to their origin page once they have completed (successfully or not) the payment process. This enhancement improves user experience by providing a seamless transition back to their initial context after finishing a transaction.
List of changes proposed in this pull request
walletPaymentInitState
action that expects an optional route name to go back to after the payment is completed/canceled.How to test
Preview
origin-back.mov