-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into feature/III-6358
- Loading branch information
Showing
17 changed files
with
384 additions
and
90 deletions.
There are no files selected for viewing
Validating CODEOWNERS rules …
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import getConfig from 'next/config'; | ||
import { useRouter } from 'next/router'; | ||
import { useMemo } from 'react'; | ||
|
||
import { useCookiesWithOptions } from './useCookiesWithOptions'; | ||
|
||
const useLegacyPath = () => { | ||
const { cookies } = useCookiesWithOptions(['token', 'udb-language']); | ||
const router = useRouter(); | ||
const { publicRuntimeConfig } = getConfig(); | ||
const prefixWhenNotEmpty = (value, prefix) => | ||
value ? `${prefix}${value}` : value; | ||
|
||
const jwt = cookies.token; | ||
const lang = cookies['udb-language']; | ||
|
||
const legacyPath = useMemo(() => { | ||
const path = new URL(`http://localhost${router.asPath}`).pathname; | ||
const { params = [], ...queryWithoutParams } = router.query; | ||
const queryString = prefixWhenNotEmpty( | ||
new URLSearchParams({ | ||
...queryWithoutParams, | ||
jwt, | ||
lang, | ||
}), | ||
'?', | ||
); | ||
|
||
return `${publicRuntimeConfig.legacyAppUrl}${path}${queryString}`; | ||
}, [ | ||
router.asPath, | ||
router.query, | ||
jwt, | ||
lang, | ||
publicRuntimeConfig.legacyAppUrl, | ||
]); | ||
|
||
return legacyPath; | ||
}; | ||
|
||
export { useLegacyPath }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.