-
Notifications
You must be signed in to change notification settings - Fork 46
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: remove the link if the author is not available (#169)
* chore: remove the link if the author is not available * chore: extract collaborator hook
- Loading branch information
1 parent
9cad8fc
commit 3c57082
Showing
2 changed files
with
28 additions
and
3 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import { useEffect, useState } from 'react'; | ||
|
||
const useHasCollaborator = (name: string): boolean => { | ||
const [availableAuthor, setAvailableAuthor] = useState(false); | ||
|
||
useEffect(() => { | ||
const fetchCollaborator = async () => { | ||
const res = await fetch(`/collaborators/name/${encodeURI(name)}`); | ||
setAvailableAuthor(res.status === 200); | ||
}; | ||
|
||
fetchCollaborator(); | ||
}, [name]); | ||
|
||
return availableAuthor; | ||
}; | ||
|
||
export default useHasCollaborator; |