From 507113d7f1afc17d9ac2c73ae3cc08dbfb2bebb1 Mon Sep 17 00:00:00 2001 From: Smilinko Date: Sat, 9 Dec 2023 00:01:36 +0100 Subject: [PATCH] added redirections after logging in or out --- .../PageLayout/Authentication/Authentication.tsx | 8 ++++---- src/components/PageLayout/LoginForm/LoginForm.tsx | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/components/PageLayout/Authentication/Authentication.tsx b/src/components/PageLayout/Authentication/Authentication.tsx index 36f14121..efe7b608 100644 --- a/src/components/PageLayout/Authentication/Authentication.tsx +++ b/src/components/PageLayout/Authentication/Authentication.tsx @@ -1,4 +1,5 @@ import Link from 'next/link' +import {useRouter} from 'next/router' import {FC, useState} from 'react' import {AuthContainer} from '@/utils/AuthContainer' @@ -7,7 +8,6 @@ import {useSeminarInfo} from '@/utils/useSeminarInfo' import {Overlay} from '../../Overlay/Overlay' import {LoginForm} from '../LoginForm/LoginForm' import styles from './Authentication.module.scss' -import { useRouter } from 'next/router' export const Authentication: FC = () => { const [displayAuthenticationOverlay, setDisplayAuthenticationOverlay] = useState(false) @@ -19,12 +19,12 @@ export const Authentication: FC = () => { const {seminar} = useSeminarInfo() - const router = useRouter() + const router = useRouter() const redirectLogout = () => { logout() - if (router.asPath.endsWith("profil") || router.asPath.endsWith("profil/uprava")) { - router.push("/") + if (router.asPath.endsWith('profil') || router.asPath.endsWith('profil/uprava')) { + router.push('/') } } diff --git a/src/components/PageLayout/LoginForm/LoginForm.tsx b/src/components/PageLayout/LoginForm/LoginForm.tsx index 2aaefd54..c3af1884 100644 --- a/src/components/PageLayout/LoginForm/LoginForm.tsx +++ b/src/components/PageLayout/LoginForm/LoginForm.tsx @@ -1,3 +1,4 @@ +import {useRouter} from 'next/router' import {FC} from 'react' import {SubmitHandler, useForm} from 'react-hook-form' @@ -5,7 +6,6 @@ import {Button} from '@/components/Clickable/Clickable' import styles from '@/components/FormItems/Form.module.scss' import {FormInput} from '@/components/FormItems/FormInput/FormInput' import {AuthContainer} from '@/utils/AuthContainer' -import { useRouter } from 'next/router' type LoginFormValues = { email: string @@ -25,12 +25,12 @@ export const LoginForm: FC = ({closeOverlay}) => { const {login} = AuthContainer.useContainer() const {handleSubmit, control} = useForm({defaultValues}) - const router = useRouter() + const router = useRouter() const redirectClose = () => { closeOverlay() - if (router.asPath.endsWith("registracia")) { - router.push("/") + if (router.asPath.endsWith('registracia')) { + router.push('/') } }