Merged in chore/move-enter-details (pull request #2778)
Chore/move enter details Approved-by: Anton Gunnarsson
This commit is contained in:
17
packages/tracking/lib/hooks/useLang.ts
Normal file
17
packages/tracking/lib/hooks/useLang.ts
Normal file
@@ -0,0 +1,17 @@
|
||||
"use client"
|
||||
import { useParams } from "next/navigation"
|
||||
|
||||
import { Lang } from "@scandic-hotels/common/constants/language"
|
||||
import { languageSchema } from "@scandic-hotels/common/utils/languages"
|
||||
|
||||
/**
|
||||
* A hook to get the current lang from the URL
|
||||
*/
|
||||
export default function useLang() {
|
||||
const { lang } = useParams<{
|
||||
lang: Lang
|
||||
}>()
|
||||
|
||||
const parsedLang = languageSchema.safeParse(lang)
|
||||
return parsedLang.success ? parsedLang.data : Lang.en
|
||||
}
|
||||
Reference in New Issue
Block a user