- refactored fetching NPED Category
This commit is contained in:
@@ -9,7 +9,7 @@ import { useCameraBlackboard } from "../../hooks/useCameraBlackboard";
|
||||
import NPED_CAT_A from "/NPED_Cat_A.svg";
|
||||
import NPED_CAT_B from "/NPED_Cat_B.svg";
|
||||
import NPED_CAT_C from "/NPED_Cat_C.svg";
|
||||
import { checkIsHotListHit } from "../../utils/utils";
|
||||
import { checkIsHotListHit, getNPEDCategory } from "../../utils/utils";
|
||||
|
||||
type AlertItemProps = {
|
||||
item: SightingType;
|
||||
@@ -24,9 +24,10 @@ const AlertItem = ({ item }: AlertItemProps) => {
|
||||
const motionAway = (item?.motion ?? "").toUpperCase() === "AWAY";
|
||||
|
||||
const isHotListHit = checkIsHotListHit(item);
|
||||
const isNPEDHitA = item?.metadata?.npedJSON?.["NPED CATEGORY"] === "A";
|
||||
const isNPEDHitB = item?.metadata?.npedJSON?.["NPED CATEGORY"] === "B";
|
||||
const isNPEDHitC = item?.metadata?.npedJSON?.["NPED CATEGORY"] === "C";
|
||||
const cat = getNPEDCategory(item);
|
||||
const isNPEDHitA = cat === "A";
|
||||
const isNPEDHitB = cat === "B";
|
||||
const isNPEDHitC = cat === "C";
|
||||
|
||||
const handleClick = () => {
|
||||
setIsModalOpen(true);
|
||||
|
||||
@@ -10,7 +10,7 @@ import HotListImg from "/Hotlist_Hit.svg";
|
||||
import NPED_CAT_A from "/NPED_Cat_A.svg";
|
||||
import NPED_CAT_B from "/NPED_Cat_B.svg";
|
||||
import NPED_CAT_C from "/NPED_Cat_C.svg";
|
||||
import { checkIsHotListHit } from "../../utils/utils";
|
||||
import { checkIsHotListHit, getNPEDCategory } from "../../utils/utils";
|
||||
|
||||
type SightingModalProps = {
|
||||
isSightingModalOpen: boolean;
|
||||
@@ -68,9 +68,10 @@ const SightingModal = ({
|
||||
|
||||
const motionAway = (sighting?.motion ?? "").toUpperCase() === "AWAY";
|
||||
const isHotListHit = checkIsHotListHit(sighting);
|
||||
const isNPEDHitA = sighting?.metadata?.npedJSON?.["NPED CATEGORY"] === "A";
|
||||
const isNPEDHitB = sighting?.metadata?.npedJSON?.["NPED CATEGORY"] === "B";
|
||||
const isNPEDHitC = sighting?.metadata?.npedJSON?.["NPED CATEGORY"] === "C";
|
||||
const cat = getNPEDCategory(sighting);
|
||||
const isNPEDHitA = cat === "A";
|
||||
const isNPEDHitB = cat === "B";
|
||||
const isNPEDHitC = cat === "C";
|
||||
|
||||
return (
|
||||
<>
|
||||
|
||||
@@ -5,8 +5,6 @@ type InfoBarprops = {
|
||||
obj: SightingType;
|
||||
};
|
||||
const InfoBar = ({ obj }: InfoBarprops) => {
|
||||
const isNPEDHitD = obj?.metadata?.npedJSON?.["NPED CATEGORY"] === "D";
|
||||
|
||||
return (
|
||||
<div className="flex items-center gap-3 text-xs bg-neutral-900 px-2 py-1 rounded justify-between">
|
||||
<div className="flex items-center gap-3 text-xs">
|
||||
@@ -18,13 +16,7 @@ const InfoBar = ({ obj }: InfoBarprops) => {
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className="min-w-14 opacity-80 ">
|
||||
{isNPEDHitD ? (
|
||||
<span className="text-amber-500 font-semibold">NPED HIT CAT D</span>
|
||||
) : (
|
||||
""
|
||||
)}
|
||||
</div>
|
||||
<div className="min-w-14 opacity-80 "></div>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
@@ -141,5 +141,5 @@ export const checkIsHotListHit = (sigthing: SightingType | null) => {
|
||||
}
|
||||
};
|
||||
|
||||
export const getNPEDCategory = (r?: SightingType) =>
|
||||
export const getNPEDCategory = (r?: SightingType | null) =>
|
||||
r?.metadata?.npedJSON?.["NPED CATEGORY"] as "A" | "B" | "C" | undefined;
|
||||
|
||||
Reference in New Issue
Block a user