x
This commit is contained in:
1 parent
f7aa4d099f
commit
ab3e53c4da
33 files changed
+290
-69
No files matched your search
@@ -32,6 +32,12 @@ const LANGUAGES = [
|
||||
{ code: 'ko', label: '한국어', short: 'KO' },
|
||||
]
|
||||
|
||||
function setLanguageCookie(code: string) {
|
||||
if (typeof document !== 'undefined') {
|
||||
document.cookie = `homaroma_lang=${code}; path=/; max-age=31536000`
|
||||
}
|
||||
}
|
||||
|
||||
function createFallbackMenu(categories: Category[]): MegaMenuPayload[] {
|
||||
const categoryLinks = categories.map((category) => {
|
||||
// category.name is a multilingual Record<lang,string> when fetched with lang=all
|
||||
@@ -90,13 +96,13 @@ export default function Navbar({ categories = [], initialMenu = [], settings = n
|
||||
const changeLanguage = (code: string) => {
|
||||
i18n.changeLanguage(code)
|
||||
localStorage.setItem('homaroma_lang', code)
|
||||
document.cookie = `homaroma_lang=${code}; path=/; max-age=31536000`
|
||||
setLanguageCookie(code)
|
||||
|
||||
const currentPathWithoutLang = getPathWithoutLocale(pathname)
|
||||
const newPath = getPathWithLocale(currentPathWithoutLang, code)
|
||||
|
||||
setLangSheetOpen(false)
|
||||
router.push(newPath)
|
||||
router.push(newPath + window.location.search)
|
||||
}
|
||||
|
||||
const loginWithLine = () => {
|
||||
@@ -105,7 +111,7 @@ export default function Navbar({ categories = [], initialMenu = [], settings = n
|
||||
maybeWindow.liff.login()
|
||||
return
|
||||
}
|
||||
router.push('/profile')
|
||||
router.push(getPathWithLocale('/profile', lang))
|
||||
}
|
||||
|
||||
|
||||
@@ -163,7 +169,7 @@ export default function Navbar({ categories = [], initialMenu = [], settings = n
|
||||
const handleSearch = (e: React.FormEvent) => {
|
||||
e.preventDefault()
|
||||
if (searchQuery.trim()) {
|
||||
router.push(`/search?q=${encodeURIComponent(searchQuery.trim())}`)
|
||||
router.push(getPathWithLocale(`/search?q=${encodeURIComponent(searchQuery.trim())}`, lang))
|
||||
setSearchOpen(false)
|
||||
setMobileOpen(false)
|
||||
setSearchQuery('')
|
||||
|
||||
Reference in new issue
Block a user