-
Notifications
You must be signed in to change notification settings - Fork 3k
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 more search filters #52938
Merged
Merged
Add more search filters #52938
Changes from 23 commits
Commits
Show all changes
26 commits
Select commit
Hold shift + click to select a range
b753beb
add more search filters
luacmartins 93f1382
add date filters to advanced page
luacmartins 13c3e87
add screens
luacmartins 9df3103
add pages
luacmartins a6e612d
add values to page
luacmartins adf06af
add values to filters
luacmartins 6578473
decode values
luacmartins 29c67e1
add spacers
luacmartins 978c180
Merge branch 'main' into cmartins-addMoreDateFilters
luacmartins e55d794
add sections
luacmartins c701978
only show posted if cards are enabled
luacmartins 06197f7
stop sorting filters
luacmartins 57e888f
fix lint
luacmartins be30679
filter empty sections
luacmartins db24949
fix ts
luacmartins dacf439
update spanish translation
luacmartins c14d1d5
refactor code to support before and after
luacmartins de2c9dd
refactor pages
luacmartins b61410e
refactor all pages
luacmartins f4690da
fix lint
luacmartins 0f24781
fix import
luacmartins 8dbf469
fix lint
luacmartins f213732
resolve conflicts
luacmartins 8621611
Merge branch 'main' into cmartins-addMoreDateFilters
luacmartins caa85b6
use array
luacmartins 7a31ff3
fix lint
luacmartins File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
import {format} from 'date-fns'; | ||
import React from 'react'; | ||
import {useOnyx} from 'react-native-onyx'; | ||
import DatePicker from '@components/DatePicker'; | ||
import FormProvider from '@components/Form/FormProvider'; | ||
import InputWrapper from '@components/Form/InputWrapper'; | ||
import type {FormOnyxValues} from '@components/Form/types'; | ||
import HeaderWithBackButton from '@components/HeaderWithBackButton'; | ||
import ScreenWrapper from '@components/ScreenWrapper'; | ||
import useLocalize from '@hooks/useLocalize'; | ||
import useThemeStyles from '@hooks/useThemeStyles'; | ||
import {updateAdvancedFilters} from '@libs/actions/Search'; | ||
import Navigation from '@libs/Navigation/Navigation'; | ||
import CONST from '@src/CONST'; | ||
import type {TranslationPaths} from '@src/languages/types'; | ||
import ONYXKEYS from '@src/ONYXKEYS'; | ||
import ROUTES from '@src/ROUTES'; | ||
import type {SearchDateFilterKeys} from './types'; | ||
|
||
type SearchDateFilterBaseProps = { | ||
/** Key used for the date filter */ | ||
dateKey: SearchDateFilterKeys; | ||
|
||
/** The translation key for the page title */ | ||
titleKey: TranslationPaths; | ||
}; | ||
|
||
function SearchDateFilterBase({dateKey, titleKey}: SearchDateFilterBaseProps) { | ||
const styles = useThemeStyles(); | ||
const {translate} = useLocalize(); | ||
|
||
const [searchAdvancedFiltersForm] = useOnyx(ONYXKEYS.FORMS.SEARCH_ADVANCED_FILTERS_FORM); | ||
const unformattedDateAfter = searchAdvancedFiltersForm?.[`${dateKey}${CONST.SEARCH.DATE_MODIFIERS.AFTER}`]; | ||
const unformattedDateBefore = searchAdvancedFiltersForm?.[`${dateKey}${CONST.SEARCH.DATE_MODIFIERS.BEFORE}`]; | ||
const dateAfter = unformattedDateAfter ? format(unformattedDateAfter, 'yyyy-MM-dd') : undefined; | ||
const dateBefore = unformattedDateBefore ? format(unformattedDateBefore, 'yyyy-MM-dd') : undefined; | ||
|
||
const updateDateFilter = (values: FormOnyxValues<typeof ONYXKEYS.FORMS.SEARCH_ADVANCED_FILTERS_FORM>) => { | ||
updateAdvancedFilters(values); | ||
Navigation.goBack(ROUTES.SEARCH_ADVANCED_FILTERS); | ||
}; | ||
|
||
return ( | ||
<ScreenWrapper | ||
testID={SearchDateFilterBase.displayName} | ||
shouldShowOfflineIndicatorInWideScreen | ||
offlineIndicatorStyle={styles.mtAuto} | ||
includeSafeAreaPaddingBottom | ||
shouldEnableMaxHeight | ||
> | ||
<HeaderWithBackButton | ||
title={translate(titleKey)} | ||
onBackButtonPress={() => { | ||
Navigation.goBack(ROUTES.SEARCH_ADVANCED_FILTERS); | ||
}} | ||
/> | ||
<FormProvider | ||
style={[styles.flex1, styles.ph5]} | ||
formID={ONYXKEYS.FORMS.SEARCH_ADVANCED_FILTERS_FORM} | ||
onSubmit={updateDateFilter} | ||
submitButtonText={translate('common.save')} | ||
enabledWhenOffline | ||
> | ||
<InputWrapper | ||
InputComponent={DatePicker} | ||
inputID={`${dateKey}${CONST.SEARCH.DATE_MODIFIERS.AFTER}`} | ||
label={translate('search.filters.date.after')} | ||
defaultValue={dateAfter} | ||
maxDate={CONST.CALENDAR_PICKER.MAX_DATE} | ||
minDate={CONST.CALENDAR_PICKER.MIN_DATE} | ||
/> | ||
<InputWrapper | ||
InputComponent={DatePicker} | ||
inputID={`${dateKey}${CONST.SEARCH.DATE_MODIFIERS.BEFORE}`} | ||
label={translate('search.filters.date.before')} | ||
defaultValue={dateBefore} | ||
maxDate={CONST.CALENDAR_PICKER.MAX_DATE} | ||
minDate={CONST.CALENDAR_PICKER.MIN_DATE} | ||
/> | ||
</FormProvider> | ||
</ScreenWrapper> | ||
); | ||
} | ||
|
||
SearchDateFilterBase.displayName = 'SearchDateFilterBase'; | ||
|
||
export default SearchDateFilterBase; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should we handle maxDate and minDate of dateBefore based on dateAfter and vice versa?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We don't do that for the current date filter, so I'm inclined to not change the behaviour as part of this PR.