forked from Expensify/App
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSearchPageBottomTab.tsx
51 lines (45 loc) · 1.99 KB
/
SearchPageBottomTab.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
import React from 'react';
import FullPageNotFoundView from '@components/BlockingViews/FullPageNotFoundView';
import ScreenWrapper from '@components/ScreenWrapper';
import Search from '@components/Search';
import useActiveRoute from '@hooks/useActiveRoute';
import useLocalize from '@hooks/useLocalize';
import useThemeStyles from '@hooks/useThemeStyles';
import useWindowDimensions from '@hooks/useWindowDimensions';
import Navigation from '@libs/Navigation/Navigation';
import TopBar from '@navigation/AppNavigator/createCustomBottomTabNavigator/TopBar';
import CONST from '@src/CONST';
import ROUTES from '@src/ROUTES';
import type {SearchQuery} from '@src/types/onyx/SearchResults';
import SearchFilters from './SearchFilters';
function SearchPageBottomTab() {
const {translate} = useLocalize();
const {isSmallScreenWidth} = useWindowDimensions();
const activeRoute = useActiveRoute();
const styles = useThemeStyles();
const currentQuery = activeRoute?.params && 'query' in activeRoute.params ? activeRoute?.params?.query : '';
const query = currentQuery as SearchQuery;
const isValidQuery = Object.values(CONST.TAB_SEARCH).includes(query);
const handleOnBackButtonPress = () => Navigation.goBack(ROUTES.SEARCH.getRoute(CONST.TAB_SEARCH.ALL));
return (
<ScreenWrapper
testID={SearchPageBottomTab.displayName}
style={styles.pv0}
>
<FullPageNotFoundView
shouldShow={!isValidQuery}
onBackButtonPress={handleOnBackButtonPress}
shouldShowLink={false}
>
<TopBar
breadcrumbLabel={translate('common.search')}
shouldDisplaySearch={false}
/>
<SearchFilters query={query} />
{isSmallScreenWidth && <Search query={query} />}
</FullPageNotFoundView>
</ScreenWrapper>
);
}
SearchPageBottomTab.displayName = 'SearchPageBottomTab';
export default SearchPageBottomTab;