Skip to content

Commit

Permalink
Redirect to seminar instead of '/' if possible (#496)
Browse files Browse the repository at this point in the history
fix #494: Redirect to seminar instead of '/' if possible
  • Loading branch information
Matushl authored Nov 24, 2024
1 parent 99deb9a commit a5717f7
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/components/Admin/AdminLayout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const AppMenuBar = () => {
position="relative"
toolbar={
<Stack gap={2} direction="row">
<Button color="inherit" onClick={() => router.push('/')}>
<Button color="inherit" onClick={() => router.push('/strom')}>
<Stack gap={1} direction="row">
<Home />
<Typography variant="body1">Späť na hlavnú stránku</Typography>
Expand Down
4 changes: 3 additions & 1 deletion src/components/Admin/useAuthProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,18 @@ import {useRouter} from 'next/router'
import {AuthProvider, HttpError} from 'react-admin'

import {AuthContainer, testAuth, testAuthRequest} from '@/utils/AuthContainer'
import {useSeminarInfo} from '@/utils/useSeminarInfo'

export const useAuthProvider = () => {
const {loginAsync, logoutAsync} = AuthContainer.useContainer()
const router = useRouter()
const {seminar} = useSeminarInfo()

const authProvider: AuthProvider = {
login: async ({username, password}) => loginAsync({data: {email: username, password}}),
logout: async () => {
await logoutAsync()
router.push('/')
router.push(`/${seminar}`)
},
checkAuth: async () => {
await testAuthRequest()
Expand Down
2 changes: 1 addition & 1 deletion src/components/PageLayout/LoginForm/LoginForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export const LoginForm: FC<LoginFormProps> = ({closeDialog}) => {
const redirectClose = () => {
closeDialog()
if (router.asPath.endsWith('registracia')) {
router.push('/')
router.push(`/${seminar}`)
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/components/PageLayout/MenuMain/BottomButtons.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export const BottomButtons: FC = () => {
const redirectLogout = () => {
logout()
if (router.asPath.endsWith('profil') || router.asPath.endsWith('profil/uprava')) {
router.push('/')
router.push(`/${seminar}`)
}
}

Expand Down
4 changes: 3 additions & 1 deletion src/components/PasswordReset/PasswordReset.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import {SubmitHandler, useForm} from 'react-hook-form'
import {Button} from '@/components/Clickable/Button'
import {FormInput} from '@/components/FormItems/FormInput/FormInput'
import {IGeneralPostResponse} from '@/types/api/general'
import {useSeminarInfo} from '@/utils/useSeminarInfo'

import {LoginForm} from '../PageLayout/LoginForm/LoginForm'

Expand All @@ -28,6 +29,7 @@ const defaultValues: PasswordResetForm = {

export const PasswordResetForm: FC<PasswordResetFormProps> = ({uid, token}) => {
const router = useRouter()
const {seminar} = useSeminarInfo()

const {handleSubmit, control, getValues} = useForm<PasswordResetForm>({defaultValues})

Expand Down Expand Up @@ -58,7 +60,7 @@ export const PasswordResetForm: FC<PasswordResetFormProps> = ({uid, token}) => {
<Typography variant="body1">Heslo úspešne zmenené, môžeš sa prihlásiť</Typography>
<LoginForm
closeDialog={() => {
router.push('/')
router.push(`/${seminar}`)
}}
/>
</Stack>
Expand Down

0 comments on commit a5717f7

Please sign in to comment.