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)
|
||||
|
||||
console.log(`Currently: ${checked} ${cookies['NEXT_LOCALE']}`)
|
||||
// console.log(`Currently: ${checked} ${cookies['NEXT_LOCALE']}`)
|
||||
|
||||
useEffect(() => {
|
||||
const locale = cookies['NEXT_LOCALE']
|
||||
|
|
@ -37,11 +37,10 @@ const HeaderMenu = (props: Props) => {
|
|||
}, [cookies])
|
||||
|
||||
function handleCheckedChange(value: boolean) {
|
||||
setChecked(value)
|
||||
setCookies('NEXT_LOCALE', (value) ? 'ja' : 'en', { path: '/'})
|
||||
|
||||
// TODO: How do we persist the current page when changing languages?
|
||||
window.location.href = '/'
|
||||
const language = (value) ? 'ja' : 'en'
|
||||
setCookies('NEXT_LOCALE', language, { path: '/'})
|
||||
router.push(router.asPath, undefined, { locale: language })
|
||||
// router.reload()
|
||||
}
|
||||
|
||||
function authItems() {
|
||||
|
|
|
|||
Loading…
Reference in a new issue