Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Redirect to seminar instead of '/' if possible #496

Merged
merged 1 commit into from
Nov 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading