Skip to content
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

Go back to correct page in referral page #32329

Merged
merged 15 commits into from
Feb 19, 2024
19 changes: 8 additions & 11 deletions src/pages/ReferralDetailsPage.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import PropTypes from 'prop-types';
import React from 'react';
import React, {useMemo} from 'react';
import {View} from 'react-native';
import {withOnyx} from 'react-native-onyx';
import _ from 'underscore';
Expand Down Expand Up @@ -54,11 +54,7 @@ function ReferralDetailsPage({route, account}) {
const shouldShowBody2 = isShareCode;
const shouldShowClipboard = contentType === CONST.REFERRAL_PROGRAM.CONTENT_TYPES.REFER_FRIEND || isShareCode;

function generateReferralURL(email) {
return `${CONST.REFERRAL_PROGRAM.LINK}/?thanks=${encodeURIComponent(email)}`;
}

function getFallbackRoute() {
const fallBackRoute = useMemo(() => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't need memo optimization here, this is a cheap function

const fallbackRoutes = {
[CONST.REFERRAL_PROGRAM.CONTENT_TYPES.MONEY_REQUEST]: ROUTES.MONEY_REQUEST_PARTICIPANTS.getRoute(CONST.IOU.TYPE.REQUEST),
[CONST.REFERRAL_PROGRAM.CONTENT_TYPES.SEND_MONEY]: ROUTES.MONEY_REQUEST_PARTICIPANTS.getRoute(CONST.IOU.TYPE.SEND),
Expand All @@ -67,6 +63,10 @@ function ReferralDetailsPage({route, account}) {
};

return fallbackRoutes[contentType];
}, [contentType]);

function generateReferralURL(email) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please bring back original order of functions

return `${CONST.REFERRAL_PROGRAM.LINK}/?thanks=${encodeURIComponent(email)}`;
}

return (
Expand All @@ -75,10 +75,7 @@ function ReferralDetailsPage({route, account}) {
shouldEnableMaxHeight
testID={ReferralDetailsPage.displayName}
>
<HeaderWithBackButton
title={translate('common.referral')}
onBackButtonPress={() => Navigation.goBack(getFallbackRoute())}
/>
<HeaderWithBackButton title={translate('common.referral')} />
<View style={[styles.justifyContentCenter, styles.alignItemsCenter, styles.ph5, styles.flex1]}>
<Icon
src={PaymentHands}
Expand Down Expand Up @@ -108,7 +105,7 @@ function ReferralDetailsPage({route, account}) {
success
style={[styles.w100]}
text={translate('common.buttonConfirm')}
onPress={() => Navigation.goBack(getFallbackRoute())}
Copy link
Contributor

@ArekChr ArekChr Dec 1, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why removing fallback routes from here? In the proposal, you said that we need to change only onBackButtonPress in HeaderWithBackButton

we should remove onBackButtonPress props and use the default onBackButtonPress as we did on other page

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. Click on FAB > Request Money > switch to Manual
  2. Enter the amount and click on Next
  3. Click on 'Request money, get $250' to go to the referral page
  4. Reload the page
  5. Click on the 'Got it' Button

Expected Result:
Click on the 'Got it' Button takes you back to the Manual page

Actual Result:
Click on the 'Got it' Button takes you back to the main chat.

issue: #31628

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ArekChr Updated.

onPress={() => Navigation.goBack(fallBackRoute)}
pressOnEnter
enterKeyEventListenerPriority={1}
/>
Expand Down
Loading