/opt/canhelp/apps/web/src/components
Edit: /opt/canhelp/apps/web/src/components/HomeCityCloud.tsx (1790B)
'use client'
import { useRouter } from 'next/navigation'
import { useLocation } from '@/context/location'
import { useLocale } from '@/context/locale'
interface LocationNode {
id: number
slug: string
names: Record
children?: LocationNode[]
}
interface Props {
locationTree: LocationNode[]
isSpecialist?: boolean
}
export function HomeCityCloud({ locationTree, isSpecialist = false }: Props) {
const router = useRouter()
const { setLocation } = useLocation()
const { locale } = useLocale()
const handleClick = (slug: string) => {
if (isSpecialist) {
router.push(`/tasks?location=${slug}`)
} else {
setLocation(slug)
router.push('/tasks/new')
}
}
if (!locationTree.length) return null
return (
{locationTree.map((city) => (
{(city.children ?? []).map((d) => (
))}
))}
)
}