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