Skip to content

Commit

Permalink
added redirections after logging in or out
Browse files Browse the repository at this point in the history
  • Loading branch information
Smilinko committed Dec 8, 2023
1 parent 87a872d commit 507113d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
8 changes: 4 additions & 4 deletions src/components/PageLayout/Authentication/Authentication.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import Link from 'next/link'
import {useRouter} from 'next/router'
import {FC, useState} from 'react'

import {AuthContainer} from '@/utils/AuthContainer'
Expand All @@ -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)
Expand All @@ -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('/')
}
}

Expand Down
8 changes: 4 additions & 4 deletions src/components/PageLayout/LoginForm/LoginForm.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import {useRouter} from 'next/router'
import {FC} from 'react'
import {SubmitHandler, useForm} from 'react-hook-form'

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
Expand All @@ -25,12 +25,12 @@ export const LoginForm: FC<ILoginForm> = ({closeOverlay}) => {
const {login} = AuthContainer.useContainer()
const {handleSubmit, control} = useForm<LoginFormValues>({defaultValues})

const router = useRouter()
const router = useRouter()

const redirectClose = () => {
closeOverlay()
if (router.asPath.endsWith("registracia")) {
router.push("/")
if (router.asPath.endsWith('registracia')) {
router.push('/')
}
}

Expand Down

0 comments on commit 507113d

Please sign in to comment.