-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Krishna Gupta <belivethatkg@gmail.com>
- Loading branch information
1 parent
40b30f0
commit 5b42bdf
Showing
4 changed files
with
31 additions
and
37 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import type {Dispatch} from 'react'; | ||
import {useCallback} from 'react'; | ||
import * as Report from '@userActions/Report'; | ||
|
||
/** | ||
* Hook for fetching reports when user updated search term and hasn't selected max number of participants | ||
*/ | ||
const useSearchTermAndSearch = (setSearchTerm: Dispatch<React.SetStateAction<string>>, maxParticipantsReached: boolean) => { | ||
const setSearchTermAndSearchInServer = useCallback( | ||
(text = '') => { | ||
if (text && !maxParticipantsReached) { | ||
Report.searchInServer(text); | ||
} | ||
setSearchTerm(text); | ||
}, | ||
[maxParticipantsReached, setSearchTerm], | ||
); | ||
|
||
return setSearchTermAndSearchInServer; | ||
}; | ||
|
||
export default useSearchTermAndSearch; |
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