satupeta-main/app/(modules)/maps/components/mapset-dialog/main/index.tsx
2026-02-23 12:21:05 +07:00

39 lines
1.2 KiB
TypeScript
Executable File

"use client";
import { useAtomValue } from "jotai";
import dynamic from "next/dynamic";
import { selectedMapsetAtom } from "../../../state/mapset-dialog";
import EmptyState from "./empty-state";
import { DatasetDetailSidebar } from "./dataset-detail-sidebar";
import { useEffect, useState } from "react";
import { mapConfig } from "@/shared/config/map-config";
const PreviewMap = dynamic(() => import("@/shared/components/preview-map"), {
ssr: false,
});
export default function MainDialog() {
const selectedMapset = useAtomValue(selectedMapsetAtom);
const [open, setOpen] = useState(false);
// Automatically open sidebar when mapset is selected
useEffect(() => {
if (!selectedMapset) {
setOpen(false);
}
}, [selectedMapset]);
return (
<>
{selectedMapset ? (
<div className="relative h-full">
<PreviewMap mapset={selectedMapset} isActiveControl={true} centerCustom={[mapConfig.center[0], mapConfig.center[1] + 1.5]} isShowPopup isShowLoadingTileLayer isShowLegend />
<DatasetDetailSidebar open={open} onCloseAction={() => setOpen(false)} onOpenAction={() => setOpen(true)} />
</div>
) : (
<EmptyState />
)}
</>
);
}