Fixed mission form

This commit is contained in:
PxlLoewe
2025-06-01 15:02:38 -07:00
parent 9826f970d8
commit fdb62aa4d2
5 changed files with 29 additions and 27 deletions

View File

@@ -121,7 +121,7 @@ export const ContextMenu = () => {
const nodeWay: [number, number][] = []; 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]), nodeWay.push([node.lat, node.lon]),
); );

View File

@@ -88,9 +88,9 @@ export const MissionForm = () => {
createdUserId: session.data?.user.id, createdUserId: session.data?.user.id,
type: "primär", type: "primär",
addressOSMways: [], addressOSMways: [],
missionKeywordAbbreviation: "", missionKeywordAbbreviation: null as any,
missionKeywordCategory: "", missionKeywordCategory: null as any,
missionKeywordName: "", missionKeywordName: null as any,
hpgFireEngineState: null, hpgFireEngineState: null,
hpgAmbulanceState: null, hpgAmbulanceState: null,
hpgPoliceState: null, hpgPoliceState: null,
@@ -108,6 +108,8 @@ export const MissionForm = () => {
}); });
const { missionFormValues, setOpen } = usePannelStore((state) => state); const { missionFormValues, setOpen } = usePannelStore((state) => state);
console.log("MissionForm rendered", form.formState.errors);
const validationRequired = HPGValidationRequired( const validationRequired = HPGValidationRequired(
form.watch("missionStationIds"), form.watch("missionStationIds"),
aircrafts, aircrafts,
@@ -164,6 +166,7 @@ export const MissionForm = () => {
id: Number(editingMissionId), id: Number(editingMissionId),
mission: { mission: {
...(mission as unknown as Prisma.MissionCreateInput), ...(mission as unknown as Prisma.MissionCreateInput),
state: undefined, // state should not be updated
missionAdditionalInfo: missionAdditionalInfo:
!mission.missionAdditionalInfo.length && hpgSzenario !mission.missionAdditionalInfo.length && hpgSzenario
? `HPG-Szenario: ${hpgSzenario}` ? `HPG-Szenario: ${hpgSzenario}`
@@ -261,8 +264,8 @@ export const MissionForm = () => {
className="select select-primary select-bordered w-full mb-4" className="select select-primary select-bordered w-full mb-4"
onChange={(e) => { onChange={(e) => {
form.setValue("type", e.target.value as missionType); form.setValue("type", e.target.value as missionType);
form.setValue("missionKeywordName", null); form.setValue("missionKeywordName", KEYWORD_CATEGORY.AB_ATMUNG);
form.setValue("missionKeywordAbbreviation", null); form.setValue("missionKeywordAbbreviation", "");
form.setValue("hpgMissionString", null); form.setValue("hpgMissionString", null);
}} }}
> >
@@ -275,9 +278,15 @@ export const MissionForm = () => {
{...form.register("missionKeywordCategory")} {...form.register("missionKeywordCategory")}
className="select select-primary select-bordered w-full mb-4" className="select select-primary select-bordered w-full mb-4"
onChange={(e) => { onChange={(e) => {
const firstKeyword = keywords?.find(
(k) => k.category === form.watch("missionKeywordCategory"),
);
form.setValue("missionKeywordCategory", e.target.value as string); form.setValue("missionKeywordCategory", e.target.value as string);
form.setValue("missionKeywordName", null); form.setValue("missionKeywordName", firstKeyword?.name || (null as any));
form.setValue("missionKeywordAbbreviation", ""); form.setValue(
"missionKeywordAbbreviation",
firstKeyword?.abreviation || (null as any),
);
form.setValue("hpgMissionString", ""); form.setValue("hpgMissionString", "");
}} }}
defaultValue="" defaultValue=""
@@ -296,8 +305,8 @@ export const MissionForm = () => {
className="select select-primary select-bordered w-full mb-4" className="select select-primary select-bordered w-full mb-4"
onChange={(e) => { onChange={(e) => {
const keyword = keywords?.find((k) => k.abreviation === e.target.value); const keyword = keywords?.find((k) => k.abreviation === e.target.value);
form.setValue("missionKeywordName", keyword?.name || null); form.setValue("missionKeywordName", keyword?.name || (null as any));
form.setValue("missionKeywordAbbreviation", keyword?.abreviation || null); form.setValue("missionKeywordAbbreviation", keyword?.abreviation || (null as any));
form.setValue("hpgMissionString", "default"); form.setValue("hpgMissionString", "default");
}} }}
defaultValue="default" defaultValue="default"

View File

@@ -1,3 +1,5 @@
import React from "react";
export const EmailFooter = () => { export const EmailFooter = () => {
return ( return (
<td style={{ textAlign: "center", paddingTop: "20px" }}> <td style={{ textAlign: "center", paddingTop: "20px" }}>

View File

@@ -66,12 +66,7 @@ export const PasswortReset = () => {
<path d="M2.5 3A1.5 1.5 0 0 0 1 4.5v.793c.026.009.051.02.076.032L7.674 8.51c.206.1.446.1.652 0l6.598-3.185A.755.755 0 0 1 15 5.293V4.5A1.5 1.5 0 0 0 13.5 3h-11Z" /> <path d="M2.5 3A1.5 1.5 0 0 0 1 4.5v.793c.026.009.051.02.076.032L7.674 8.51c.206.1.446.1.652 0l6.598-3.185A.755.755 0 0 1 15 5.293V4.5A1.5 1.5 0 0 0 13.5 3h-11Z" />
<path d="M15 6.954 8.978 9.86a2.25 2.25 0 0 1-1.956 0L1 6.954V11.5A1.5 1.5 0 0 0 2.5 13h11a1.5 1.5 0 0 0 1.5-1.5V6.954Z" /> <path d="M15 6.954 8.978 9.86a2.25 2.25 0 0 1-1.956 0L1 6.954V11.5A1.5 1.5 0 0 0 2.5 13h11a1.5 1.5 0 0 0 1.5-1.5V6.954Z" />
</svg> </svg>
<input <input type="text" className="grow" {...form.register("email")} placeholder="Email" />
type="text"
className="grow"
{...form.register("email")}
placeholder="Email"
/>
</label> </label>
<p className="text-error"> <p className="text-error">
{typeof form.formState.errors.email?.message === "string" {typeof form.formState.errors.email?.message === "string"
@@ -80,15 +75,11 @@ export const PasswortReset = () => {
</p> </p>
<span className="text-sm font-medium flex justify-end"> <span className="text-sm font-medium flex justify-end">
<Link href="/passwort-reset" className="link link-accent link-hover "> <Link href="/passwort-reset" className="link link-accent link-hover ">
Passwort vergessen? neues Passwort anfordern
</Link> </Link>
</span> </span>
<div className="card-actions mt-6"> <div className="card-actions mt-6">
<Button <Button disabled={isLoading} isLoading={isLoading} className="btn btn-primary btn-block">
disabled={isLoading}
isLoading={isLoading}
className="btn btn-primary btn-block"
>
Login Login
</Button> </Button>
</div> </div>

View File

@@ -8,12 +8,12 @@ model Mission {
addressStreet String? addressStreet String?
addressCity String? addressCity String?
addressZip String? addressZip String?
addressAdditionalInfo String? addressAdditionalInfo String? @default("")
addressMissionLocation String? addressMissionLocation String? @default("")
addressOSMways Json[] @default([]) addressOSMways Json[] @default([])
missionKeywordCategory String? missionKeywordCategory String
missionKeywordName String? missionKeywordName String
missionKeywordAbbreviation String? missionKeywordAbbreviation String
missionPatientInfo String missionPatientInfo String
missionAdditionalInfo String missionAdditionalInfo String
missionStationIds Int[] @default([]) missionStationIds Int[] @default([])