From 6fb66b91cafb483f4739f739816828fcaa01d455 Mon Sep 17 00:00:00 2001 From: dukenv0307 Date: Fri, 1 Dec 2023 13:13:03 +0700 Subject: [PATCH 1/6] go back to correct page in referral page --- src/pages/ReferralDetailsPage.js | 19 ++----------------- 1 file changed, 2 insertions(+), 17 deletions(-) diff --git a/src/pages/ReferralDetailsPage.js b/src/pages/ReferralDetailsPage.js index 60b5d23b39da..2f773d16a8ff 100644 --- a/src/pages/ReferralDetailsPage.js +++ b/src/pages/ReferralDetailsPage.js @@ -17,7 +17,6 @@ import Navigation from '@libs/Navigation/Navigation'; import useThemeStyles from '@styles/useThemeStyles'; 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 */ @@ -58,27 +57,13 @@ 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(getFallbackRoute())} - /> + Navigation.goBack(getFallbackRoute())} + onPress={() => Navigation.goBack()} pressOnEnter enterKeyEventListenerPriority={1} /> From 1f22bec902d8e96699377a9d10168752e4f8fc61 Mon Sep 17 00:00:00 2001 From: dukenv0307 Date: Mon, 4 Dec 2023 13:46:19 +0700 Subject: [PATCH 2/6] add fallback route for confirm button --- 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 2f773d16a8ff..2b6bc9249bc6 100644 --- a/src/pages/ReferralDetailsPage.js +++ b/src/pages/ReferralDetailsPage.js @@ -1,5 +1,5 @@ import PropTypes from 'prop-types'; -import React from 'react'; +import React, {useMemo} from 'react'; import {View} from 'react-native'; import {withOnyx} from 'react-native-onyx'; import _ from 'underscore'; @@ -17,6 +17,7 @@ import Navigation from '@libs/Navigation/Navigation'; import useThemeStyles from '@styles/useThemeStyles'; 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 */ @@ -53,6 +54,17 @@ function ReferralDetailsPage({route, account}) { const shouldShowBody2 = isShareCode; const shouldShowClipboard = contentType === CONST.REFERRAL_PROGRAM.CONTENT_TYPES.REFER_FRIEND || isShareCode; + const fallBackRoute = useMemo(() => { + 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]; + }, [contentType]); + function generateReferralURL(email) { return `${CONST.REFERRAL_PROGRAM.LINK}/?thanks=${encodeURIComponent(email)}`; } @@ -93,7 +105,7 @@ function ReferralDetailsPage({route, account}) { success style={[styles.w100]} text={translate('common.buttonConfirm')} - onPress={() => Navigation.goBack()} + onPress={() => Navigation.goBack(fallBackRoute)} pressOnEnter enterKeyEventListenerPriority={1} /> From 2c2b068bf13be2ebef31382f42e2c830679c8814 Mon Sep 17 00:00:00 2001 From: dukenv0307 Date: Mon, 25 Dec 2023 16:20:11 +0700 Subject: [PATCH 3/6] refactor referral route --- src/ROUTES.ts | 20 ++++++++++++++++ src/SCREENS.ts | 5 ++++ .../OptionsSelector/BaseOptionsSelector.js | 6 +++-- .../AppNavigator/ModalStackNavigators.tsx | 5 ++++ src/libs/Navigation/linkingConfig.ts | 5 ++++ src/pages/NewChatPage.js | 2 ++ src/pages/ReferralDetailsPage.js | 23 +++++++++++++++++-- src/pages/SearchPage.js | 2 ++ src/pages/ShareCodePage.js | 2 +- ...yForRefactorRequestParticipantsSelector.js | 14 +++++++++++ .../step/IOURequestStepParticipants.js | 2 ++ 11 files changed, 81 insertions(+), 5 deletions(-) diff --git a/src/ROUTES.ts b/src/ROUTES.ts index ca1fe9f0e81a..64de8064ba81 100644 --- a/src/ROUTES.ts +++ b/src/ROUTES.ts @@ -463,6 +463,26 @@ const ROUTES = { route: 'referral/:contentType', getRoute: (contentType: string) => `referral/${contentType}` as const, }, + REFERRAL_DETAILS_MODAL_REQUEST: { + route: 'create/request/participants/:transactionID/:reportID/referral/:contentType', + getRoute: (transactionID: string, reportID: string, contentType: string) => `create/request/participants/${transactionID}/${reportID}/referral/${contentType}` as const, + }, + REFERRAL_DETAILS_MODAL_START_CHAT: { + route: 'new/referral/:contentType', + getRoute: (contentType: string) => `new/referral/${contentType}` as const, + }, + REFERRAL_DETAILS_MODAL_SEND_MONEY: { + route: 'send/new/participants/referral/:contentType', + getRoute: (contentType: string) => `send/new/participants/referral/${contentType}` as const, + }, + REFERRAL_DETAILS_MODAL_REFER_FRIEND: { + route: 'search/referral/:contentType', + getRoute: (contentType: string) => `search/referral/${contentType}` as const, + }, + REFERRAL_DETAILS_MODAL_SHARE_CODE: { + route: 'settings/shareCode/referral/:contentType', + getRoute: (contentType: string) => `settings/shareCode/referral/${contentType}` as const, + }, // These are some one-off routes that will be removed once they're no longer needed (see GH issues for details) SAASTR: 'saastr', diff --git a/src/SCREENS.ts b/src/SCREENS.ts index 2cd263237866..b8282ce2d8b7 100644 --- a/src/SCREENS.ts +++ b/src/SCREENS.ts @@ -235,6 +235,11 @@ const SCREENS = { REIMBURSEMENT_ACCOUNT: 'ReimbursementAccount', GET_ASSISTANCE: 'GetAssistance', REFERRAL_DETAILS: 'Referral_Details', + REFERRAL_DETAILS_MONEY_REQUEST: 'Referral_Details_Money_Request', + REFERRAL_DETAILS_START_CHAT: 'Referral_Details_Start_Chat', + REFERRAL_DETAILS_SEND_MONEY: 'Referral_Details_Send_Money', + REFERRAL_DETAILS_REFER_FRIEND: 'Referral_Details_Refer_Friend', + REFERRAL_DETAILS_SHARE_CODE: 'Referral_Details_Share_Code', KEYBOARD_SHORTCUTS: 'KeyboardShortcuts', } as const; diff --git a/src/components/OptionsSelector/BaseOptionsSelector.js b/src/components/OptionsSelector/BaseOptionsSelector.js index 3c40b3cf1144..725d55cf5925 100755 --- a/src/components/OptionsSelector/BaseOptionsSelector.js +++ b/src/components/OptionsSelector/BaseOptionsSelector.js @@ -24,7 +24,6 @@ import KeyboardShortcut from '@libs/KeyboardShortcut'; import Navigation from '@libs/Navigation/Navigation'; import setSelection from '@libs/setSelection'; import CONST from '@src/CONST'; -import ROUTES from '@src/ROUTES'; import {defaultProps as optionsSelectorDefaultProps, propTypes as optionsSelectorPropTypes} from './optionsSelectorPropTypes'; const propTypes = { @@ -49,6 +48,9 @@ const propTypes = { /** Referral content type */ referralContentType: PropTypes.string, + /** Referral route */ + referralRoute: PropTypes.string, + ...optionsSelectorPropTypes, ...withLocalizePropTypes, ...withThemeStylesPropTypes, @@ -621,7 +623,7 @@ class BaseOptionsSelector extends Component { { - Navigation.navigate(ROUTES.REFERRAL_DETAILS_MODAL.getRoute(this.props.referralContentType)); + Navigation.navigate(this.props.referralRoute); }} style={[ this.props.themeStyles.p5, diff --git a/src/libs/Navigation/AppNavigator/ModalStackNavigators.tsx b/src/libs/Navigation/AppNavigator/ModalStackNavigators.tsx index 256ea6d4eceb..37c751235086 100644 --- a/src/libs/Navigation/AppNavigator/ModalStackNavigators.tsx +++ b/src/libs/Navigation/AppNavigator/ModalStackNavigators.tsx @@ -277,6 +277,11 @@ const SignInModalStackNavigator = createModalStackNavigator({ [SCREENS.REFERRAL_DETAILS]: () => require('../../../pages/ReferralDetailsPage').default as React.ComponentType, + [SCREENS.REFERRAL_DETAILS_MONEY_REQUEST]: () => require('../../../pages/ReferralDetailsPage').default as React.ComponentType, + [SCREENS.REFERRAL_DETAILS_START_CHAT]: () => require('../../../pages/ReferralDetailsPage').default as React.ComponentType, + [SCREENS.REFERRAL_DETAILS_SEND_MONEY]: () => require('../../../pages/ReferralDetailsPage').default as React.ComponentType, + [SCREENS.REFERRAL_DETAILS_REFER_FRIEND]: () => require('../../../pages/ReferralDetailsPage').default as React.ComponentType, + [SCREENS.REFERRAL_DETAILS_SHARE_CODE]: () => require('../../../pages/ReferralDetailsPage').default as React.ComponentType, }); export { diff --git a/src/libs/Navigation/linkingConfig.ts b/src/libs/Navigation/linkingConfig.ts index 0383455a5946..e5979bb78075 100644 --- a/src/libs/Navigation/linkingConfig.ts +++ b/src/libs/Navigation/linkingConfig.ts @@ -487,6 +487,11 @@ const linkingConfig: LinkingOptions = { [SCREENS.RIGHT_MODAL.REFERRAL]: { screens: { [SCREENS.REFERRAL_DETAILS]: ROUTES.REFERRAL_DETAILS_MODAL.route, + [SCREENS.REFERRAL_DETAILS_MONEY_REQUEST]: ROUTES.REFERRAL_DETAILS_MODAL_REQUEST.route, + [SCREENS.REFERRAL_DETAILS_START_CHAT]: ROUTES.REFERRAL_DETAILS_MODAL_START_CHAT.route, + [SCREENS.REFERRAL_DETAILS_SEND_MONEY]: ROUTES.REFERRAL_DETAILS_MODAL_SEND_MONEY.route, + [SCREENS.REFERRAL_DETAILS_REFER_FRIEND]: ROUTES.REFERRAL_DETAILS_MODAL_REFER_FRIEND.route, + [SCREENS.REFERRAL_DETAILS_SHARE_CODE]: ROUTES.REFERRAL_DETAILS_MODAL_SHARE_CODE.route, }, }, }, diff --git a/src/pages/NewChatPage.js b/src/pages/NewChatPage.js index d7abbab6e93f..60f4d7c1334a 100755 --- a/src/pages/NewChatPage.js +++ b/src/pages/NewChatPage.js @@ -22,6 +22,7 @@ import variables from '@styles/variables'; import * as Report from '@userActions/Report'; import CONST from '@src/CONST'; import ONYXKEYS from '@src/ONYXKEYS'; +import ROUTES from '@src/ROUTES'; import personalDetailsPropType from './personalDetailsPropType'; import reportPropTypes from './reportPropTypes'; @@ -253,6 +254,7 @@ function NewChatPage({betas, isGroupChat, personalDetails, reports, translate, i shouldShowConfirmButton shouldShowReferralCTA referralContentType={CONST.REFERRAL_PROGRAM.CONTENT_TYPES.START_CHAT} + referralRoute={ROUTES.REFERRAL_DETAILS_MODAL_START_CHAT.getRoute(CONST.REFERRAL_PROGRAM.CONTENT_TYPES.START_CHAT)} confirmButtonText={selectedOptions.length > 1 ? translate('newChatPage.createGroup') : translate('newChatPage.createChat')} textInputAlert={isOffline ? `${translate('common.youAppearToBeOffline')} ${translate('search.resultsAreLimited')}` : ''} onConfirmSelection={createGroup} diff --git a/src/pages/ReferralDetailsPage.js b/src/pages/ReferralDetailsPage.js index fb02778db72d..49671a59a204 100644 --- a/src/pages/ReferralDetailsPage.js +++ b/src/pages/ReferralDetailsPage.js @@ -1,6 +1,5 @@ import PropTypes from 'prop-types'; -import React, {useMemo, useRef} from 'react'; -import {View} from 'react-native'; +import React, {useRef} from 'react'; import {withOnyx} from 'react-native-onyx'; import _ from 'underscore'; import ContextMenuItem from '@components/ContextMenuItem'; @@ -15,9 +14,11 @@ 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 * as Link from '@userActions/Link'; import CONST from '@src/CONST'; import ONYXKEYS from '@src/ONYXKEYS'; +import ROUTES from '@src/ROUTES'; import SCREENS from '@src/SCREENS'; import * as ReportActionContextMenu from './home/report/ContextMenu/ReportActionContextMenu'; @@ -25,6 +26,10 @@ const propTypes = { /** Navigation route context info provided by react navigation */ route: PropTypes.shape({ params: PropTypes.shape({ + /** The ID of the transaction being configured */ + transactionID: PropTypes.string, + /** The report ID of the IOU */ + reportID: PropTypes.string, /** The type of the content from where CTA was called */ contentType: PropTypes.string, }), @@ -48,6 +53,7 @@ function ReferralDetailsPage({route, account}) { const popoverAnchor = useRef(null); const {isExecuting, singleExecution} = useSingleExecution(); let {contentType} = route.params; + const {transactionID, reportID} = route.params; if (!_.includes(_.values(CONST.REFERRAL_PROGRAM.CONTENT_TYPES), contentType)) { contentType = CONST.REFERRAL_PROGRAM.CONTENT_TYPES.REFER_FRIEND; @@ -59,6 +65,18 @@ function ReferralDetailsPage({route, account}) { const shouldShowClipboard = contentType === CONST.REFERRAL_PROGRAM.CONTENT_TYPES.REFER_FRIEND || isShareCode; const referralLink = `${CONST.REFERRAL_PROGRAM.LINK}/?thanks=${encodeURIComponent(account.primaryLogin)}`; + function getFallbackRoute() { + const fallbackRoutes = { + [CONST.REFERRAL_PROGRAM.CONTENT_TYPES.MONEY_REQUEST]: ROUTES.MONEY_REQUEST_STEP_PARTICIPANTS.getRoute(CONST.IOU.TYPE.REQUEST, transactionID, reportID), + [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, + [CONST.REFERRAL_PROGRAM.CONTENT_TYPES.SHARE_CODE]: ROUTES.SETTINGS_SHARE_CODE, + }; + + return fallbackRoutes[contentType]; + } + return ( Navigation.navigate(getFallbackRoute())} > {contentHeader} {contentBody} diff --git a/src/pages/SearchPage.js b/src/pages/SearchPage.js index 061f43e73de8..da04fe70fba6 100755 --- a/src/pages/SearchPage.js +++ b/src/pages/SearchPage.js @@ -16,6 +16,7 @@ import * as Report from '@userActions/Report'; import Timing from '@userActions/Timing'; import CONST from '@src/CONST'; import ONYXKEYS from '@src/ONYXKEYS'; +import ROUTES from '@src/ROUTES'; import personalDetailsPropType from './personalDetailsPropType'; import reportPropTypes from './reportPropTypes'; @@ -181,6 +182,7 @@ function SearchPage({betas, personalDetails, reports, isSearchingForReports}) { textInputLabel={translate('optionsSelector.nameEmailOrPhoneNumber')} shouldShowReferralCTA referralContentType={CONST.REFERRAL_PROGRAM.CONTENT_TYPES.REFER_FRIEND} + referralRoute={ROUTES.REFERRAL_DETAILS_MODAL_REFER_FRIEND.getRoute(CONST.REFERRAL_PROGRAM.CONTENT_TYPES.REFER_FRIEND)} textInputAlert={isOffline ? `${translate('common.youAppearToBeOffline')} ${translate('search.resultsAreLimited')}` : ''} onLayout={searchRendered} safeAreaPaddingBottomStyle={safeAreaPaddingBottomStyle} diff --git a/src/pages/ShareCodePage.js b/src/pages/ShareCodePage.js index 1f062a42f8bf..65c952016b5a 100644 --- a/src/pages/ShareCodePage.js +++ b/src/pages/ShareCodePage.js @@ -121,7 +121,7 @@ class ShareCodePage extends React.Component { Navigation.navigate(ROUTES.REFERRAL_DETAILS_MODAL.getRoute(CONST.REFERRAL_PROGRAM.CONTENT_TYPES.SHARE_CODE))} + onPress={() => Navigation.navigate(ROUTES.REFERRAL_DETAILS_MODAL_SHARE_CODE.getRoute(CONST.REFERRAL_PROGRAM.CONTENT_TYPES.SHARE_CODE))} /> diff --git a/src/pages/iou/request/MoneyTemporaryForRefactorRequestParticipantsSelector.js b/src/pages/iou/request/MoneyTemporaryForRefactorRequestParticipantsSelector.js index 4db9c4ce3fb7..c8d94d247278 100644 --- a/src/pages/iou/request/MoneyTemporaryForRefactorRequestParticipantsSelector.js +++ b/src/pages/iou/request/MoneyTemporaryForRefactorRequestParticipantsSelector.js @@ -20,6 +20,7 @@ import personalDetailsPropType from '@pages/personalDetailsPropType'; import reportPropTypes from '@pages/reportPropTypes'; import CONST from '@src/CONST'; import ONYXKEYS from '@src/ONYXKEYS'; +import ROUTES from '@src/ROUTES'; const propTypes = { /** Beta features list */ @@ -63,6 +64,12 @@ const propTypes = { /** Whether we are searching for reports in the server */ isSearchingForReports: PropTypes.bool, + /** The report ID of the IOU */ + reportID: PropTypes.string.isRequired, + + /** The ID of the transaction being configured */ + transactionID: PropTypes.string.isRequired, + ...withLocalizePropTypes, }; @@ -89,6 +96,8 @@ function MoneyTemporaryForRefactorRequestParticipantsSelector({ iouType, iouRequestType, isSearchingForReports, + reportID, + transactionID, }) { const styles = useThemeStyles(); const [searchTerm, setSearchTerm] = useState(''); @@ -321,6 +330,11 @@ function MoneyTemporaryForRefactorRequestParticipantsSelector({ shouldShowOptions={isOptionsDataReady} shouldShowReferralCTA referralContentType={iouType === 'send' ? CONST.REFERRAL_PROGRAM.CONTENT_TYPES.SEND_MONEY : CONST.REFERRAL_PROGRAM.CONTENT_TYPES.MONEY_REQUEST} + referralRoute={ + iouType === 'send' + ? ROUTES.REFERRAL_DETAILS_MODAL_SEND_MONEY.getRoute(CONST.REFERRAL_PROGRAM.CONTENT_TYPES.SEND_MONEY) + : ROUTES.REFERRAL_DETAILS_MODAL_REQUEST.getRoute(transactionID, reportID, CONST.REFERRAL_PROGRAM.CONTENT_TYPES.MONEY_REQUEST) + } shouldPreventDefaultFocusOnSelectRow={!Browser.isMobile()} shouldDelayFocus footerContent={isAllowedToSplit && footerContent} diff --git a/src/pages/iou/request/step/IOURequestStepParticipants.js b/src/pages/iou/request/step/IOURequestStepParticipants.js index ec670b828146..4bb676cab7af 100644 --- a/src/pages/iou/request/step/IOURequestStepParticipants.js +++ b/src/pages/iou/request/step/IOURequestStepParticipants.js @@ -95,6 +95,8 @@ function IOURequestStepParticipants({ onParticipantsAdded={addParticipant} onFinish={goToNextStep} iouType={iouType} + reportID={reportID} + transactionID={transactionID} iouRequestType={iouRequestType} /> From a5aa7d0fc748b3d595a5ab80dd4dcd40d72b9004 Mon Sep 17 00:00:00 2001 From: dukenv0307 Date: Tue, 6 Feb 2024 21:56:24 +0700 Subject: [PATCH 4/6] revert change --- src/SCREENS.ts | 5 ----- .../OptionsSelector/BaseOptionsSelector.js | 3 --- .../AppNavigator/ModalStackNavigators.tsx | 5 ----- src/pages/NewChatPage.js | 1 - src/pages/ReferralDetailsPage.tsx | 14 -------------- src/pages/SearchPage.js | 2 -- ...poraryForRefactorRequestParticipantsSelector.js | 1 - 7 files changed, 31 deletions(-) diff --git a/src/SCREENS.ts b/src/SCREENS.ts index 61aa208f0a98..e2f0e9745561 100644 --- a/src/SCREENS.ts +++ b/src/SCREENS.ts @@ -250,11 +250,6 @@ const SCREENS = { REIMBURSEMENT_ACCOUNT: 'ReimbursementAccount', GET_ASSISTANCE: 'GetAssistance', REFERRAL_DETAILS: 'Referral_Details', - REFERRAL_DETAILS_MONEY_REQUEST: 'Referral_Details_Money_Request', - REFERRAL_DETAILS_START_CHAT: 'Referral_Details_Start_Chat', - REFERRAL_DETAILS_SEND_MONEY: 'Referral_Details_Send_Money', - REFERRAL_DETAILS_REFER_FRIEND: 'Referral_Details_Refer_Friend', - REFERRAL_DETAILS_SHARE_CODE: 'Referral_Details_Share_Code', KEYBOARD_SHORTCUTS: 'KeyboardShortcuts', } as const; diff --git a/src/components/OptionsSelector/BaseOptionsSelector.js b/src/components/OptionsSelector/BaseOptionsSelector.js index 5c860c7be178..345680e809f3 100755 --- a/src/components/OptionsSelector/BaseOptionsSelector.js +++ b/src/components/OptionsSelector/BaseOptionsSelector.js @@ -47,9 +47,6 @@ const propTypes = { /** Referral content type */ referralContentType: PropTypes.string, - /** Referral route */ - referralRoute: PropTypes.string, - ...optionsSelectorPropTypes, ...withLocalizePropTypes, ...withThemeStylesPropTypes, diff --git a/src/libs/Navigation/AppNavigator/ModalStackNavigators.tsx b/src/libs/Navigation/AppNavigator/ModalStackNavigators.tsx index 5fdb3b8d846e..110c13fa07bf 100644 --- a/src/libs/Navigation/AppNavigator/ModalStackNavigators.tsx +++ b/src/libs/Navigation/AppNavigator/ModalStackNavigators.tsx @@ -282,11 +282,6 @@ const SignInModalStackNavigator = createModalStackNavigator({ [SCREENS.REFERRAL_DETAILS]: () => require('../../../pages/ReferralDetailsPage').default as React.ComponentType, - [SCREENS.REFERRAL_DETAILS_MONEY_REQUEST]: () => require('../../../pages/ReferralDetailsPage').default as React.ComponentType, - [SCREENS.REFERRAL_DETAILS_START_CHAT]: () => require('../../../pages/ReferralDetailsPage').default as React.ComponentType, - [SCREENS.REFERRAL_DETAILS_SEND_MONEY]: () => require('../../../pages/ReferralDetailsPage').default as React.ComponentType, - [SCREENS.REFERRAL_DETAILS_REFER_FRIEND]: () => require('../../../pages/ReferralDetailsPage').default as React.ComponentType, - [SCREENS.REFERRAL_DETAILS_SHARE_CODE]: () => require('../../../pages/ReferralDetailsPage').default as React.ComponentType, }); const ProcessMoneyRequestHoldStackNavigator = createModalStackNavigator({ diff --git a/src/pages/NewChatPage.js b/src/pages/NewChatPage.js index 420dc487ef71..44131de01fa6 100755 --- a/src/pages/NewChatPage.js +++ b/src/pages/NewChatPage.js @@ -24,7 +24,6 @@ import * as Report from '@userActions/Report'; import * as User from '@userActions/User'; import CONST from '@src/CONST'; import ONYXKEYS from '@src/ONYXKEYS'; -import ROUTES from '@src/ROUTES'; import personalDetailsPropType from './personalDetailsPropType'; import reportPropTypes from './reportPropTypes'; diff --git a/src/pages/ReferralDetailsPage.tsx b/src/pages/ReferralDetailsPage.tsx index 38d7fe7110ee..f5a5aef14373 100644 --- a/src/pages/ReferralDetailsPage.tsx +++ b/src/pages/ReferralDetailsPage.tsx @@ -18,7 +18,6 @@ import type {ReferralDetailsNavigatorParamList} from '@libs/Navigation/types'; import * as Link from '@userActions/Link'; import CONST from '@src/CONST'; import ONYXKEYS from '@src/ONYXKEYS'; -import ROUTES from '@src/ROUTES'; import SCREENS from '@src/SCREENS'; import type {Account} from '@src/types/onyx'; import * as ReportActionContextMenu from './home/report/ContextMenu/ReportActionContextMenu'; @@ -37,7 +36,6 @@ function ReferralDetailsPage({route, account}: ReferralDetailsPageProps) { const popoverAnchor = useRef(null); const {isExecuting, singleExecution} = useSingleExecution(); let {contentType} = route.params; - const {transactionID, reportID} = route.params; if (!Object.values(CONST.REFERRAL_PROGRAM.CONTENT_TYPES).includes(contentType)) { contentType = CONST.REFERRAL_PROGRAM.CONTENT_TYPES.REFER_FRIEND; @@ -49,18 +47,6 @@ function ReferralDetailsPage({route, account}: ReferralDetailsPageProps) { const shouldShowClipboard = contentType === CONST.REFERRAL_PROGRAM.CONTENT_TYPES.REFER_FRIEND || isShareCode; const referralLink = `${CONST.REFERRAL_PROGRAM.LINK}${account?.primaryLogin ? `/?thanks=${account.primaryLogin}` : ''}`; - function getFallbackRoute() { - const fallbackRoutes = { - [CONST.REFERRAL_PROGRAM.CONTENT_TYPES.MONEY_REQUEST]: ROUTES.MONEY_REQUEST_STEP_PARTICIPANTS.getRoute(CONST.IOU.TYPE.REQUEST, transactionID, reportID), - [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, - [CONST.REFERRAL_PROGRAM.CONTENT_TYPES.SHARE_CODE]: ROUTES.SETTINGS_SHARE_CODE, - }; - - return fallbackRoutes[contentType]; - } - return ( Date: Tue, 6 Feb 2024 22:16:31 +0700 Subject: [PATCH 5/6] add new solution --- src/ROUTES.ts | 2 +- src/components/ReferralProgramCTA.tsx | 2 +- src/libs/Navigation/types.ts | 1 + src/pages/ReferralDetailsPage.tsx | 10 ++++++++++ src/pages/ShareCodePage.tsx | 2 +- 5 files changed, 14 insertions(+), 3 deletions(-) diff --git a/src/ROUTES.ts b/src/ROUTES.ts index 016e4267803b..328884b3b4bb 100644 --- a/src/ROUTES.ts +++ b/src/ROUTES.ts @@ -488,7 +488,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 f1c7539cc6b5..d6a07a25e7b9 100644 --- a/src/components/ReferralProgramCTA.tsx +++ b/src/components/ReferralProgramCTA.tsx @@ -30,7 +30,7 @@ function ReferralProgramCTA({referralContentType, onCloseButtonPress = () => {}} 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 48ef69f27768..53cf6a91b700 100644 --- a/src/libs/Navigation/types.ts +++ b/src/libs/Navigation/types.ts @@ -341,6 +341,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 831f0eb8f1d8..5e703b392b04 100644 --- a/src/pages/ShareCodePage.tsx +++ b/src/pages/ShareCodePage.tsx @@ -116,7 +116,7 @@ function ShareCodePage({report, session, currentUserPersonalDetails}: ShareCodeP 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()))} /> From 7e0f064d5f962823577aab20dac9bfba303ff000 Mon Sep 17 00:00:00 2001 From: dukenv0307 Date: Tue, 13 Feb 2024 23:45:54 +0700 Subject: [PATCH 6/6] fix lint --- src/pages/ShareCodePage.tsx | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/pages/ShareCodePage.tsx b/src/pages/ShareCodePage.tsx index fa56338939a4..36bdb2d1e2b6 100644 --- a/src/pages/ShareCodePage.tsx +++ b/src/pages/ShareCodePage.tsx @@ -131,7 +131,9 @@ function ShareCodePage({report, session, currentUserPersonalDetails}: ShareCodeP Navigation.navigate(ROUTES.REFERRAL_DETAILS_MODAL.getRoute(CONST.REFERRAL_PROGRAM.CONTENT_TYPES.SHARE_CODE, Navigation.getActiveRouteWithoutParams()))} + onPress={() => + Navigation.navigate(ROUTES.REFERRAL_DETAILS_MODAL.getRoute(CONST.REFERRAL_PROGRAM.CONTENT_TYPES.SHARE_CODE, Navigation.getActiveRouteWithoutParams())) + } wrapperStyle={themeStyles.sectionMenuItemTopDescription} shouldShowRightIcon />