Skip to content

Commit

Permalink
Merge pull request #31658 from Expensify/cmartins-fixReferralBackRoute
Browse files Browse the repository at this point in the history
  • Loading branch information
francoisl authored Nov 21, 2023
2 parents da549c0 + ab1f2a9 commit 228ea33
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions src/pages/ReferralDetailsPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import Navigation from '@libs/Navigation/Navigation';
import styles from '@styles/styles';
import CONST from '@src/CONST';
import ONYXKEYS from '@src/ONYXKEYS';
import ROUTES from '@src/ROUTES';

const propTypes = {
/** Navigation route context info provided by react navigation */
Expand Down Expand Up @@ -52,6 +53,17 @@ function ReferralDetailsPage({route, account}) {
return `${CONST.REFERRAL_PROGRAM.LINK}/?thanks=${encodeURIComponent(email)}`;
}

function getFallbackRoute() {
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),
[CONST.REFERRAL_PROGRAM.CONTENT_TYPES.START_CHAT]: ROUTES.NEW_CHAT,
[CONST.REFERRAL_PROGRAM.CONTENT_TYPES.REFER_FRIEND]: ROUTES.SEARCH,
};

return fallbackRoutes[contentType];
}

return (
<ScreenWrapper
includeSafeAreaPaddingBottom={false}
Expand All @@ -60,7 +72,7 @@ function ReferralDetailsPage({route, account}) {
>
<HeaderWithBackButton
title={translate('common.referral')}
onBackButtonPress={() => Navigation.goBack()}
onBackButtonPress={() => Navigation.goBack(getFallbackRoute())}
/>
<View style={[styles.justifyContentCenter, styles.alignItemsCenter, styles.ph5, styles.flex1]}>
<Icon
Expand All @@ -86,7 +98,7 @@ function ReferralDetailsPage({route, account}) {
success
style={[styles.w100]}
text={translate('common.buttonConfirm')}
onPress={() => Navigation.goBack()}
onPress={() => Navigation.goBack(getFallbackRoute())}
pressOnEnter
enterKeyEventListenerPriority={1}
/>
Expand Down

0 comments on commit 228ea33

Please sign in to comment.