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

Search - Add Reset filters button to Advanced Filters page #48243

Merged
Merged
Show file tree
Hide file tree
Changes from all 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
1 change: 1 addition & 0 deletions src/languages/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3761,6 +3761,7 @@ export default {
search: {
resultsAreLimited: 'Search results are limited.',
viewResults: 'View results',
resetFilters: 'Reset filters',
searchResults: {
emptyResults: {
title: 'Nothing to show',
Expand Down
1 change: 1 addition & 0 deletions src/languages/es.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3811,6 +3811,7 @@ export default {
search: {
resultsAreLimited: 'Los resultados de búsqueda están limitados.',
viewResults: 'Ver resultados',
resetFilters: 'Restablecer filtros',
searchResults: {
emptyResults: {
title: 'No hay nada que ver aquí',
Expand Down
14 changes: 13 additions & 1 deletion src/pages/Search/SearchAdvancedFiltersPage.tsx
Original file line number Diff line number Diff line change
@@ -1,22 +1,34 @@
import React from 'react';
import {useOnyx} from 'react-native-onyx';
import HeaderWithBackButton from '@components/HeaderWithBackButton';
import ScreenWrapper from '@components/ScreenWrapper';
import TextLink from '@components/TextLink';
import useLocalize from '@hooks/useLocalize';
import useThemeStyles from '@hooks/useThemeStyles';
import * as SearchActions from '@userActions/Search';
import ONYXKEYS from '@src/ONYXKEYS';
import type {SearchAdvancedFiltersForm} from '@src/types/form';
import AdvancedSearchFilters from './AdvancedSearchFilters';

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

const emptySearchFilters: SearchAdvancedFiltersForm = {} as SearchAdvancedFiltersForm;
const [searchAdvancedFilters = emptySearchFilters] = useOnyx(ONYXKEYS.FORMS.SEARCH_ADVANCED_FILTERS_FORM);

const shouldShowResetFilters = Object.values(searchAdvancedFilters).some((value) => (Array.isArray(value) ? value.length !== 0 : !!value));

return (
<ScreenWrapper
testID={SearchAdvancedFiltersPage.displayName}
shouldShowOfflineIndicatorInWideScreen
offlineIndicatorStyle={styles.mtAuto}
includeSafeAreaPaddingBottom={false}
>
<HeaderWithBackButton title={translate('search.filtersHeader')} />
<HeaderWithBackButton title={translate('search.filtersHeader')}>
{shouldShowResetFilters && <TextLink onPress={SearchActions.clearAdvancedFilters}>{translate('search.resetFilters')}</TextLink>}
</HeaderWithBackButton>
<AdvancedSearchFilters />
</ScreenWrapper>
);
Expand Down
Loading