2025-09-16 11:07:35 +01:00
|
|
|
import type { SightingType } from "../../types/types";
|
|
|
|
|
import NumberPlate from "../PlateStack/NumberPlate";
|
|
|
|
|
import SightingModal from "../SightingModal/SightingModal";
|
|
|
|
|
import InfoBar from "../SightingsWidget/InfoBar";
|
|
|
|
|
import { useState } from "react";
|
2025-09-19 11:22:09 +01:00
|
|
|
import HotListImg from "/Hotlist_Hit.svg";
|
2025-09-16 11:07:35 +01:00
|
|
|
|
|
|
|
|
type AlertItemProps = {
|
|
|
|
|
item: SightingType;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const AlertItem = ({ item }: AlertItemProps) => {
|
|
|
|
|
const [isModalOpen, setIsModalOpen] = useState(false);
|
|
|
|
|
const motionAway = (item?.motion ?? "").toUpperCase() === "AWAY";
|
2025-09-21 20:10:05 +01:00
|
|
|
const isNPEDHit = item?.metadata?.npedJSON?.status_code === 404;
|
2025-09-19 11:22:09 +01:00
|
|
|
const isHotListHit = item?.metadata?.hotlistMatches?.Hotlist0 === true;
|
2025-09-16 11:07:35 +01:00
|
|
|
|
|
|
|
|
const handleClick = () => {
|
|
|
|
|
setIsModalOpen(true);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const closeModal = () => {
|
|
|
|
|
setIsModalOpen(false);
|
|
|
|
|
};
|
|
|
|
|
return (
|
|
|
|
|
<>
|
|
|
|
|
<InfoBar obj={item} />
|
|
|
|
|
<div
|
|
|
|
|
className=" flex flex-row p-4 border border-gray-400 rounded-lg items-center w-full mx-auto justify-between"
|
|
|
|
|
onClick={handleClick}
|
|
|
|
|
>
|
2025-09-19 11:22:09 +01:00
|
|
|
{isHotListHit && (
|
|
|
|
|
<img
|
|
|
|
|
src={HotListImg}
|
|
|
|
|
alt="hotlistHit"
|
|
|
|
|
className="h-20 object-contain rounded-md"
|
|
|
|
|
/>
|
|
|
|
|
)}
|
2025-09-21 20:10:05 +01:00
|
|
|
{isNPEDHit && (
|
|
|
|
|
<img
|
|
|
|
|
src={HotListImg}
|
|
|
|
|
alt="hotlistHit"
|
|
|
|
|
className="h-20 object-contain rounded-md"
|
|
|
|
|
/>
|
|
|
|
|
)}
|
2025-09-16 11:07:35 +01:00
|
|
|
<div className="flex flex-col">
|
|
|
|
|
<small>MAKE: {item.make}</small>
|
|
|
|
|
<small>MODEL: {item.model}</small>
|
|
|
|
|
<small>COLOUR: {item.color}</small>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<NumberPlate vrm={item.vrm} motion={motionAway} />
|
|
|
|
|
</div>
|
|
|
|
|
<SightingModal
|
|
|
|
|
isSightingModalOpen={isModalOpen}
|
|
|
|
|
handleClose={closeModal}
|
|
|
|
|
sighting={item}
|
|
|
|
|
/>
|
|
|
|
|
</>
|
|
|
|
|
);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
export default AlertItem;
|