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
2 changes: 1 addition & 1 deletion src/ROUTES.ts
Original file line number Diff line number Diff line change
Expand Up @@ -507,7 +507,7 @@ const ROUTES = {
// Referral program promotion
REFERRAL_DETAILS_MODAL: {
route: 'referral/:contentType',
getRoute: (contentType: string) => `referral/${contentType}` as const,
getRoute: (contentType: string, backTo?: string) => getUrlWithBackToParam(`referral/${contentType}`, backTo),
},
PROCESS_MONEY_REQUEST_HOLD: 'hold-request-educational',
} as const;
Expand Down
2 changes: 1 addition & 1 deletion src/components/ReferralProgramCTA.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ function ReferralProgramCTA({referralContentType, dismissedReferralBanners}: Ref
return (
<PressableWithoutFeedback
onPress={() => {
Navigation.navigate(ROUTES.REFERRAL_DETAILS_MODAL.getRoute(referralContentType));
Navigation.navigate(ROUTES.REFERRAL_DETAILS_MODAL.getRoute(referralContentType, Navigation.getActiveRouteWithoutParams()));
}}
style={[styles.w100, styles.br2, styles.highlightBG, styles.flexRow, styles.justifyContentBetween, styles.alignItemsCenter, {gap: 10, padding: 10}, styles.pl5]}
accessibilityLabel="referral"
Expand Down
1 change: 1 addition & 0 deletions src/libs/Navigation/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -391,6 +391,7 @@ type SignInNavigatorParamList = {
type ReferralDetailsNavigatorParamList = {
[SCREENS.REFERRAL_DETAILS]: {
contentType: ValueOf<typeof CONST.REFERRAL_PROGRAM.CONTENT_TYPES>;
backTo: string;
};
};

Expand Down
10 changes: 10 additions & 0 deletions src/pages/ReferralDetailsPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,12 @@ import useSingleExecution from '@hooks/useSingleExecution';
import useTheme from '@hooks/useTheme';
import useThemeStyles from '@hooks/useThemeStyles';
import Clipboard from '@libs/Clipboard';
import Navigation from '@libs/Navigation/Navigation';
import type {ReferralDetailsNavigatorParamList} from '@libs/Navigation/types';
import * as Link from '@userActions/Link';
import CONST from '@src/CONST';
import ONYXKEYS from '@src/ONYXKEYS';
import type {Route} from '@src/ROUTES';
import SCREENS from '@src/SCREENS';
import type {Account} from '@src/types/onyx';
import * as ReportActionContextMenu from './home/report/ContextMenu/ReportActionContextMenu';
Expand All @@ -36,6 +38,7 @@ function ReferralDetailsPage({route, account}: ReferralDetailsPageProps) {
const popoverAnchor = useRef(null);
const {isExecuting, singleExecution} = useSingleExecution();
let {contentType} = route.params;
const {backTo} = route.params;

if (!Object.values(CONST.REFERRAL_PROGRAM.CONTENT_TYPES).includes(contentType)) {
contentType = CONST.REFERRAL_PROGRAM.CONTENT_TYPES.REFER_FRIEND;
Expand All @@ -60,6 +63,13 @@ function ReferralDetailsPage({route, account}: ReferralDetailsPageProps) {
headerContainerStyles={[styles.staticHeaderImage, styles.justifyContentEnd]}
backgroundColor={theme.PAGE_THEMES[SCREENS.REFERRAL_DETAILS].backgroundColor}
testID={ReferralDetailsPage.displayName}
onBackButtonPress={() => {
if (backTo) {
Navigation.goBack(backTo as Route);
return;
}
Navigation.goBack();
}}
>
<Text style={[styles.textHeadline, styles.mb2, styles.ph5]}>{contentHeader}</Text>
<Text style={[styles.webViewStyles.baseFontStyle, styles.ml0, styles.mb5, styles.ph5]}>{contentBody}</Text>
Expand Down
4 changes: 3 additions & 1 deletion src/pages/ShareCodePage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,9 @@ function ShareCodePage({report}: ShareCodePageProps) {
<MenuItem
title={translate(`referralProgram.${CONST.REFERRAL_PROGRAM.CONTENT_TYPES.SHARE_CODE}.buttonText1`)}
icon={Expensicons.Cash}
onPress={() => Navigation.navigate(ROUTES.REFERRAL_DETAILS_MODAL.getRoute(CONST.REFERRAL_PROGRAM.CONTENT_TYPES.SHARE_CODE))}
onPress={() =>
Navigation.navigate(ROUTES.REFERRAL_DETAILS_MODAL.getRoute(CONST.REFERRAL_PROGRAM.CONTENT_TYPES.SHARE_CODE, Navigation.getActiveRouteWithoutParams()))
}
wrapperStyle={themeStyles.sectionMenuItemTopDescription}
shouldShowRightIcon
/>
Expand Down
Loading