Add custom hooks for time distance and retrieving like count

Documentation added to all custom hooks
This commit is contained in:
Aaron William Po
2023-04-03 23:32:32 -04:00
parent 801a3c8ad3
commit a4362a531c
13 changed files with 174 additions and 53 deletions

View File

@@ -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();