/opt/canhelp/apps/web/src/components
Edit: /opt/canhelp/apps/web/src/components/HomeCityPicker.tsx (5490B)
'use client'
import { useState } from 'react'
import { useLocation } from '@/context/location'
import { useLocale } from '@/context/locale'
export function HomeCityPicker() {
const { locationSlug, locationTree, setLocation, getLabel } = useLocation()
const { t, locale } = useLocale()
const [open, setOpen] = useState(false)
const label = getLabel(locale)
return (
{open && (
<>
{/* Backdrop */}
setOpen(false)} />
{/* Anywhere */}
{locationTree.map((city) => {
const cityName = city.names[locale] ?? city.names.el
const districts = city.children ?? []
const isCitySelected = locationSlug === city.slug
return (
{cityName}
{districts.map((d) => {
const dName = d.names[locale] ?? d.names.el
const isSelected = locationSlug === d.slug
return (
)
})}
)
})}
>
)}
)
}