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

[CP Stag] Add fallback routes to Referral page #31658

Merged
merged 2 commits into from
Nov 21, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading