2025-08-04 17:45:44 +02:00
|
|
|
"use client";
|
2025-08-28 18:27:07 +02:00
|
|
|
import { MapIcon } from "lucide-react";
|
2025-08-04 17:45:44 +02:00
|
|
|
import dynamic from "next/dynamic";
|
2025-08-28 18:27:07 +02:00
|
|
|
import { useState } from "react";
|
2025-08-04 17:45:44 +02:00
|
|
|
import { Button } from "~/components/ui/button";
|
|
|
|
|
import {
|
2025-08-28 18:27:07 +02:00
|
|
|
Dialog,
|
|
|
|
|
DialogContent,
|
|
|
|
|
DialogDescription,
|
|
|
|
|
DialogHeader,
|
|
|
|
|
DialogTitle,
|
|
|
|
|
DialogTrigger,
|
2025-08-04 17:45:44 +02:00
|
|
|
} from "~/components/ui/dialog";
|
2025-08-28 18:27:07 +02:00
|
|
|
import { useTranslation } from "~/providers/I18nProvider";
|
2025-08-04 17:45:44 +02:00
|
|
|
|
2025-08-28 18:27:07 +02:00
|
|
|
const MapComp = dynamic(() => import("~/components/map/Map"), {
|
|
|
|
|
ssr: false,
|
2025-08-04 17:45:44 +02:00
|
|
|
});
|
|
|
|
|
|
|
|
|
|
export const MappaDialogFullscreen = ({
|
2025-08-28 18:27:07 +02:00
|
|
|
lat,
|
|
|
|
|
long,
|
2025-08-04 17:45:44 +02:00
|
|
|
}: {
|
2025-08-28 18:27:07 +02:00
|
|
|
lat: string | null;
|
|
|
|
|
long: string | null;
|
2025-08-04 17:45:44 +02:00
|
|
|
}) => {
|
2025-08-28 18:27:07 +02:00
|
|
|
const { t } = useTranslation();
|
|
|
|
|
const [open, setOpen] = useState(false);
|
|
|
|
|
return (
|
|
|
|
|
<Dialog open={open} onOpenChange={setOpen}>
|
|
|
|
|
<DialogTrigger asChild>
|
|
|
|
|
<Button className="w-auto grow" disabled={!lat || !long}>
|
|
|
|
|
<MapIcon className="size-5" /> {t.mappa}
|
|
|
|
|
</Button>
|
|
|
|
|
</DialogTrigger>
|
|
|
|
|
<DialogContent className="h-full w-screen max-w-[100vw] p-0 sm:max-h-[60vh] sm:max-w-2xl [&_#dialog-close]:bg-white [&_#dialog-close]:opacity-100 [&_#dialog-close>svg]:size-8">
|
|
|
|
|
<DialogHeader className="hidden h-0">
|
|
|
|
|
<DialogTitle className="sr-only">{t.mappa}</DialogTitle>
|
|
|
|
|
<DialogDescription className="sr-only">{t.mappa}</DialogDescription>
|
|
|
|
|
</DialogHeader>
|
|
|
|
|
<div className="size-full">
|
|
|
|
|
{lat && long && (
|
|
|
|
|
<>
|
|
|
|
|
<MapComp
|
|
|
|
|
posix={{
|
|
|
|
|
pos: {
|
|
|
|
|
lat: Number.parseFloat(lat),
|
|
|
|
|
lng: Number.parseFloat(long),
|
|
|
|
|
},
|
|
|
|
|
popupTxt:
|
|
|
|
|
"Posizione esatta fornita dopo la richiesta di contatto",
|
|
|
|
|
}}
|
|
|
|
|
markerType="home"
|
|
|
|
|
scrollWheelZoom
|
|
|
|
|
width="100%"
|
|
|
|
|
height="100%"
|
|
|
|
|
zoom={14}
|
|
|
|
|
/>
|
|
|
|
|
</>
|
|
|
|
|
)}
|
|
|
|
|
</div>
|
|
|
|
|
</DialogContent>
|
|
|
|
|
</Dialog>
|
|
|
|
|
);
|
2025-08-04 17:45:44 +02:00
|
|
|
};
|