diff --git a/src/components/HistoryList/AlertItem.tsx b/src/components/HistoryList/AlertItem.tsx index cc75e13..71cabdb 100644 --- a/src/components/HistoryList/AlertItem.tsx +++ b/src/components/HistoryList/AlertItem.tsx @@ -43,9 +43,7 @@ const AlertItem = ({ item }: AlertItemProps) => { path: "alertHistory", }); const oldArray = res?.result; - const updatedArray = oldArray?.filter( - (item: SightingType) => item?.ref !== deletedItem?.ref - ); + const updatedArray = oldArray?.filter((item: SightingType) => item?.ref !== deletedItem?.ref); mutation.mutate({ operation: "INSERT", @@ -58,45 +56,14 @@ const AlertItem = ({ item }: AlertItemProps) => {
-
- {isHotListHit && ( - hotlistHit - )} - {isNPEDHitA && ( - NPEDHITicon - )} - {isNPEDHitB && ( - NPEDHITicon - )} - {isNPEDHitC && ( - NPEDHITicon - )} - -
- MAKE: {item.make} - MODEL: {item.model} - COLOUR: {item.color} +
+ {isHotListHit && hotlistHit} + {isNPEDHitA && NPEDHITicon} + {isNPEDHitB && NPEDHITicon} + {isNPEDHitC && NPEDHITicon} + -
void; }; -const SightingModal = ({ - isSightingModalOpen, - handleClose, - sighting, - onDelete, -}: SightingModalProps) => { +const SightingModal = ({ isSightingModalOpen, handleClose, sighting, onDelete }: SightingModalProps) => { const { dispatch } = useAlertHitContext(); const { query, mutation } = useCameraBlackboard(); + const hotlistName = getHotlistName(sighting?.metadata?.hotlistMatches); + const handleAcknowledgeButton = () => { try { if (!sighting) { @@ -78,9 +75,7 @@ const SightingModal = ({
-

- Sighting Details -

+

Sighting Details

{onDelete ? ( @@ -121,41 +116,19 @@ const SightingModal = ({
- plate patch + plate patch + {hotlistName && ( +
+

Hotlist

+

{hotlistName ? hotlistName[0] : "-"}

+
+ )}
- {isHotListHit && ( - hotlistHit - )} - {isNPEDHitA && ( - hotlistHit - )} - {isNPEDHitB && ( - hotlistHit - )} - {isNPEDHitC && ( - hotlistHit - )} + {isHotListHit && hotlistHit} + {isNPEDHitA && hotlistHit} + {isNPEDHitB && hotlistHit} + {isNPEDHitC && hotlistHit}
diff --git a/src/utils/utils.ts b/src/utils/utils.ts index 4e031ec..65a4fc8 100644 --- a/src/utils/utils.ts +++ b/src/utils/utils.ts @@ -1,7 +1,7 @@ import switchSound from "../assets/sounds/ui/switch.mp3"; import popup from "../assets/sounds/ui/popup_open.mp3"; import notification from "../assets/sounds/ui/notification.mp3"; -import type { SightingType } from "../types/types"; +import type { HotlistMatches, SightingType } from "../types/types"; export function getSoundFileURL(name: string) { const sounds: Record = { @@ -79,8 +79,7 @@ export const formatNumberPlate = (plate: string) => { return formattedPlate; }; -export const BLANK_IMG = - "data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw=="; +export const BLANK_IMG = "data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw=="; export function capitalize(s?: string) { return s ? s.charAt(0).toUpperCase() + s.slice(1) : ""; @@ -120,12 +119,7 @@ export function drawRects( rects.forEach((r) => { const [x, y, rw, rh] = r; ctx.beginPath(); - ctx.rect( - Math.round(x * w), - Math.round(y * h), - Math.round(rw * w), - Math.round(rh * h) - ); + ctx.rect(Math.round(x * w), Math.round(y * h), Math.round(rw * w), Math.round(rh * h)); ctx.stroke(); }); } @@ -133,13 +127,18 @@ export function drawRects( export const checkIsHotListHit = (sigthing: SightingType | null) => { if (!sigthing) return; if (sigthing?.metadata?.hotlistMatches) { - const isHotListHit = Object.values( - sigthing?.metadata?.hotlistMatches - ).includes(true); + const isHotListHit = Object.values(sigthing?.metadata?.hotlistMatches).includes(true); return isHotListHit; } }; +export function getHotlistName(obj: HotlistMatches | undefined) { + if (!obj || Object.values(obj).includes(false)) return; + + const keys = Object.keys(obj); + return keys; +} + export const getNPEDCategory = (r?: SightingType | null) => r?.metadata?.npedJSON?.["NPED CATEGORY"] as "A" | "B" | "C" | undefined;