mirror of
https://github.com/aaronpo97/the-biergarten-app.git
synced 2026-02-16 20:13:49 +00:00
- Updated BeerPostHeader in /id page to use semantic HTML tags - Removed the getServerSidesProps fn in /login and /register. Moved the redirect logic over to the client, will redirect on the client side. - Added delete BeerPost option on the edit page.
18 lines
399 B
TypeScript
18 lines
399 B
TypeScript
import UserContext from '@/contexts/userContext';
|
|
import { useRouter } from 'next/router';
|
|
import { useContext, useEffect } from 'react';
|
|
|
|
const useRedirectWhenLoggedIn = () => {
|
|
const { user } = useContext(UserContext);
|
|
const router = useRouter();
|
|
|
|
useEffect(() => {
|
|
if (!user) {
|
|
return;
|
|
}
|
|
router.push('/');
|
|
}, [user, router]);
|
|
};
|
|
|
|
export default useRedirectWhenLoggedIn;
|