Skip to content

Commit 66c316d

Browse files
committed
Add new navigator to allow for new SearchMoneyRequestReport screen
1 parent 5c4dc1c commit 66c316d

File tree

18 files changed

+224
-57
lines changed

18 files changed

+224
-57
lines changed

src/NAVIGATORS.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,5 @@ export default {
1414
REPORTS_SPLIT_NAVIGATOR: 'ReportsSplitNavigator',
1515
SETTINGS_SPLIT_NAVIGATOR: 'SettingsSplitNavigator',
1616
WORKSPACE_SPLIT_NAVIGATOR: 'WorkspaceSplitNavigator',
17+
SEARCH_FULLSCREEN_NAVIGATOR: 'SearchFullscreenNavigator',
1718
} as const;

src/ROUTES.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,16 @@ const ROUTES = {
7878
return getUrlWithBackToParam(baseRoute, backTo);
7979
},
8080
},
81+
SEARCH_MONEY_REQUEST_REPORT: {
82+
route: 'search/report/:reportID',
83+
getRoute: ({reportID, backTo}: {reportID: string | undefined; backTo?: string}) => {
84+
if (!reportID) {
85+
Log.warn('Invalid reportID is used to build the SEARCH_MONEY_REQUEST_REPORT route');
86+
}
87+
const baseRoute = `search/view/${reportID}` as const;
88+
return getUrlWithBackToParam(baseRoute, backTo);
89+
},
90+
},
8191
TRANSACTION_HOLD_REASON_RHP: 'search/hold',
8292

8393
// This is a utility route used to go to the user's concierge chat, or the sign-in page if the user's not authenticated

