2025-12-23 10:37:02 +00:00
|
|
|
import { useState } from "react";
|
2025-12-22 12:19:00 +00:00
|
|
|
import CardHeader from "../../../../components/CardHeader";
|
|
|
|
|
import Card from "../../../../components/ui/Card";
|
|
|
|
|
import type { SightingType } from "../../../../utils/types";
|
|
|
|
|
import SightingItem from "./SightingItem";
|
2025-12-23 10:37:02 +00:00
|
|
|
import SightingItemModal from "./sightingItemModal/SightingItemModal";
|
2025-12-22 12:19:00 +00:00
|
|
|
|
|
|
|
|
type SightingStackProps = {
|
|
|
|
|
sightings: SightingType[];
|
|
|
|
|
};
|
|
|
|
|
const SightingStack = ({ sightings }: SightingStackProps) => {
|
2025-12-23 10:37:02 +00:00
|
|
|
const [isSightingModalOpen, setIsSightingModalOpen] = useState(false);
|
|
|
|
|
const [currentSighting, setCurrentSighting] = useState<SightingType | null>(null);
|
|
|
|
|
const handleOpenModal = (sighting: SightingType | null) => {
|
|
|
|
|
if (!sighting) return;
|
|
|
|
|
setCurrentSighting(sighting);
|
|
|
|
|
setIsSightingModalOpen(true);
|
|
|
|
|
};
|
|
|
|
|
|
2025-12-22 12:19:00 +00:00
|
|
|
return (
|
2025-12-23 10:37:02 +00:00
|
|
|
<>
|
2026-01-12 15:38:01 +00:00
|
|
|
<Card className="p-4 w-full h-[65vh] overflow-y-auto">
|
2025-12-23 10:37:02 +00:00
|
|
|
<CardHeader title="Live Sightings" />
|
|
|
|
|
<div className="md:h-[65%]">
|
|
|
|
|
{sightings.map((sighting) => (
|
|
|
|
|
<SightingItem key={sighting.ref} sighting={sighting} onOpenModal={() => handleOpenModal(sighting)} />
|
|
|
|
|
))}
|
|
|
|
|
</div>
|
|
|
|
|
</Card>
|
|
|
|
|
<SightingItemModal
|
|
|
|
|
isOpen={isSightingModalOpen}
|
|
|
|
|
close={() => setIsSightingModalOpen(false)}
|
|
|
|
|
sighting={currentSighting}
|
|
|
|
|
/>
|
|
|
|
|
</>
|
2025-12-22 12:19:00 +00:00
|
|
|
);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
export default SightingStack;
|