added tons of features

This commit is contained in:
2025-02-05 08:01:14 +02:00
parent 4ae0d8c545
commit 8138da6b1d
195 changed files with 12619 additions and 415 deletions

View File

@@ -0,0 +1,41 @@
'use client'
import {useLocale} from 'next-intl'
import {redirect} from 'next/navigation'
import {Link, usePathname, useRouter} from '@/i18n/routing'
import {Label} from '@/ui/label'
import {Switch} from '@/ui/switch'
export default function LocaleSwitcher() {
const router = useRouter()
const pathname = usePathname()
const locale = useLocale()
const initialState = locale !== 'uk'
const handler = (state: boolean) => {
const newPath = `/${locale}${pathname}`
//window.history.replaceState(null, '', newPath)
const link = document.getElementById('lang-switch')
if (link) {
link.innerText = `${state ? '/ru' : ''}${pathname}`
link.setAttribute('href', `${state ? '/ru' : ''}${pathname}`)
link.click()
}
}
// router.replace('/cabinet', {locale: checked ? 'ru' : 'uk'}
return (
<div className='flex items-center space-x-2'>
<Link id='lang-switch' href='/' locale='uk'>
LA
</Link>
<Label htmlFor='locale-switcher'>Укр</Label>
<Switch
id='locale-switcher'
defaultChecked={initialState}
onCheckedChange={handler}
/>
<Label htmlFor='locale-switcher'>Рус</Label>
</div>
)
}