Update changeLanguage
It needs the router
This commit is contained in:
parent
ef06168c08
commit
4765349b6b
2 changed files with 6 additions and 6 deletions
|
|
@ -160,7 +160,7 @@ const LoginModal = (props: Props) => {
|
||||||
accountState.account.authorized = true
|
accountState.account.authorized = true
|
||||||
|
|
||||||
setOpen(false)
|
setOpen(false)
|
||||||
changeLanguage(user.language)
|
changeLanguage(router, user.language)
|
||||||
}
|
}
|
||||||
|
|
||||||
function openChange(open: boolean) {
|
function openChange(open: boolean) {
|
||||||
|
|
|
||||||
|
|
@ -1,11 +1,11 @@
|
||||||
import { setCookie } from 'cookies-next'
|
import { setCookie } from 'cookies-next'
|
||||||
import { useRouter } from 'next/router'
|
import { NextRouter } from 'next/router'
|
||||||
|
|
||||||
export default function changeLanguage(newLanguage: string) {
|
|
||||||
const router = useRouter()
|
|
||||||
|
|
||||||
|
export default function changeLanguage(
|
||||||
|
router: NextRouter,
|
||||||
|
newLanguage: string
|
||||||
|
) {
|
||||||
if (newLanguage !== router.locale) {
|
if (newLanguage !== router.locale) {
|
||||||
setCookie('NEXT_LOCALE', newLanguage, { path: '/' })
|
setCookie('NEXT_LOCALE', newLanguage, { path: '/' })
|
||||||
router.push(router.asPath, undefined, { locale: newLanguage })
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue