"use client";
import React, { useEffect, useState, Suspense } from "react";
import Link from "next/link";
import dynamic from "next/dynamic";
import { useSearchParams, useRouter } from "next/navigation";
import Button from "@/components/ui/Button";
import { mapLayers } from "@/components/ui/mapLayers";
// Dynamically import the map component to avoid SSR issues
const DynamicMap = dynamic(() => import("@/components/ui/LeafletMap"), {
ssr: false,
loading: () => (
{/* Floating Header - Left Side */}
{/* Title Box */}
Projects Map
{markers.length} of {projects.length} projects with coordinates
{" "}
{/* Zoom Controls - Below Title */}
{" "}
{" "}
{/* Tool Panel - Below Zoom Controls */}
{" "}
{" "}
{/* Move Tool */}
{/* Select Tool */}
{/* Measure Tool */}
{/* Draw Tool */}
{/* Pin/Marker Tool */}
{/* Area Tool */}
{/* Layer Control Panel - Right Side */}
{/* Action Buttons */}
{/* Layer Control Panel */}
{/* Layer Control Header */}
{" "}
{/* Layer Control Content */}
{/* Base Layers Section */}
{/* Overlay Layers Section */}
{mapLayers.overlays && mapLayers.overlays.length > 0 && (
)}
{" "}
{/* Status Filter Panel - Bottom Left */}
Filters:
{/* Toggle All Button */}
{/* Individual Status Filters */}
{Object.entries(statusConfig).map(([status, config]) => {
const isActive = statusFilters[status];
const projectCount = projects.filter(
(p) => p.project_status === status && p.coordinates
).length;
return (
);
})}{" "}
{" "}
{/* Status Panel - Bottom Left */}
{markers.length > 0 && (
Filters:
{/* Toggle All Button */}
{/* Individual Status Filters */}
{Object.entries(statusConfig).map(([status, config]) => {
const isActive = statusFilters[status];
const projectCount = projects.filter(
(p) => p.project_status === status && p.coordinates
).length;
return (
);
})}
)}{" "}
{/* Full Screen Map */}
{markers.length === 0 ? (
No projects with coordinates
Projects need coordinates to appear on the map. Add coordinates
when creating or editing projects.
) : (
)}{" "}
);
}
export default function ProjectsMapPage() {
return (