From b3f5626872c07483b4cad8b0c11a02f944f8b838 Mon Sep 17 00:00:00 2001 From: Carlos Martins Date: Tue, 21 Nov 2023 14:05:39 -0700 Subject: [PATCH 1/2] add fallback routes --- src/pages/ReferralDetailsPage.js | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/src/pages/ReferralDetailsPage.js b/src/pages/ReferralDetailsPage.js index 282e85fe0237..83f7f97e80bf 100644 --- a/src/pages/ReferralDetailsPage.js +++ b/src/pages/ReferralDetailsPage.js @@ -3,6 +3,7 @@ import React from 'react'; import {View} from 'react-native'; import {withOnyx} from 'react-native-onyx'; import _ from 'underscore'; +import ROUTES from '@src/ROUTES'; import Button from '@components/Button'; import CopyTextToClipboard from '@components/CopyTextToClipboard'; import FixedFooter from '@components/FixedFooter'; @@ -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 ( Navigation.goBack()} + onBackButtonPress={() => Navigation.goBack(getFallbackRoute())} /> Navigation.goBack()} + onPress={() => Navigation.goBack(getFallbackRoute())} pressOnEnter enterKeyEventListenerPriority={1} /> From ab1f2a9681fa2885f1cbcf5d5b19d0c6ff15e424 Mon Sep 17 00:00:00 2001 From: Carlos Martins Date: Tue, 21 Nov 2023 14:32:13 -0700 Subject: [PATCH 2/2] fix lint --- src/pages/ReferralDetailsPage.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/pages/ReferralDetailsPage.js b/src/pages/ReferralDetailsPage.js index 83f7f97e80bf..36fc74836d58 100644 --- a/src/pages/ReferralDetailsPage.js +++ b/src/pages/ReferralDetailsPage.js @@ -3,7 +3,6 @@ import React from 'react'; import {View} from 'react-native'; import {withOnyx} from 'react-native-onyx'; import _ from 'underscore'; -import ROUTES from '@src/ROUTES'; import Button from '@components/Button'; import CopyTextToClipboard from '@components/CopyTextToClipboard'; import FixedFooter from '@components/FixedFooter'; @@ -18,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 */ @@ -62,7 +62,7 @@ function ReferralDetailsPage({route, account}) { }; return fallbackRoutes[contentType]; - }; + } return (