diff --git a/apps/dispatch/app/_components/map/ContextMenu.tsx b/apps/dispatch/app/_components/map/ContextMenu.tsx
index 544aa5a0..2948f566 100644
--- a/apps/dispatch/app/_components/map/ContextMenu.tsx
+++ b/apps/dispatch/app/_components/map/ContextMenu.tsx
@@ -4,6 +4,7 @@ import { useDispatchConnectionStore } from "_store/dispatch/connectionStore";
import { useMapStore } from "_store/mapStore";
import { usePannelStore } from "_store/pannelStore";
import { MapPin, MapPinned, Radius, Ruler, Search, RulerDimensionLine, Scan } from "lucide-react";
+import { getOsmAddress } from "querys/osm";
import { useEffect, useState } from "react";
import toast from "react-hot-toast";
import { Popup, useMap } from "react-leaflet";
@@ -100,43 +101,8 @@ export const ContextMenu = () => {
data-tip={einsatzBtnText}
style={{ transform: "translateX(-50%)" }}
onClick={async () => {
- const address = await fetch(
- `https://nominatim.openstreetmap.org/reverse?lat=${contextMenu.lat}&lon=${contextMenu.lng}&format=json`,
- );
- const data = (await address.json()) as {
- address?: {
- ISO3166_2_lvl4?: string;
- country?: string;
- country_code?: string;
- county?: string;
- house_number?: string;
- municipality?: string;
- postcode?: string;
- road?: string;
- state?: string;
- city?: string;
- town?: string;
- };
- display_name?: string;
- importance?: number;
- lat?: string;
- licence?: string;
- lon?: string;
- name?: string;
- osm_id?: number;
- osm_type?: string;
- place_id?: number;
- place_rank?: number;
- type?: string;
- };
- const addressObj = data.address ?? {};
+ const { parsed } = await getOsmAddress(contextMenu.lat, contextMenu.lng);
const objects = await addOSMobjects();
- const exactAddress = objects.find((object) => {
- return (
- object.tags["addr:street"] == addressObj.road &&
- object.tags["addr:housenumber"]?.includes(addressObj.house_number ?? "")
- );
- });
const closestToContext = objects.reduce((prev, curr) => {
const prevLat = prev.nodes?.[0]?.lat ?? 0;
const prevLon = prev.nodes?.[0]?.lon ?? 0;
@@ -160,11 +126,7 @@ export const ContextMenu = () => {
);
setMissionFormValues({
- addressLat: contextMenu.lat,
- addressLng: contextMenu.lng,
- addressCity: addressObj.city || addressObj.town || "",
- addressStreet: `${addressObj.road || "keine Straße"}, ${addressObj.house_number || "keine HN"}`,
- addressZip: addressObj.postcode || "",
+ ...parsed,
state: "draft",
addressOSMways: [closestToContext],
});
diff --git a/apps/dispatch/app/_components/map/MissionMarkers.tsx b/apps/dispatch/app/_components/map/MissionMarkers.tsx
index 8b402115..bed7c4f2 100644
--- a/apps/dispatch/app/_components/map/MissionMarkers.tsx
+++ b/apps/dispatch/app/_components/map/MissionMarkers.tsx
@@ -220,7 +220,8 @@ const MissionMarker = ({ mission }: { mission: Mission }) => {
const needsAction =
HPGValidationRequired(mission.missionStationIds, aircrafts, mission.hpgMissionString) &&
- mission.hpgValidationState !== "VALID";
+ mission.hpgValidationState !== "VALID" &&
+ mission.state === "draft";
useEffect(() => {
const handleClick = () => {
diff --git a/apps/dispatch/app/_components/map/_components/MissionMarkerTabs.tsx b/apps/dispatch/app/_components/map/_components/MissionMarkerTabs.tsx
index 4dfb7cf7..94b84a0e 100644
--- a/apps/dispatch/app/_components/map/_components/MissionMarkerTabs.tsx
+++ b/apps/dispatch/app/_components/map/_components/MissionMarkerTabs.tsx
@@ -35,6 +35,8 @@ import { deleteMissionAPI, editMissionAPI, sendMissionAPI } from "querys/mission
import { getConnectedAircraftsAPI } from "querys/aircrafts";
import { getStationsAPI } from "querys/stations";
import { useDispatchConnectionStore } from "_store/dispatch/connectionStore";
+import { HPGValidationRequired } from "helpers/hpgValidationRequired";
+import { getOsmAddress } from "querys/osm";
const Einsatzdetails = ({
mission,
@@ -53,6 +55,10 @@ const Einsatzdetails = ({
});
},
});
+ const { data: aircrafts } = useQuery({
+ queryKey: ["aircrafts"],
+ queryFn: getConnectedAircraftsAPI,
+ });
const sendAlertMutation = useMutation({
mutationKey: ["missions"],
mutationFn: (id: number) => sendMissionAPI(id, {}),
@@ -155,26 +161,36 @@ const Einsatzdetails = ({
-