From fdb62aa4d259a6623260c34fba70bf9c6f9d9967 Mon Sep 17 00:00:00 2001 From: PxlLoewe <72106766+PxlLoewe@users.noreply.github.com> Date: Sun, 1 Jun 2025 15:02:38 -0700 Subject: [PATCH] Fixed mission form --- .../app/_components/map/ContextMenu.tsx | 2 +- .../_components/pannel/MissionForm.tsx | 27 ++++++++++++------- .../modules/mail-templates/EmailFooter.tsx | 2 ++ .../_components/PasswortReset.tsx | 15 +++-------- .../database/prisma/schema/mission.prisma | 10 +++---- 5 files changed, 29 insertions(+), 27 deletions(-) diff --git a/apps/dispatch/app/_components/map/ContextMenu.tsx b/apps/dispatch/app/_components/map/ContextMenu.tsx index 2c506145..9f7fc800 100644 --- a/apps/dispatch/app/_components/map/ContextMenu.tsx +++ b/apps/dispatch/app/_components/map/ContextMenu.tsx @@ -121,7 +121,7 @@ export const ContextMenu = () => { const nodeWay: [number, number][] = []; - closestToContext.nodes.map((node: { lat: number; lon: number }) => + closestToContext.nodes?.foreach((node: { lat: number; lon: number }) => nodeWay.push([node.lat, node.lon]), ); diff --git a/apps/dispatch/app/dispatch/_components/pannel/MissionForm.tsx b/apps/dispatch/app/dispatch/_components/pannel/MissionForm.tsx index 716a0284..97cd9b30 100644 --- a/apps/dispatch/app/dispatch/_components/pannel/MissionForm.tsx +++ b/apps/dispatch/app/dispatch/_components/pannel/MissionForm.tsx @@ -88,9 +88,9 @@ export const MissionForm = () => { createdUserId: session.data?.user.id, type: "primär", addressOSMways: [], - missionKeywordAbbreviation: "", - missionKeywordCategory: "", - missionKeywordName: "", + missionKeywordAbbreviation: null as any, + missionKeywordCategory: null as any, + missionKeywordName: null as any, hpgFireEngineState: null, hpgAmbulanceState: null, hpgPoliceState: null, @@ -108,6 +108,8 @@ export const MissionForm = () => { }); const { missionFormValues, setOpen } = usePannelStore((state) => state); + console.log("MissionForm rendered", form.formState.errors); + const validationRequired = HPGValidationRequired( form.watch("missionStationIds"), aircrafts, @@ -164,6 +166,7 @@ export const MissionForm = () => { id: Number(editingMissionId), mission: { ...(mission as unknown as Prisma.MissionCreateInput), + state: undefined, // state should not be updated missionAdditionalInfo: !mission.missionAdditionalInfo.length && hpgSzenario ? `HPG-Szenario: ${hpgSzenario}` @@ -261,8 +264,8 @@ export const MissionForm = () => { className="select select-primary select-bordered w-full mb-4" onChange={(e) => { form.setValue("type", e.target.value as missionType); - form.setValue("missionKeywordName", null); - form.setValue("missionKeywordAbbreviation", null); + form.setValue("missionKeywordName", KEYWORD_CATEGORY.AB_ATMUNG); + form.setValue("missionKeywordAbbreviation", ""); form.setValue("hpgMissionString", null); }} > @@ -275,9 +278,15 @@ export const MissionForm = () => { {...form.register("missionKeywordCategory")} className="select select-primary select-bordered w-full mb-4" onChange={(e) => { + const firstKeyword = keywords?.find( + (k) => k.category === form.watch("missionKeywordCategory"), + ); form.setValue("missionKeywordCategory", e.target.value as string); - form.setValue("missionKeywordName", null); - form.setValue("missionKeywordAbbreviation", ""); + form.setValue("missionKeywordName", firstKeyword?.name || (null as any)); + form.setValue( + "missionKeywordAbbreviation", + firstKeyword?.abreviation || (null as any), + ); form.setValue("hpgMissionString", ""); }} defaultValue="" @@ -296,8 +305,8 @@ export const MissionForm = () => { className="select select-primary select-bordered w-full mb-4" onChange={(e) => { const keyword = keywords?.find((k) => k.abreviation === e.target.value); - form.setValue("missionKeywordName", keyword?.name || null); - form.setValue("missionKeywordAbbreviation", keyword?.abreviation || null); + form.setValue("missionKeywordName", keyword?.name || (null as any)); + form.setValue("missionKeywordAbbreviation", keyword?.abreviation || (null as any)); form.setValue("hpgMissionString", "default"); }} defaultValue="default" diff --git a/apps/hub-server/modules/mail-templates/EmailFooter.tsx b/apps/hub-server/modules/mail-templates/EmailFooter.tsx index 06d00136..f453af7b 100644 --- a/apps/hub-server/modules/mail-templates/EmailFooter.tsx +++ b/apps/hub-server/modules/mail-templates/EmailFooter.tsx @@ -1,3 +1,5 @@ +import React from "react"; + export const EmailFooter = () => { return (
{typeof form.formState.errors.email?.message === "string" @@ -80,15 +75,11 @@ export const PasswortReset = () => {
- Passwort vergessen? + neues Passwort anfordern