src/SCREENS.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ const SCREENS = {
3737
},
3838
SEARCH: {
3939
ROOT: 'Search_Root',
40+
MONEY_REQUEST_REPORT: 'Search_Money_Request_Report',
4041
REPORT_RHP: 'Search_Report_RHP',
4142
ADVANCED_FILTERS_RHP: 'Search_Advanced_Filters_RHP',
4243
ADVANCED_FILTERS_DATE_RHP: 'Search_Advanced_Filters_Date_RHP',

src/components/Navigation/BottomTabBar/index.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ import {getPreservedSplitNavigatorState} from '@navigation/AppNavigator/createSp
2727
import {isFullScreenName} from '@navigation/helpers/isNavigatorName';
2828
import Navigation from '@navigation/Navigation';
2929
import navigationRef from '@navigation/navigationRef';
30-
import type {AuthScreensParamList, RootNavigatorParamList, State, WorkspaceSplitNavigatorParamList} from '@navigation/types';
30+
import type {RootNavigatorParamList, SearchFullscreenNavigatorParamList, State, WorkspaceSplitNavigatorParamList} from '@navigation/types';
3131
import BottomTabAvatar from '@pages/home/sidebar/BottomTabAvatar';
3232
import BottomTabBarFloatingActionButton from '@pages/home/sidebar/BottomTabBarFloatingActionButton';
3333
import variables from '@styles/variables';
@@ -112,7 +112,7 @@ function BottomTabBar({selectedTab, isTooltipAllowed = false}: BottomTabBarProps
112112
const lastSearchRoute = rootState.routes.findLast((route) => route.name === SCREENS.SEARCH.ROOT);
113113

114114
if (lastSearchRoute) {
115-
const {q, ...rest} = lastSearchRoute.params as AuthScreensParamList[typeof SCREENS.SEARCH.ROOT];
115+
const {q, ...rest} = lastSearchRoute.params as SearchFullscreenNavigatorParamList[typeof SCREENS.SEARCH.ROOT];
116116
const cleanedQuery = handleQueryWithPolicyID(q, activeWorkspaceID);
117117

118118
Navigation.navigate(

src/components/Search/index.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ import {
3535
} from '@libs/SearchUIUtils';
3636
import {isOnHold} from '@libs/TransactionUtils';
3737
import Navigation from '@navigation/Navigation';
38-
import type {AuthScreensParamList} from '@navigation/types';
38+
import type {SearchFullscreenNavigatorParamList} from '@navigation/types';
3939
import EmptySearchView from '@pages/Search/EmptySearchView';
4040
import variables from '@styles/variables';
4141
import CONST from '@src/CONST';
@@ -133,7 +133,7 @@ function Search({queryJSON, onSearchListScroll, isSearchScreenFocused, contentCo
133133
// We need to use isSmallScreenWidth instead of shouldUseNarrowLayout for enabling the selection mode on small screens only
134134
// eslint-disable-next-line rulesdir/prefer-shouldUseNarrowLayout-instead-of-isSmallScreenWidth
135135
const {isSmallScreenWidth, isLargeScreenWidth} = useResponsiveLayout();
136-
const navigation = useNavigation<PlatformStackNavigationProp<AuthScreensParamList>>();
136+
const navigation = useNavigation<PlatformStackNavigationProp<SearchFullscreenNavigatorParamList>>();
137137
const isFocused = useIsFocused();
138138
const [lastNonEmptySearchResults, setLastNonEmptySearchResults] = useState<SearchResults | undefined>(undefined);
139139
const {

src/libs/Navigation/AppNavigator/AuthScreens.tsx

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ import NetworkConnection from '@libs/NetworkConnection';
3333
import onyxSubscribe from '@libs/onyxSubscribe';
3434
import Pusher from '@libs/Pusher';
3535
import PusherConnectionManager from '@libs/PusherConnectionManager';
36-
import * as SearchQueryUtils from '@libs/SearchQueryUtils';
3736
import * as SessionUtils from '@libs/SessionUtils';
3837
import ConnectionCompletePage from '@pages/ConnectionCompletePage';
3938
import NotFoundPage from '@pages/ErrorPage/NotFoundPage';
@@ -96,7 +95,7 @@ const loadWorkspaceJoinUser = () => require<ReactComponentModule>('@pages/worksp
9695
const loadReportSplitNavigator = () => require<ReactComponentModule>('./Navigators/ReportsSplitNavigator').default;
9796
const loadSettingsSplitNavigator = () => require<ReactComponentModule>('./Navigators/SettingsSplitNavigator').default;
9897
const loadWorkspaceSplitNavigator = () => require<ReactComponentModule>('./Navigators/WorkspaceSplitNavigator').default;
99-
const loadSearchPage = () => require<ReactComponentModule>('@pages/Search/SearchPage').default;
98+
const loadSearchNavigator = () => require<ReactComponentModule>('./Navigators/SearchNavigator').default;
10099

101100
function initializePusher() {
102101
return Pusher.init({
@@ -466,10 +465,9 @@ function AuthScreens({session, lastOpenedPublicRoomID, initialLastUpdateIDApplie
466465
getComponent={loadSettingsSplitNavigator}
467466
/>
468467
<RootStack.Screen
469-
name={SCREENS.SEARCH.ROOT}
468+
name={NAVIGATORS.SEARCH_FULLSCREEN_NAVIGATOR}
470469
options={rootNavigatorScreenOptions.fullScreen}
471-
getComponent={loadSearchPage}
472-
initialParams={{q: SearchQueryUtils.buildSearchQueryString()}}
470+
getComponent={loadSearchNavigator}
473471
/>
474472
<RootStack.Screen
475473
name={NAVIGATORS.WORKSPACE_SPLIT_NAVIGATOR}
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
import React from 'react';
2+
import type {SearchFullscreenNavigatorParamList} from '@libs/Navigation/types';
3+
import * as SearchQueryUtils from '@libs/SearchQueryUtils';
4+
import FreezeWrapper from '@navigation/AppNavigator/FreezeWrapper';
5+
import createPlatformStackNavigator from '@navigation/PlatformStackNavigation/createPlatformStackNavigator';
6+
import SCREENS from '@src/SCREENS';
7+
import type ReactComponentModule from '@src/types/utils/ReactComponentModule';
8+
9+
const loadSearchPage = () => require<ReactComponentModule>('@pages/Search/SearchPage').default;
10+
const loadSearchMoneyReportPage = () => require<ReactComponentModule>('@pages/Search/SearchMoneyRequestReportPage').default;
11+
12+
const Stack = createPlatformStackNavigator<SearchFullscreenNavigatorParamList>();
13+
14+
function SearchNavigator() {
15+
return (
16+
<FreezeWrapper>
17+
<Stack.Navigator
18+
screenOptions={{headerShown: false}}
19+
defaultCentralScreen={SCREENS.SEARCH.ROOT}
20+
>
21+
<Stack.Screen
22+
name={SCREENS.SEARCH.ROOT}
23+
getComponent={loadSearchPage}
24+
initialParams={{q: SearchQueryUtils.buildSearchQueryString()}}
25+
/>
26+
<Stack.Screen
27+
name={SCREENS.SEARCH.MONEY_REQUEST_REPORT}
28+
getComponent={loadSearchMoneyReportPage}
29+
/>
30+
</Stack.Navigator>
31+
</FreezeWrapper>
32+
);
33+
}
34+
35+
SearchNavigator.displayName = 'SearchNavigator';
36+
37+
export default SearchNavigator;

src/libs/Navigation/AppNavigator/createSplitNavigator/getInitialSplitNavigatorState.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import type {NavigationState, PartialState} from '@react-navigation/native';
22
import {SIDEBAR_TO_SPLIT} from '@libs/Navigation/linkingConfig/RELATIONS';
3-
import type {NavigationPartialRoute, SplitNavigatorBySidebar, SplitNavigatorParamListType, SplitNavigatorSidebarScreen} from '@libs/Navigation/types';
3+
import type {NavigationPartialRoute, SplitNavigatorBySidebar, SplitNavigatorParamList, SplitNavigatorSidebarScreen} from '@libs/Navigation/types';
44

5-
type ExtractRouteType<T extends SplitNavigatorSidebarScreen> = Extract<keyof SplitNavigatorParamListType[(typeof SIDEBAR_TO_SPLIT)[T]], string>;
5+
type ExtractRouteType<T extends SplitNavigatorSidebarScreen> = Extract<keyof SplitNavigatorParamList[(typeof SIDEBAR_TO_SPLIT)[T]], string>;
66

77
// The function getPathFromState that we are using in some places isn't working correctly without defined index.
88
const getRoutesWithIndex = (routes: NavigationPartialRoute[]): PartialState<NavigationState> => ({routes, index: routes.length - 1});

src/libs/Navigation/helpers/getAdaptedStateFromPath.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ function getMatchingFullScreenRoute(route: NavigationPartialRoute, policyID?: st
7373
const paramsFromRoute = getParamsFromRoute(SCREENS.SEARCH.ROOT);
7474

7575
return {
76-
name: SCREENS.SEARCH.ROOT,
76+
name: NAVIGATORS.SEARCH_FULLSCREEN_NAVIGATOR,
7777
params: paramsFromRoute.length > 0 ? pick(route.params, paramsFromRoute) : undefined,
7878
};
7979
}

src/libs/Navigation/helpers/isNavigatorName.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import {SIDEBAR_TO_SPLIT, SPLIT_TO_SIDEBAR} from '@libs/Navigation/linkingConfig/RELATIONS';
22
import type {FullScreenName, OnboardingFlowName, SplitNavigatorName, SplitNavigatorSidebarScreen} from '@libs/Navigation/types';
3+
import NAVIGATORS from '@src/NAVIGATORS';
34
import SCREENS from '@src/SCREENS';
45

56
const ONBOARDING_SCREENS = [
@@ -12,7 +13,7 @@ const ONBOARDING_SCREENS = [
1213
SCREENS.ONBOARDING.WORKSPACES,
1314
];
1415

15-
const FULL_SCREENS_SET = new Set([...Object.values(SIDEBAR_TO_SPLIT), SCREENS.SEARCH.ROOT]);
16+
const FULL_SCREENS_SET = new Set([...Object.values(SIDEBAR_TO_SPLIT), NAVIGATORS.SEARCH_FULLSCREEN_NAVIGATOR]);
1617
const SIDEBARS_SET = new Set(Object.values(SPLIT_TO_SIDEBAR));
1718
const ONBOARDING_SCREENS_SET = new Set(ONBOARDING_SCREENS);
1819
const SPLIT_NAVIGATORS_SET = new Set(Object.values(SIDEBAR_TO_SPLIT));

0 commit comments

Comments
 (0)