-
Notifications
You must be signed in to change notification settings - Fork 2.8k
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 #48566 from Expensify/lucien/search-savedSearches
[Search v2.3] [App] Implement Saved Search feature
- Loading branch information
Showing
32 changed files
with
625 additions
and
97 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,47 @@ | ||
import React, {useState} from 'react'; | ||
import ConfirmModal from '@components/ConfirmModal'; | ||
import Navigation from '@libs/Navigation/Navigation'; | ||
import * as SearchUtils from '@libs/SearchUtils'; | ||
import * as SearchActions from '@userActions/Search'; | ||
import CONST from '@src/CONST'; | ||
import ROUTES from '@src/ROUTES'; | ||
import useLocalize from './useLocalize'; | ||
|
||
export default function useDeleteSavedSearch() { | ||
const [isDeleteModalVisible, setIsDeleteModalVisible] = useState(false); | ||
const [hashToDelete, setHashToDelete] = useState(0); | ||
const {translate} = useLocalize(); | ||
|
||
const showDeleteModal = (hash: number) => { | ||
setIsDeleteModalVisible(true); | ||
setHashToDelete(hash); | ||
}; | ||
|
||
const handleDelete = () => { | ||
SearchActions.deleteSavedSearch(hashToDelete); | ||
setIsDeleteModalVisible(false); | ||
SearchActions.clearAdvancedFilters(); | ||
Navigation.navigate( | ||
ROUTES.SEARCH_CENTRAL_PANE.getRoute({ | ||
query: SearchUtils.buildCannedSearchQuery(CONST.SEARCH.DATA_TYPES.EXPENSE, CONST.SEARCH.STATUS.EXPENSE.ALL), | ||
}), | ||
); | ||
}; | ||
|
||
function DeleteConfirmModal() { | ||
return ( | ||
<ConfirmModal | ||
title={translate('search.deleteSavedSearch')} | ||
onConfirm={handleDelete} | ||
onCancel={() => setIsDeleteModalVisible(false)} | ||
isVisible={isDeleteModalVisible} | ||
prompt={translate('search.deleteSavedSearchConfirm')} | ||
confirmText={translate('common.delete')} | ||
cancelText={translate('common.cancel')} | ||
danger | ||
/> | ||
); | ||
} | ||
|
||
return {showDeleteModal, DeleteConfirmModal}; | ||
} |
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,5 @@ | ||
type DeleteSavedSearchParams = { | ||
hash: number; | ||
}; | ||
|
||
export default DeleteSavedSearchParams; |
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,8 @@ | ||
import type {SearchQueryString} from '@components/Search/types'; | ||
|
||
type SaveSearchParams = { | ||
jsonQuery: SearchQueryString; | ||
name?: string; | ||
}; | ||
|
||
export default SaveSearchParams; |
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.