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

Add basic version of AdvancedFilters Page #45407

Merged
Show file tree
Hide file tree
Changes from 14 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions src/ROUTES.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,21 @@ const ROUTES = {
},
},

SEARCH_ADVANCED_FILTERS: {
route: '/search/filters',
getRoute: () => `search/filters` as const,
},
Kicu marked this conversation as resolved.
Show resolved Hide resolved

SEARCH_ADVANCED_FILTERS_DATE: {
route: '/search/filters/date',
getRoute: () => `search/filters/date` as const,
},

SEARCH_ADVANCED_FILTERS_TYPE: {
route: '/search/filters/type',
getRoute: () => `search/filters/type` as const,
},

SEARCH_REPORT: {
route: '/search/:query/view/:reportID',
getRoute: (query: string, reportID: string) => `search/${query}/view/${reportID}` as const,
Expand Down
4 changes: 4 additions & 0 deletions src/SCREENS.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ const SCREENS = {
SEARCH: {
CENTRAL_PANE: 'Search_Central_Pane',
REPORT_RHP: 'Search_Report_RHP',
ADVANCED_FILTERS_RHP: 'Search_Advanced_Filters_RHP',
ADVANCED_FILTERS_DATE_RHP: 'Search_Advanced_Filters_Date_RHP',
ADVANCED_FILTERS_TYPE_RHP: 'Search_Advanced_Filters_Type_RHP',
TRANSACTION_HOLD_REASON_RHP: 'Search_Transaction_Hold_Reason_RHP',
BOTTOM_TAB: 'Search_Bottom_Tab',
},
Expand Down Expand Up @@ -145,6 +148,7 @@ const SCREENS = {
TRANSACTION_DUPLICATE: 'TransactionDuplicate',
TRAVEL: 'Travel',
SEARCH_REPORT: 'SearchReport',
SEARCH_ADVANCED_FILTERS: 'SearchAdvancedFilters',
SETTINGS_CATEGORIES: 'SettingsCategories',
RESTRICTED_ACTION: 'RestrictedAction',
REPORT_EXPORT: 'Report_Export',
Expand Down
7 changes: 7 additions & 0 deletions src/languages/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3505,6 +3505,13 @@ export default {
unhold: 'Unhold',
noOptionsAvailable: 'No options available for the selected group of expenses.',
},
filtersHeader: 'Filters',
filters: {
date: {
before: 'Before',
after: 'After',
},
},
},
genericErrorPage: {
title: 'Uh-oh, something went wrong!',
Expand Down
7 changes: 7 additions & 0 deletions src/languages/es.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3560,6 +3560,13 @@ export default {
unhold: 'Desbloquear',
noOptionsAvailable: 'No hay opciones disponibles para el grupo de gastos seleccionado.',
},
filtersHeader: 'Filtros',
filters: {
date: {
before: 'Antes',
after: 'Después',
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you verify these translations @luacmartins

Kicu marked this conversation as resolved.
Show resolved Hide resolved
},
},
},
genericErrorPage: {
title: '¡Oh-oh, algo salió mal!',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import type {
ReportSettingsNavigatorParamList,
RoomInviteNavigatorParamList,
RoomMembersNavigatorParamList,
SearchAdvancedFiltersParamList,
SearchReportParamList,
SettingsNavigatorParamList,
SignInNavigatorParamList,
Expand Down Expand Up @@ -495,6 +496,12 @@ const SearchReportModalStackNavigator = createModalStackNavigator<SearchReportPa
[SCREENS.SEARCH.TRANSACTION_HOLD_REASON_RHP]: () => require<ReactComponentModule>('../../../../pages/Search/SearchHoldReasonPage').default,
});

const SearchAdvancedFiltersModalStackNavigator = createModalStackNavigator<SearchAdvancedFiltersParamList>({
[SCREENS.SEARCH.ADVANCED_FILTERS_RHP]: () => require<ReactComponentModule>('../../../../pages/Search/SearchAdvancedFiltersPage').default,
[SCREENS.SEARCH.ADVANCED_FILTERS_DATE_RHP]: () => require<ReactComponentModule>('../../../../pages/Search/SearchFiltersDatePage').default,
[SCREENS.SEARCH.ADVANCED_FILTERS_TYPE_RHP]: () => require<ReactComponentModule>('../../../../pages/Search/SearchFiltersTypePage').default,
});

const RestrictedActionModalStackNavigator = createModalStackNavigator<SearchReportParamList>({
[SCREENS.RESTRICTED_ACTION_ROOT]: () => require<ReactComponentModule>('../../../../pages/RestrictedAction/Workspace/WorkspaceRestrictedActionPage').default,
});
Expand Down Expand Up @@ -529,4 +536,5 @@ export {
TransactionDuplicateStackNavigator,
SearchReportModalStackNavigator,
RestrictedActionModalStackNavigator,
SearchAdvancedFiltersModalStackNavigator,
};
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,10 @@ function RightModalNavigator({navigation}: RightModalNavigatorProps) {
name={SCREENS.RIGHT_MODAL.RESTRICTED_ACTION}
component={ModalStackNavigators.RestrictedActionModalStackNavigator}
/>
<Stack.Screen
name={SCREENS.RIGHT_MODAL.SEARCH_ADVANCED_FILTERS}
component={ModalStackNavigators.SearchAdvancedFiltersModalStackNavigator}
/>
</Stack.Navigator>
</View>
</NoDropZone>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ const CENTRAL_PANE_TO_RHP_MAPPING: Partial<Record<CentralPaneName, string[]>> =
[SCREENS.SETTINGS.ABOUT]: [SCREENS.SETTINGS.APP_DOWNLOAD_LINKS],
[SCREENS.SETTINGS.SAVE_THE_WORLD]: [SCREENS.I_KNOW_A_TEACHER, SCREENS.INTRO_SCHOOL_PRINCIPAL, SCREENS.I_AM_A_TEACHER],
[SCREENS.SETTINGS.TROUBLESHOOT]: [SCREENS.SETTINGS.CONSOLE],
[SCREENS.SEARCH.CENTRAL_PANE]: [SCREENS.SEARCH.REPORT_RHP, SCREENS.SEARCH.TRANSACTION_HOLD_REASON_RHP],
[SCREENS.SEARCH.CENTRAL_PANE]: [SCREENS.SEARCH.REPORT_RHP, SCREENS.SEARCH.TRANSACTION_HOLD_REASON_RHP, SCREENS.SEARCH.ADVANCED_FILTERS_RHP],
[SCREENS.SETTINGS.SUBSCRIPTION.ROOT]: [
SCREENS.SETTINGS.SUBSCRIPTION.ADD_PAYMENT_CARD,
SCREENS.SETTINGS.SUBSCRIPTION.SIZE,
Expand Down
7 changes: 7 additions & 0 deletions src/libs/Navigation/linkingConfig/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -962,6 +962,13 @@ const config: LinkingOptions<RootStackParamList>['config'] = {
[SCREENS.SEARCH.TRANSACTION_HOLD_REASON_RHP]: ROUTES.TRANSACTION_HOLD_REASON_RHP.route,
},
},
[SCREENS.RIGHT_MODAL.SEARCH_ADVANCED_FILTERS]: {
screens: {
[SCREENS.SEARCH.ADVANCED_FILTERS_RHP]: ROUTES.SEARCH_ADVANCED_FILTERS.route,
[SCREENS.SEARCH.ADVANCED_FILTERS_DATE_RHP]: ROUTES.SEARCH_ADVANCED_FILTERS_DATE.route,
[SCREENS.SEARCH.ADVANCED_FILTERS_TYPE_RHP]: ROUTES.SEARCH_ADVANCED_FILTERS_TYPE.route,
},
},
[SCREENS.RIGHT_MODAL.RESTRICTED_ACTION]: {
screens: {
[SCREENS.RESTRICTED_ACTION_ROOT]: ROUTES.RESTRICTED_ACTION.route,
Expand Down
6 changes: 6 additions & 0 deletions src/libs/Navigation/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1059,6 +1059,7 @@ type RightModalNavigatorParamList = {
[SCREENS.RIGHT_MODAL.TRAVEL]: NavigatorScreenParams<TravelNavigatorParamList>;
[SCREENS.RIGHT_MODAL.SEARCH_REPORT]: NavigatorScreenParams<SearchReportParamList>;
[SCREENS.RIGHT_MODAL.RESTRICTED_ACTION]: NavigatorScreenParams<RestrictedActionParamList>;
[SCREENS.RIGHT_MODAL.SEARCH_ADVANCED_FILTERS]: NavigatorScreenParams<never>;
Kicu marked this conversation as resolved.
Show resolved Hide resolved
};

type TravelNavigatorParamList = {
Expand Down Expand Up @@ -1250,6 +1251,10 @@ type SearchReportParamList = {
};
};

type SearchAdvancedFiltersParamList = {
[SCREENS.SEARCH.ADVANCED_FILTERS_RHP]: Record<string, never>;
};

type RestrictedActionParamList = {
[SCREENS.RESTRICTED_ACTION_ROOT]: {
policyID: string;
Expand Down Expand Up @@ -1328,5 +1333,6 @@ export type {
WelcomeVideoModalNavigatorParamList,
TransactionDuplicateNavigatorParamList,
SearchReportParamList,
SearchAdvancedFiltersParamList,
RestrictedActionParamList,
};
53 changes: 53 additions & 0 deletions src/pages/Search/AdvancedSearchFilters.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
import React from 'react';
import {View} from 'react-native';
import MenuItemWithTopDescription from '@components/MenuItemWithTopDescription';
import useLocalize from '@hooks/useLocalize';
import useSingleExecution from '@hooks/useSingleExecution';
import Navigation from '@libs/Navigation/Navigation';
import type {Route} from '@src/ROUTES';

const advancedFilters = [
{
fieldName: 'type',
description: 'common.type' as const,
route: '/search/filters/type' as Route,
Kicu marked this conversation as resolved.
Show resolved Hide resolved
luacmartins marked this conversation as resolved.
Show resolved Hide resolved
},
{
fieldName: 'date',
description: 'common.date' as const,
route: '/search/filters/date' as Route,
},
];

function getFilterDisplayTitle(filters: Record<string, string>, fieldName: string) {
// This is temporary because the full parsing of search query is not yet done
// The actual value will be `filters[fieldName].value` to be updated later
Kicu marked this conversation as resolved.
Show resolved Hide resolved
return fieldName;
}

function AdvancedSearchFilters() {
const {singleExecution} = useSingleExecution();
const {translate} = useLocalize();

return (
<View>
{advancedFilters.map((item) => {
const filterValue = getFilterDisplayTitle({}, item.fieldName);
luacmartins marked this conversation as resolved.
Show resolved Hide resolved
const onPress = singleExecution(() => Navigation.navigate(item.route));
Kicu marked this conversation as resolved.
Show resolved Hide resolved

return (
<MenuItemWithTopDescription
Kicu marked this conversation as resolved.
Show resolved Hide resolved
title={filterValue}
description={translate(item.description)}
shouldShowRightIcon
onPress={onPress}
/>
);
})}
</View>
);
}

AdvancedSearchFilters.displayName = 'AdvancedSearchFilters';

export default AdvancedSearchFilters;
29 changes: 29 additions & 0 deletions src/pages/Search/SearchAdvancedFiltersPage.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import React from 'react';
import FullPageNotFoundView from '@components/BlockingViews/FullPageNotFoundView';
import HeaderWithBackButton from '@components/HeaderWithBackButton';
import ScreenWrapper from '@components/ScreenWrapper';
import useLocalize from '@hooks/useLocalize';
import useThemeStyles from '@hooks/useThemeStyles';
import AdvancedSearchFilters from './AdvancedSearchFilters';

function SearchAdvancedFiltersPage() {
luacmartins marked this conversation as resolved.
Show resolved Hide resolved
const styles = useThemeStyles();
const {translate} = useLocalize();

return (
<ScreenWrapper
testID={SearchAdvancedFiltersPage.displayName}
shouldShowOfflineIndicatorInWideScreen
offlineIndicatorStyle={styles.mtAuto}
>
<FullPageNotFoundView shouldShow={false}>
<HeaderWithBackButton title={translate('search.filtersHeader')} />
<AdvancedSearchFilters />
</FullPageNotFoundView>
</ScreenWrapper>
);
}

SearchAdvancedFiltersPage.displayName = 'SearchAdvancedFiltersPage';

export default SearchAdvancedFiltersPage;
1 change: 1 addition & 0 deletions src/pages/Search/SearchFilters.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ type SearchMenuFilterItem = {
route: Route;
};

// Because we will add have AdvancedFilters, in future rename this component to `SearchTypeMenu|Tabs|Filters` to avoid confusion
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// Because we will add have AdvancedFilters, in future rename this component to `SearchTypeMenu|Tabs|Filters` to avoid confusion
// TODO: Because we will add AdvancedFilters component, in future rename this component to `SearchTypeMenu|Tabs|Filters` to avoid confusion

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can already rename this to SearchStatusBar

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry but this can't be SearchStatusBar because this is the component that is currently (and for now still will be) displayed in LHN. So this is not the moment to rename it or it will confuse developers.

We should rename it I think when we are actually removing it from LHN - which this PR is not doing.
CC @adamgrzybowski @WojtekBoman

function SearchFilters({query}: SearchFiltersProps) {
const styles = useThemeStyles();
const {isSmallScreenWidth} = useWindowDimensions();
Expand Down
32 changes: 32 additions & 0 deletions src/pages/Search/SearchFiltersDatePage.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import React from 'react';
import {View} from 'react-native';
import FullPageNotFoundView from '@components/BlockingViews/FullPageNotFoundView';
import HeaderWithBackButton from '@components/HeaderWithBackButton';
import ScreenWrapper from '@components/ScreenWrapper';
import useLocalize from '@hooks/useLocalize';
import useThemeStyles from '@hooks/useThemeStyles';
import Text from '@src/components/Text';

function SearchFiltersDatePage() {
const styles = useThemeStyles();
const {translate} = useLocalize();

return (
<ScreenWrapper
testID={SearchFiltersDatePage.displayName}
shouldShowOfflineIndicatorInWideScreen
offlineIndicatorStyle={styles.mtAuto}
>
<FullPageNotFoundView shouldShow={false}>
<HeaderWithBackButton title={translate('common.date')} />
<View style={[styles.flex1, styles.ph3]}>
<Text>Advanced filters Date form</Text>
Kicu marked this conversation as resolved.
Show resolved Hide resolved
</View>
</FullPageNotFoundView>
</ScreenWrapper>
);
}

SearchFiltersDatePage.displayName = 'SearchFiltersDatePage';

export default SearchFiltersDatePage;
32 changes: 32 additions & 0 deletions src/pages/Search/SearchFiltersTypePage.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import React from 'react';
import {View} from 'react-native';
import FullPageNotFoundView from '@components/BlockingViews/FullPageNotFoundView';
import HeaderWithBackButton from '@components/HeaderWithBackButton';
import ScreenWrapper from '@components/ScreenWrapper';
import useLocalize from '@hooks/useLocalize';
import useThemeStyles from '@hooks/useThemeStyles';
import Text from '@src/components/Text';

function SearchFiltersTypePage() {
const styles = useThemeStyles();
const {translate} = useLocalize();

return (
<ScreenWrapper
testID={SearchFiltersTypePage.displayName}
shouldShowOfflineIndicatorInWideScreen
offlineIndicatorStyle={styles.mtAuto}
>
<FullPageNotFoundView shouldShow={false}>
<HeaderWithBackButton title={translate('common.type')} />
<View style={[styles.flex1, styles.ph3]}>
<Text>Advanced filters Type form</Text>
Kicu marked this conversation as resolved.
Show resolved Hide resolved
</View>
</FullPageNotFoundView>
</ScreenWrapper>
);
}

SearchFiltersTypePage.displayName = 'SearchFiltersTypePage';

export default SearchFiltersTypePage;
Loading