-
Notifications
You must be signed in to change notification settings - Fork 3.9k
Add purchase-currency and purchase-amount #69532
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
Merged
Merged
Changes from all commits
Commits
Show all changes
22 commits
Select commit
Hold shift + click to select a range
6e9c660
add to filters
JS00001 e8d577e
add to consts
JS00001 e24f6fd
add purchase amount to display didle
JS00001 b107ee1
add more amount params
JS00001 ac5559f
add currency
JS00001 d04199a
add peggy
JS00001 f737a8c
add linking
JS00001 0927261
update titles
JS00001 be89f27
make a currency base component
JS00001 0adc3c6
update currency base to support multi/single selcet
JS00001 14cc507
update group currency to use same component
JS00001 5edacde
Merge branch 'main' of github.com:Expensify/App into jsenyitko-purcha…
JS00001 b17c468
fix or
JS00001 4c140ef
generate search parser w/o merge conflicts
JS00001 335ca36
eslint fix
JS00001 c0c4240
translations
JS00001 2e9a92f
get rid of submodule
JS00001 0ac5576
Merge branch 'main' of github.com:Expensify/App into jsenyitko-purcha…
JS00001 77d50a9
fix currency base route
JS00001 3b1e2a0
update filter routes
JS00001 61c6d60
fix mobile-e
JS00001 a1e8974
Merge branch 'main' of github.com:Expensify/App into jsenyitko-purcha…
JS00001 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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,97 @@ | ||
| import React, {useMemo} from 'react'; | ||
| import {View} from 'react-native'; | ||
| import HeaderWithBackButton from '@components/HeaderWithBackButton'; | ||
| import ScreenWrapper from '@components/ScreenWrapper'; | ||
| import useLocalize from '@hooks/useLocalize'; | ||
| import useOnyx from '@hooks/useOnyx'; | ||
| import useThemeStyles from '@hooks/useThemeStyles'; | ||
| import {updateAdvancedFilters} from '@libs/actions/Search'; | ||
| import {getCurrencySymbol} from '@libs/CurrencyUtils'; | ||
| import Navigation from '@libs/Navigation/Navigation'; | ||
| import type {TranslationPaths} from '@src/languages/types'; | ||
| import ONYXKEYS from '@src/ONYXKEYS'; | ||
| import ROUTES from '@src/ROUTES'; | ||
| import SearchMultipleSelectionPicker from './SearchMultipleSelectionPicker'; | ||
| import type {SearchSingleSelectionPickerItem} from './SearchSingleSelectionPicker'; | ||
| import SearchSingleSelectionPicker from './SearchSingleSelectionPicker'; | ||
| import type {SearchCurrencyFilterKeys} from './types'; | ||
|
|
||
| type SearchFiltersCurrencyBaseProps = { | ||
| multiselect?: boolean; | ||
| title: TranslationPaths; | ||
| filterKey: SearchCurrencyFilterKeys; | ||
| }; | ||
|
|
||
| function SearchFiltersCurrencyBase({title, filterKey, multiselect = false}: SearchFiltersCurrencyBaseProps) { | ||
| const styles = useThemeStyles(); | ||
| const {translate} = useLocalize(); | ||
| const [currencyList] = useOnyx(ONYXKEYS.CURRENCY_LIST, {canBeMissing: false}); | ||
| const [searchAdvancedFiltersForm] = useOnyx(ONYXKEYS.FORMS.SEARCH_ADVANCED_FILTERS_FORM, {canBeMissing: false}); | ||
| const selectedCurrencyData = searchAdvancedFiltersForm?.[filterKey]; | ||
|
|
||
| const {selectedCurrenciesItems, currencyItems} = useMemo(() => { | ||
| const currencies: SearchSingleSelectionPickerItem[] = []; | ||
| const selectedCurrencies: SearchSingleSelectionPickerItem[] = []; | ||
|
|
||
| Object.keys(currencyList ?? {}).forEach((currencyCode) => { | ||
| if (currencyList?.[currencyCode]?.retired) { | ||
| return; | ||
| } | ||
|
|
||
| if (Array.isArray(selectedCurrencyData) && selectedCurrencyData?.includes(currencyCode) && !selectedCurrencies.some((currencyItem) => currencyItem.value === currencyCode)) { | ||
| selectedCurrencies.push({name: `${currencyCode} - ${getCurrencySymbol(currencyCode)}`, value: currencyCode}); | ||
| } | ||
|
|
||
| if (!Array.isArray(selectedCurrencyData) && selectedCurrencyData === currencyCode) { | ||
| selectedCurrencies.push({name: `${currencyCode} - ${getCurrencySymbol(currencyCode)}`, value: currencyCode}); | ||
| } | ||
|
|
||
| if (!currencies.some((item) => item.value === currencyCode)) { | ||
| currencies.push({name: `${currencyCode} - ${getCurrencySymbol(currencyCode)}`, value: currencyCode}); | ||
| } | ||
| }); | ||
|
|
||
| return {selectedCurrenciesItems: selectedCurrencies, currencyItems: currencies}; | ||
| }, [currencyList, selectedCurrencyData]); | ||
|
|
||
| const handleOnSubmit = (values: string[] | string | undefined) => { | ||
| updateAdvancedFilters({[filterKey]: values ?? null}); | ||
| }; | ||
|
|
||
| return ( | ||
| <ScreenWrapper | ||
| testID={SearchFiltersCurrencyBase.displayName} | ||
| shouldShowOfflineIndicatorInWideScreen | ||
| offlineIndicatorStyle={styles.mtAuto} | ||
| includeSafeAreaPaddingBottom | ||
| shouldEnableMaxHeight | ||
| > | ||
| <HeaderWithBackButton | ||
| title={translate(title)} | ||
| onBackButtonPress={() => { | ||
| Navigation.goBack(ROUTES.SEARCH_ADVANCED_FILTERS.getRoute()); | ||
| }} | ||
| /> | ||
| <View style={[styles.flex1]}> | ||
| {multiselect && ( | ||
| <SearchMultipleSelectionPicker | ||
| items={currencyItems} | ||
| initiallySelectedItems={selectedCurrenciesItems} | ||
| onSaveSelection={handleOnSubmit} | ||
| /> | ||
| )} | ||
| {!multiselect && ( | ||
| <SearchSingleSelectionPicker | ||
| items={currencyItems} | ||
| initiallySelectedItem={selectedCurrenciesItems.at(0)} | ||
| onSaveSelection={handleOnSubmit} | ||
| /> | ||
| )} | ||
| </View> | ||
| </ScreenWrapper> | ||
| ); | ||
| } | ||
|
|
||
| SearchFiltersCurrencyBase.displayName = 'SearchFiltersCurrencyBase'; | ||
|
|
||
| export default SearchFiltersCurrencyBase; | ||
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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.
Uh oh!
There was an error while loading. Please reload this page.