/opt/canhelp/apps/web/src/app/tasks
Edit: /opt/canhelp/apps/web/src/app/tasks/TaskModeToggle.tsx (1589B)
'use client'
import { useRouter, usePathname, useSearchParams } from 'next/navigation'
import { useLocale } from '@/context/locale'
export function TaskModeToggle({ mode }: { mode: 'all' | 'for_me' }) {
const router = useRouter()
const pathname = usePathname()
const searchParams = useSearchParams()
const { locale } = useLocale()
const switchTo = (newMode: 'all' | 'for_me') => {
const params = new URLSearchParams(searchParams.toString())
if (newMode === 'for_me') {
params.set('mode', 'for_me')
} else {
params.delete('mode')
}
params.delete('page')
router.push(`${pathname}${params.toString() ? '?' + params.toString() : ''}`)
}
const forMeLabel = locale === 'ru' ? 'Для меня' : locale === 'en' ? 'For me' : 'Για μένα'
const allLabel = locale === 'ru' ? 'Все заказы' : locale === 'en' ? 'All tasks' : 'Όλες οι εργασίες'
return (
)
}