mirror of
https://github.com/hedgedoc/hedgedoc.git
synced 2026-06-23 04:10:17 +00:00
refactor(frontend): export DEFAULT_FALLBACK_URL
Signed-off-by: Philip Molares <philip.molares@udo.edu>
This commit is contained in:
committed by
Erik Michelson
parent
89e441597d
commit
f9077d7ff5
@@ -10,6 +10,7 @@ import { MessageType } from '@hedgedoc/commons'
|
||||
import type { Listener } from 'eventemitter2'
|
||||
import { useRouter } from 'next/navigation'
|
||||
import { useCallback, useEffect } from 'react'
|
||||
import { DEFAULT_FALLBACK_URL } from '../../../../login-page/utils/use-get-post-login-redirect-url'
|
||||
|
||||
/**
|
||||
* Hook that redirects the user to the history page and displays a notification when the note is deleted.
|
||||
@@ -27,7 +28,7 @@ export const useOnNoteDeleted = (websocketConnection: MessageTransporter): void
|
||||
noteTitle
|
||||
}
|
||||
})
|
||||
router.push('/explore/my')
|
||||
router.push(DEFAULT_FALLBACK_URL)
|
||||
}, [router, noteTitle, dispatchUiNotification])
|
||||
|
||||
useEffect(() => {
|
||||
|
||||
@@ -5,13 +5,13 @@
|
||||
*/
|
||||
import { useSingleStringUrlParameter } from '../../../hooks/common/use-single-string-url-parameter'
|
||||
|
||||
const defaultFallback = '/explore/my'
|
||||
export const DEFAULT_FALLBACK_URL = '/explore/my'
|
||||
|
||||
/**
|
||||
* Returns the URL that the user should be redirected to after logging in.
|
||||
* If no parameter has been provided or if the URL is not relative, then "/explore/my" will be used.
|
||||
*/
|
||||
export const useGetPostLoginRedirectUrl = (): string => {
|
||||
const redirectBackUrl = useSingleStringUrlParameter('redirectBackTo', defaultFallback)
|
||||
return redirectBackUrl.startsWith('/') && !redirectBackUrl.startsWith('//') ? redirectBackUrl : defaultFallback
|
||||
const redirectBackUrl = useSingleStringUrlParameter('redirectBackTo', DEFAULT_FALLBACK_URL)
|
||||
return redirectBackUrl.startsWith('/') && !redirectBackUrl.startsWith('//') ? redirectBackUrl : DEFAULT_FALLBACK_URL
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user