-
Notifications
You must be signed in to change notification settings - Fork 3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #46566 from software-mansion-labs/search-v2/curren…
…cy-filter [Search v2] [App] Create Currency filter
- Loading branch information
Showing
20 changed files
with
140 additions
and
24 deletions.
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
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
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,71 @@ | ||
import React, {useState} from 'react'; | ||
import {useOnyx} from 'react-native-onyx'; | ||
import FullPageNotFoundView from '@components/BlockingViews/FullPageNotFoundView'; | ||
import CurrencySelectionList from '@components/CurrencySelectionList'; | ||
import type {CurrencyListItem} from '@components/CurrencySelectionList/types'; | ||
import FormAlertWithSubmitButton from '@components/FormAlertWithSubmitButton'; | ||
import HeaderWithBackButton from '@components/HeaderWithBackButton'; | ||
import ScreenWrapper from '@components/ScreenWrapper'; | ||
import useLocalize from '@hooks/useLocalize'; | ||
import useThemeStyles from '@hooks/useThemeStyles'; | ||
import * as SearchActions from '@libs/actions/Search'; | ||
import Navigation from '@libs/Navigation/Navigation'; | ||
import ONYXKEYS from '@src/ONYXKEYS'; | ||
import ROUTES from '@src/ROUTES'; | ||
|
||
function SearchFiltersCurrencyPage() { | ||
const styles = useThemeStyles(); | ||
const {translate} = useLocalize(); | ||
const [searchAdvancedFiltersForm] = useOnyx(ONYXKEYS.FORMS.SEARCH_ADVANCED_FILTERS_FORM); | ||
const [selectedCurrencies, setSelectedCurrencies] = useState<string[]>(searchAdvancedFiltersForm?.currency ?? []); | ||
|
||
const handleOnSelectOption = (option: CurrencyListItem) => { | ||
if (selectedCurrencies.includes(option.currencyCode)) { | ||
setSelectedCurrencies(selectedCurrencies.filter((currency) => currency !== option.currencyCode)); | ||
return; | ||
} | ||
|
||
setSelectedCurrencies([option.currencyCode, ...selectedCurrencies]); | ||
}; | ||
|
||
const handleOnSubmit = () => { | ||
SearchActions.updateAdvancedFilters({...searchAdvancedFiltersForm, currency: selectedCurrencies}); | ||
Navigation.goBack(ROUTES.SEARCH_ADVANCED_FILTERS); | ||
}; | ||
|
||
return ( | ||
<ScreenWrapper | ||
testID={SearchFiltersCurrencyPage.displayName} | ||
shouldShowOfflineIndicatorInWideScreen | ||
offlineIndicatorStyle={styles.mtAuto} | ||
includeSafeAreaPaddingBottom={false} | ||
> | ||
{({didScreenTransitionEnd}) => ( | ||
<FullPageNotFoundView shouldShow={false}> | ||
<HeaderWithBackButton title={translate('search.filters.currency')} /> | ||
<CurrencySelectionList | ||
canSelectMultiple | ||
selectedCurrencies={selectedCurrencies} | ||
searchInputLabel={translate('common.search')} | ||
onSelect={(option: CurrencyListItem) => { | ||
if (!didScreenTransitionEnd) { | ||
return; | ||
} | ||
handleOnSelectOption(option); | ||
}} | ||
/> | ||
<FormAlertWithSubmitButton | ||
buttonText={translate('common.save')} | ||
containerStyles={[styles.m4, styles.mb5]} | ||
onSubmit={handleOnSubmit} | ||
enabledWhenOffline | ||
/> | ||
</FullPageNotFoundView> | ||
)} | ||
</ScreenWrapper> | ||
); | ||
} | ||
|
||
SearchFiltersCurrencyPage.displayName = 'SearchFiltersCurrencyPage'; | ||
|
||
export default SearchFiltersCurrencyPage; |
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.