-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move fetch user data logic and format date out
- Loading branch information
1 parent
057d57c
commit 8fe91f8
Showing
5 changed files
with
42 additions
and
38 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,15 @@ | ||
import { fetchData } from '@/utils/utils'; | ||
import { QueriedUserData } from 'bookem-shared/src/types/database'; | ||
import { useEffect, useState } from 'react'; | ||
|
||
export const useUserData = () => { | ||
const [userData, setUserData] = useState<QueriedUserData | null>(null); | ||
|
||
useEffect(() => { | ||
fetchData('/api/users/') | ||
.then(data => setUserData(data)) | ||
.catch(err => console.error('Error fetching user data:', err)); | ||
}, []); | ||
|
||
return userData; | ||
}; |
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