import { useState } from "react"; import { useCameraFeedContext } from "../../../../app/context/CameraFeedContext"; import type { DecodeReading } from "../../../../types/types"; import { useSightingEntryAndExit } from "../../hooks/useSightingEntryAndExit"; import PlatePatchModal from "./platePatchModal/PlatePatchModal"; const SightingEntryTable = () => { const { state } = useCameraFeedContext(); const [isPlatePatchModalOpen, setIsPlatePatchModalOpen] = useState(false); const [currentPatch, setCurrentPatch] = useState(null); const cameraFeedID = state.cameraFeedID; const { entryQuery } = useSightingEntryAndExit(cameraFeedID); const isLoading = entryQuery?.isFetching; const readings = entryQuery?.data?.decodes; const handleRowClick = (reading: DecodeReading) => { setCurrentPatch(reading); setIsPlatePatchModalOpen(true); }; if (isLoading) return Loading Sighting data…; return ( <>
{/* Desktop Table */}
{readings?.map((reading: DecodeReading) => ( handleRowClick(reading)} > ))}
VRM Bay ID Seen Count First Seen Last Seen
{reading?.vrm} {reading?.laneID} {reading?.seenCount} {reading?.firstSeenTimeHumane} {reading?.lastSeenTimeHumane}
{/* Mobile */}
{readings?.map((reading: DecodeReading) => (
handleRowClick(reading)} >
{reading?.vrm} Bay {reading?.laneID}
Seen Count: {reading?.seenCount}
First Seen: {reading?.firstSeenTimeHumane}
Last Seen: {reading?.lastSeenTimeHumane}
))}
setIsPlatePatchModalOpen(false)} currentPatch={currentPatch} direction={"entry"} /> ); }; export default SightingEntryTable;