mirror of
https://github.com/aaronpo97/the-biergarten-app.git
synced 2026-02-16 10:42:08 +00:00
Add custom hooks for time distance and retrieving like count
Documentation added to all custom hooks
This commit is contained in:
@@ -2,7 +2,14 @@ import UserContext from '@/contexts/userContext';
|
||||
import { useRouter } from 'next/router';
|
||||
import { useContext } from 'react';
|
||||
|
||||
const useRedirectWhenLoggedIn = () => {
|
||||
/**
|
||||
* Custom React hook that redirects the user to the home page if they are logged in. This
|
||||
* hook is used to prevent logged in users from accessing the login and signup pages. Must
|
||||
* be used under the UserContext provider.
|
||||
*
|
||||
* @returns {void}
|
||||
*/
|
||||
const useRedirectWhenLoggedIn = (): void => {
|
||||
const { user } = useContext(UserContext);
|
||||
const router = useRouter();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user