From 5ce26e5334868a26f96be393219517ec455ff33e Mon Sep 17 00:00:00 2001 From: PxlLoewe <72106766+PxlLoewe@users.noreply.github.com> Date: Sat, 10 May 2025 20:01:15 -0700 Subject: [PATCH] fixed overlapping OSMlayer --- apps/dispatch/app/api/position-log/route.ts | 14 ++++++++++---- .../_components/map/SearchElements.tsx | 17 ++++++++++++++--- grafana/grafana.db | Bin 1122304 -> 1122304 bytes 3 files changed, 24 insertions(+), 7 deletions(-) diff --git a/apps/dispatch/app/api/position-log/route.ts b/apps/dispatch/app/api/position-log/route.ts index 7951c8a9..47d7eb4c 100644 --- a/apps/dispatch/app/api/position-log/route.ts +++ b/apps/dispatch/app/api/position-log/route.ts @@ -16,10 +16,6 @@ export const PUT = async (req: Request) => { ); } - const positionLog = await prisma.positionLog.create({ - data: position, - }); - const activeAircraft = await prisma.connectedAircraft.findFirst({ where: { userId: session.user.id, @@ -33,6 +29,16 @@ export const PUT = async (req: Request) => { }, }); + if (!activeAircraft) { + return Response.json( + { message: "No active aircraft found" }, + { status: 400 }, + ); + } + const positionLog = await prisma.positionLog.create({ + data: position, + }); + await prisma.connectedAircraft.update({ where: { id: activeAircraft?.id, diff --git a/apps/dispatch/app/dispatch/_components/map/SearchElements.tsx b/apps/dispatch/app/dispatch/_components/map/SearchElements.tsx index fb8068ca..7fec4a48 100644 --- a/apps/dispatch/app/dispatch/_components/map/SearchElements.tsx +++ b/apps/dispatch/app/dispatch/_components/map/SearchElements.tsx @@ -41,13 +41,14 @@ export const SearchElements = () => { element: (typeof searchElements)[1]; isActive?: boolean; }) => { - const ref = useRef(null); + const ref = useRef(null); useEffect(() => { if (ref.current) { ref.current.on("click", () => { - const center = ref.current.getBounds().getCenter(); - if (searchPopup?.elementId !== element.wayID) { + console.log("click"); + const center = ref.current?.getBounds().getCenter(); + if (center && searchPopup?.elementId !== element.wayID) { setSearchPopup({ lat: center.lat, lng: center.lng, @@ -130,6 +131,16 @@ export const SearchElements = () => { ); })} {searchElements.map((element, i) => { + if ( + missions.data?.some( + (mission) => + (mission.addressOSMways as (OSMWay | null)[]) + .filter((e): e is OSMWay => e !== null) + .some((e) => e.wayID === element.wayID) && + openMissionMarker.some((m) => m.id === mission.id), + ) + ) + return null; return ( owWr8$g)I=F)#;A=6-*nm3UsL!$kVJqHkTZa-wtWgWl*RL#4Uk&#(oJIeyDzw`Oo8yGm*co_MY z@%!@nvej-EaNy2mV<~3gV3^+M#;wO^s%vN%Vqj!tVrgY)88!W&54WTkNK64Hre|hq eU}kJ)V$}Y|jT?x0fS4DE`GA;z`x`d_k(&TWHAhPT delta 255 zcmZoT;L>owWr8$g$V3@u#*mE(-*nkj<;0ksIj1*n<`kYTV8zAJT&~w%uEz+(OhC*G z#4JF}3dC$c%)Y%`k3)=+M=?WA;UEJ8gQ6t|%k+MG4l$MtnJe$6Z`S8fVm+QA7ZSDo zmOjU6epXc(W?RPT5A``D+7H=t05RwGL-t(O0W3h(yjvL=nFY49Ea3V(pP#Lkfs=I_ zBmXjfUtV9+zZB8XATeT3VSJSQ#2bO+VPQ-F!- hnOT~d8CjT`x4&`Y24Wr{<^^ItAm-ox#!W!vCIG9fOalM_