"use client";
import { useRef, useState, useCallback } from "react";
import dynamic from "next/dynamic";
import { BasemapSwitcher, type BasemapId } from "./basemap-switcher";
import { SearchBar, type FeatureHit, type UatHit } from "./search-bar";
import {
FeatureInfoPanel,
type ClickedFeatureLite,
} from "./feature-info-panel";
import type { MapViewerHandle } from "./map-viewer";
const MapViewer = dynamic(
() => import("./map-viewer").then((m) => ({ default: m.MapViewer })),
{
ssr: false,
loading: () => (
),
},
);
export function GeoportalV2() {
const mapRef = useRef(null);
const [basemap, setBasemap] = useState("liberty");
const [clicked, setClicked] = useState(null);
const handleFeatureClick = useCallback((f: ClickedFeatureLite | null) => {
setClicked(f);
}, []);
const handleUatSelect = useCallback((uat: UatHit) => {
// Search response doesn't carry bbox/centroid yet — leave panel + let user pan.
// Future: enrich search response with uat bounding box, then flyTo.
console.info("UAT selected:", uat.siruta, uat.name);
}, []);
const handleFeatureSelect = useCallback((f: FeatureHit) => {
// Show panel directly (feature ID is known)
setClicked({
id: f.id,
siruta: "",
cadastralRef: f.cadastralRef,
layerId: f.layerId,
areaValue: f.areaValue,
});
}, []);
return (
{/* Top-left: search */}
{/* Top-right: basemap + panel */}
{clicked && (
setClicked(null)}
/>
)}
{/* Bottom-right: cutover badge (visible until full rollout) */}
gis.ac · v2
);
}