Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 | 1x | import React, { useEffect } from "react";
import { X, MapPin } from "lucide-react";
import type { AccountSession } from "@/hooks/useSessions";
import { SessionRow } from "./SessionUI";
interface SessionMarkerModalProps {
sessions: AccountSession[];
onClose: () => void;
onRevoke?: (id: string) => Promise<void>;
}
/** Inline modal listing every session clustered at a clicked globe pin
* (markers dedupe by location, so a pin can represent more than one session). */
export const SessionMarkerModal: React.FC<SessionMarkerModalProps> = ({
sessions,
onClose,
onRevoke,
}) => {
useEffect(() => {
const handler = (e: KeyboardEvent) => {
if (e.key === "Escape") onClose();
};
window.addEventListener("keydown", handler);
return () => window.removeEventListener("keydown", handler);
}, [onClose]);
if (sessions.length === 0) return null;
const place = [sessions[0].location.city, sessions[0].location.country]
.filter(Boolean)
.join(", ");
return (
<div
className="fixed inset-0 z-50 flex items-center justify-center bg-black/40 px-4"
onClick={onClose}
>
<div
role="dialog"
aria-modal="true"
className="w-full max-w-md rounded-xl border border-gray-200 dark:border-gray-700 bg-white dark:bg-gray-800 shadow-xl overflow-hidden"
onClick={(e) => e.stopPropagation()}
>
<div className="px-5 py-3.5 border-b border-gray-100 dark:border-gray-700 flex items-center justify-between gap-3">
<div className="flex items-center gap-2 min-w-0">
<MapPin className="size-4 text-gray-400 shrink-0" />
<h3 className="text-sm font-semibold text-gray-700 dark:text-gray-300 truncate">
{place || "Unknown location"}
</h3>
<span className="text-xs text-gray-400 dark:text-gray-500 shrink-0">
{sessions.length} session{sessions.length === 1 ? "" : "s"}
</span>
</div>
<button
onClick={onClose}
className="text-gray-400 hover:text-gray-600 dark:hover:text-gray-300 shrink-0"
aria-label="Close"
>
<X className="size-4" />
</button>
</div>
<div className="px-5 py-1 max-h-[60vh] overflow-y-auto">
{sessions.map((session) => (
<SessionRow key={session.id} session={session} onRevoke={onRevoke} />
))}
</div>
</div>
</div>
);
};
export default SessionMarkerModal;
|