'use client'; import { useQuery } from '@tanstack/react-query'; import { Card, CardContent } from '@/components/ui/card'; import { Button } from '@/components/ui/button'; import { Skeleton } from '@/components/ui/skeleton'; import { MapPin, Plus, ChevronRight } from 'lucide-react'; import { api } from '@/lib/api'; interface Zone { id: string; name: string; } interface Area { id: string; name: string; description?: string; zones?: Zone[]; } export default function AreasPage() { const { data, isLoading } = useQuery({ queryKey: ['areas'], queryFn: async () => (await api.get('/api/v1/areas')).data, }); const areas: Area[] = Array.isArray(data) ? data : (data?.data ?? []); return (

Areas & Zones

Service area and coverage zones

{isLoading ? (
{Array.from({ length: 3 }).map((_, i) => ( ))}
) : areas.length === 0 ? (

No service areas yet

) : (
{areas.map((area) => (

{area.name}

{area.description &&

{area.description}

} {area.zones && area.zones.length > 0 && (
{area.zones.map(z => ( {z.name} ))}
)}
{area.zones?.length ?? 0} zone{(area.zones?.length ?? 0) !== 1 ? 's' : ''}
))}
)}
); }