diff --git a/src/ROUTES.ts b/src/ROUTES.ts index 559c49ff3e2e..d1e7ec285bcc 100644 --- a/src/ROUTES.ts +++ b/src/ROUTES.ts @@ -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; diff --git a/src/components/ReferralProgramCTA.tsx b/src/components/ReferralProgramCTA.tsx index 83bdfd67fef1..6db37ce1320a 100644 --- a/src/components/ReferralProgramCTA.tsx +++ b/src/components/ReferralProgramCTA.tsx @@ -43,7 +43,7 @@ function ReferralProgramCTA({referralContentType, dismissedReferralBanners}: Ref return ( { - 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" diff --git a/src/libs/Navigation/types.ts b/src/libs/Navigation/types.ts index ba59bcf48c05..78f8746ed918 100644 --- a/src/libs/Navigation/types.ts +++ b/src/libs/Navigation/types.ts @@ -391,6 +391,7 @@ type SignInNavigatorParamList = { type ReferralDetailsNavigatorParamList = { [SCREENS.REFERRAL_DETAILS]: { contentType: ValueOf; + backTo: string; }; }; diff --git a/src/pages/ReferralDetailsPage.tsx b/src/pages/ReferralDetailsPage.tsx index f5a5aef14373..d8a27e171933 100644 --- a/src/pages/ReferralDetailsPage.tsx +++ b/src/pages/ReferralDetailsPage.tsx @@ -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'; @@ -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; @@ -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(); + }} > {contentHeader} {contentBody} diff --git a/src/pages/ShareCodePage.tsx b/src/pages/ShareCodePage.tsx index a2db98017dc3..f17b81041236 100644 --- a/src/pages/ShareCodePage.tsx +++ b/src/pages/ShareCodePage.tsx @@ -129,7 +129,9 @@ function ShareCodePage({report}: ShareCodePageProps) { 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 />