Fixed implementation of unauth language switcher
Now we can go implement it for auth
This commit is contained in:
parent
8d9b68906c
commit
14c6b5e2da
1 changed files with 5 additions and 6 deletions
|
|
@ -29,7 +29,7 @@ const HeaderMenu = (props: Props) => {
|
||||||
|
|
||||||
const [checked, setChecked] = useState(false)
|
const [checked, setChecked] = useState(false)
|
||||||
|
|
||||||
console.log(`Currently: ${checked} ${cookies['NEXT_LOCALE']}`)
|
// console.log(`Currently: ${checked} ${cookies['NEXT_LOCALE']}`)
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const locale = cookies['NEXT_LOCALE']
|
const locale = cookies['NEXT_LOCALE']
|
||||||
|
|
@ -37,11 +37,10 @@ const HeaderMenu = (props: Props) => {
|
||||||
}, [cookies])
|
}, [cookies])
|
||||||
|
|
||||||
function handleCheckedChange(value: boolean) {
|
function handleCheckedChange(value: boolean) {
|
||||||
setChecked(value)
|
const language = (value) ? 'ja' : 'en'
|
||||||
setCookies('NEXT_LOCALE', (value) ? 'ja' : 'en', { path: '/'})
|
setCookies('NEXT_LOCALE', language, { path: '/'})
|
||||||
|
router.push(router.asPath, undefined, { locale: language })
|
||||||
// TODO: How do we persist the current page when changing languages?
|
// router.reload()
|
||||||
window.location.href = '/'
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function authItems() {
|
function authItems() {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue