From 30a4f6488f6d2459219b33d286a2b9f88ff9dc34 Mon Sep 17 00:00:00 2001 From: PxlLoewe <72106766+PxlLoewe@users.noreply.github.com> Date: Tue, 8 Jul 2025 19:23:49 -0700 Subject: [PATCH] E Nr, Karte Zentrieren, Statin-select --- apps/dispatch-server/routes/mission.ts | 2 +- .../dispatch/_components/StationSelect.tsx | 21 ++++++------------- .../_components/pannel/MissionForm.tsx | 2 +- .../app/_components/map/AircraftMarker.tsx | 10 +++++++-- .../map/_components/AircraftMarkerTabs.tsx | 1 + 5 files changed, 17 insertions(+), 19 deletions(-) diff --git a/apps/dispatch-server/routes/mission.ts b/apps/dispatch-server/routes/mission.ts index a58a9d94..b08f56ca 100644 --- a/apps/dispatch-server/routes/mission.ts +++ b/apps/dispatch-server/routes/mission.ts @@ -63,7 +63,7 @@ router.put("/", async (req, res) => { const month = String(date.getMonth() + 1).padStart(2, "0"); // Months are zero-based const day = String(date.getDate()).padStart(2, "0"); - const publicId = `__${year}${month}${day}${missionsTodayCount ? missionsTodayCount + 1 : 1}`; + const publicId = `ENr.: ${year}${month}${day}${missionsTodayCount ? missionsTodayCount + 1 : 1}`; const newMission = await prisma.mission.create({ data: { ...req.body, diff --git a/apps/dispatch/app/(app)/dispatch/_components/StationSelect.tsx b/apps/dispatch/app/(app)/dispatch/_components/StationSelect.tsx index b03f406e..dec6274a 100644 --- a/apps/dispatch/app/(app)/dispatch/_components/StationSelect.tsx +++ b/apps/dispatch/app/(app)/dispatch/_components/StationSelect.tsx @@ -50,9 +50,9 @@ export function StationsSelect({ useEffect(() => { setValue([ ...(selectedStations || []).map((id) => String(id)), - ...(vehicleStates.hpgAmbulanceState !== HpgState.NOT_REQUESTED ? ["RTW"] : []), - ...(vehicleStates.hpgFireEngineState !== HpgState.NOT_REQUESTED ? ["FW"] : []), - ...(vehicleStates.hpgPoliceState !== HpgState.NOT_REQUESTED ? ["POL"] : []), + ...(vehicleStates.hpgAmbulanceState !== HpgState.NOT_REQUESTED || undefined ? ["RTW"] : []), + ...(vehicleStates.hpgFireEngineState !== HpgState.NOT_REQUESTED || undefined ? ["FW"] : []), + ...(vehicleStates.hpgPoliceState !== HpgState.NOT_REQUESTED || undefined ? ["POL"] : []), ]); // eslint-disable-next-line react-hooks/exhaustive-deps }, [selectedStations, vehicleStates]); @@ -110,18 +110,9 @@ export function StationsSelect({ onChange={(v) => { setValue(v); if (!isMulti) return onChange?.(v); - const hpgAmbulanceState = - vehicleStates.hpgAmbulanceState === "NOT_REQUESTED" && v.includes("RTW") - ? HpgState.DISPATCHED - : vehicleStates.hpgAmbulanceState; - const hpgFireEngineState = - vehicleStates.hpgFireEngineState === "NOT_REQUESTED" && v.includes("FW") - ? HpgState.DISPATCHED - : vehicleStates.hpgFireEngineState; - const hpgPoliceState = - vehicleStates.hpgPoliceState === "NOT_REQUESTED" && v.includes("POL") - ? HpgState.DISPATCHED - : vehicleStates.hpgPoliceState; + const hpgAmbulanceState = v.includes("RTW") ? HpgState.DISPATCHED : HpgState.NOT_REQUESTED; + const hpgFireEngineState = v.includes("FW") ? HpgState.DISPATCHED : HpgState.NOT_REQUESTED; + const hpgPoliceState = v.includes("POL") ? HpgState.DISPATCHED : HpgState.NOT_REQUESTED; onChange?.({ selectedStationIds: v diff --git a/apps/dispatch/app/(app)/dispatch/_components/pannel/MissionForm.tsx b/apps/dispatch/app/(app)/dispatch/_components/pannel/MissionForm.tsx index cfb0f371..3ae8f2e0 100644 --- a/apps/dispatch/app/(app)/dispatch/_components/pannel/MissionForm.tsx +++ b/apps/dispatch/app/(app)/dispatch/_components/pannel/MissionForm.tsx @@ -3,7 +3,6 @@ import React, { useEffect } from "react"; import { useForm } from "react-hook-form"; import { zodResolver } from "@hookform/resolvers/zod"; import { BellRing, BookmarkPlus, Radio } from "lucide-react"; -import { Select } from "_components/Select"; import { KEYWORD_CATEGORY, Mission, missionType, Prisma } from "@repo/db"; import { JsonValueType, @@ -254,6 +253,7 @@ export const MissionForm = () => { isMulti selectedStations={form.watch("missionStationIds")} onChange={(v) => { + console.log("Selected stations:", v); form.setValue("missionStationIds", v.selectedStationIds); form.setValue("hpgAmbulanceState", v.hpgAmbulanceState); form.setValue("hpgFireEngineState", v.hpgFireEngineState); diff --git a/apps/dispatch/app/_components/map/AircraftMarker.tsx b/apps/dispatch/app/_components/map/AircraftMarker.tsx index b89bfe67..23ac1ef2 100644 --- a/apps/dispatch/app/_components/map/AircraftMarker.tsx +++ b/apps/dispatch/app/_components/map/AircraftMarker.tsx @@ -71,7 +71,7 @@ const AircraftPopupContent = ({ } }, [currentTab, aircraft, mission]); - const setOpenAircraftMarker = useMapStore((state) => state.setOpenAircraftMarker); + const { setOpenAircraftMarker, setMap } = useMapStore((state) => state); const { anchor } = useSmartPopup(); return ( <> @@ -133,7 +133,13 @@ const AircraftPopupContent = ({ style={{ backgroundColor: `${FMS_STATUS_COLORS[aircraft.fmsStatus]}`, }} - /* onClick={() => handleTabChange("fms")} */ + onClick={() => { + if (!aircraft.posLat || !aircraft.posLng) return; + setMap({ + center: [aircraft.posLat, aircraft.posLng], + zoom: 14, + }); + }} > diff --git a/apps/dispatch/app/_components/map/_components/AircraftMarkerTabs.tsx b/apps/dispatch/app/_components/map/_components/AircraftMarkerTabs.tsx index edc6e7f2..39c6e55b 100644 --- a/apps/dispatch/app/_components/map/_components/AircraftMarkerTabs.tsx +++ b/apps/dispatch/app/_components/map/_components/AircraftMarkerTabs.tsx @@ -442,6 +442,7 @@ const SDSTab = ({