added mok mission
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
{
|
||||
"tabWidth": 2,
|
||||
"useTabs": true,
|
||||
"printWidth": 80
|
||||
"printWidth": 80,
|
||||
"singleQuote": false
|
||||
}
|
||||
|
||||
@@ -19,7 +19,6 @@ interface SelectProps<T extends FieldValues>
|
||||
name: Path<T>;
|
||||
form: UseFormReturn<T> | any;
|
||||
formOptions?: RegisterOptions<T>;
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
}
|
||||
|
||||
const customStyles: StylesConfig<any, false> = {
|
||||
|
||||
@@ -3,15 +3,43 @@ import { MissionOptionalDefaults } from "@repo/db/zod";
|
||||
import { create } from "zustand";
|
||||
|
||||
interface MissionStore {
|
||||
missions: MissionOptionalDefaults[];
|
||||
setMissions: (missions: MissionOptionalDefaults[]) => void;
|
||||
missions: Mission[];
|
||||
setMissions: (missions: Mission[]) => void;
|
||||
getMissions: () => Promise<undefined>;
|
||||
createMission: (mission: MissionOptionalDefaults) => Promise<Mission>;
|
||||
setMission: (mission: MissionOptionalDefaults) => void;
|
||||
setMission: (mission: Mission) => void;
|
||||
}
|
||||
|
||||
export const useMissionsStore = create<MissionStore>((set) => ({
|
||||
missions: [],
|
||||
missions: [
|
||||
{
|
||||
id: 1,
|
||||
type: "primär",
|
||||
state: "draft",
|
||||
addressCity: "Berlin",
|
||||
addressStreet: "Alexanderplatz",
|
||||
addressZip: "10178",
|
||||
addressOSMways: [],
|
||||
missionAdditionalInfo: "",
|
||||
addressLat: 52.520008,
|
||||
addressLng: 13.404954,
|
||||
missionKeywordName: "Test",
|
||||
missionKeywordCategory: "Test",
|
||||
missionKeywordAbbreviation: "Test",
|
||||
missionPatientInfo: "Test",
|
||||
missionStationIds: [],
|
||||
createdUserId: "1",
|
||||
missionLog: [],
|
||||
missionStationUserIds: [],
|
||||
hpgLocationLat: 52.520008,
|
||||
hpgLocationLng: 13.404954,
|
||||
hpgAmbulanceState: null,
|
||||
hpgFireEngineState: null,
|
||||
hpgPoliceState: null,
|
||||
createdAt: new Date(),
|
||||
updatedAt: new Date(),
|
||||
},
|
||||
],
|
||||
setMissions: (missions) => set({ missions }),
|
||||
createMission: async (mission) => {
|
||||
const res = await fetch("/api/mission", {
|
||||
|
||||
@@ -1,12 +1,17 @@
|
||||
"use client";
|
||||
import { MissionOptionalDefaults } from "@repo/db/zod";
|
||||
import { create } from "zustand";
|
||||
|
||||
interface PannelStore {
|
||||
isOpen: boolean;
|
||||
setOpen: (isOpen: boolean) => void;
|
||||
missionFormValues?: Partial<MissionOptionalDefaults>;
|
||||
setMissionFormValues: (values: Partial<MissionOptionalDefaults>) => void;
|
||||
}
|
||||
|
||||
export const usePannelStore = create<PannelStore>((set) => ({
|
||||
isOpen: true, // DEBUG, REMOVE LATER FOR PROD
|
||||
setOpen: (isOpen) => set({ isOpen }),
|
||||
missionFormValues: undefined,
|
||||
setMissionFormValues: (values) => set({ missionFormValues: values }),
|
||||
}));
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { useMapStore } from "_store/mapStore";
|
||||
import { usePannelStore } from "_store/pannelStore";
|
||||
import { MapPinned, Search } from "lucide-react";
|
||||
import { useEffect } from "react";
|
||||
import { Popup, useMap } from "react-leaflet";
|
||||
@@ -7,7 +8,9 @@ export const ContextMenu = () => {
|
||||
const map = useMap();
|
||||
const { contextMenu, setContextMenu, setSearchElements, setSearchPopup } =
|
||||
useMapStore();
|
||||
|
||||
const setMissionFormValues = usePannelStore(
|
||||
(state) => state.setMissionFormValues,
|
||||
);
|
||||
useEffect(() => {
|
||||
const handleContextMenu = (e: any) => {
|
||||
setContextMenu({ lat: e.latlng.lat, lng: e.latlng.lng });
|
||||
@@ -49,12 +52,12 @@ export const ContextMenu = () => {
|
||||
country: string;
|
||||
country_code: string;
|
||||
county: string;
|
||||
hamlet: string;
|
||||
house_number: string;
|
||||
municipality: string;
|
||||
postcode: string;
|
||||
road: string;
|
||||
state: string;
|
||||
town: string;
|
||||
city: string;
|
||||
};
|
||||
display_name: string;
|
||||
importance: number;
|
||||
@@ -68,6 +71,14 @@ export const ContextMenu = () => {
|
||||
place_rank: number;
|
||||
type: string;
|
||||
};
|
||||
setMissionFormValues({
|
||||
addressLat: contextMenu.lat,
|
||||
addressLng: contextMenu.lng,
|
||||
addressCity: data.address.city,
|
||||
addressStreet: `${data.address.road}, ${data.address.house_number}`,
|
||||
addressZip: data.address.postcode,
|
||||
state: "draft",
|
||||
});
|
||||
}}
|
||||
>
|
||||
<MapPinned size={20} />
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
"use client";
|
||||
import React, { useEffect, useState } from "react";
|
||||
import { useForm, Controller } from "react-hook-form";
|
||||
import React, { use, useEffect, useState } from "react";
|
||||
import { useForm } from "react-hook-form";
|
||||
import { zodResolver } from "@hookform/resolvers/zod";
|
||||
import { z } from "zod";
|
||||
import { BellRing, BookmarkPlus, Trash2 } from "lucide-react";
|
||||
import { Select } from "_components/Select";
|
||||
import { Keyword, Station } from "@repo/db";
|
||||
@@ -11,26 +10,34 @@ import {
|
||||
MissionOptionalDefaults,
|
||||
MissionOptionalDefaultsSchema,
|
||||
} from "@repo/db/zod";
|
||||
|
||||
const clearBtn = () => {
|
||||
return (
|
||||
<button className="btn btn-sm btn-circle btn-info">
|
||||
<Trash2 className="w-4 h-4" />
|
||||
</button>
|
||||
);
|
||||
};
|
||||
import { usePannelStore } from "_store/pannelStore";
|
||||
|
||||
export const MissionForm = () => {
|
||||
const form = useForm<MissionOptionalDefaults>({
|
||||
resolver: zodResolver(MissionOptionalDefaultsSchema),
|
||||
defaultValues: {},
|
||||
});
|
||||
const { missionFormValues, setMissionFormValues } = usePannelStore(
|
||||
(state) => state,
|
||||
);
|
||||
|
||||
/* const formValues = form.watch();
|
||||
useEffect(() => {
|
||||
if (formValues) {
|
||||
setMissionFormValues(formValues);
|
||||
}
|
||||
}, [formValues, setMissionFormValues]); */
|
||||
|
||||
useEffect(() => {
|
||||
if (missionFormValues) {
|
||||
form.reset(missionFormValues);
|
||||
}
|
||||
}, [missionFormValues, form]);
|
||||
|
||||
const [stations, setStations] = useState<Station[]>([]);
|
||||
const [keywords, setKeywords] = useState<Keyword[]>([]);
|
||||
|
||||
useEffect(() => {
|
||||
console.log("useEffect");
|
||||
getKeywords().then((data) => {
|
||||
setKeywords(data);
|
||||
});
|
||||
@@ -48,7 +55,7 @@ export const MissionForm = () => {
|
||||
console.log(form.formState.errors);
|
||||
|
||||
return (
|
||||
<form onSubmit={form.handleSubmit(onSubmit)} className="space-y-4">
|
||||
<form className="space-y-4">
|
||||
{/* Koorinaten Section */}
|
||||
<div className="form-control">
|
||||
<h2 className="text-lg font-bold mb-2">Koordinaten</h2>
|
||||
@@ -185,7 +192,13 @@ export const MissionForm = () => {
|
||||
|
||||
<div className="form-control min-h-[140px] max-w-[320px]">
|
||||
<div className="flex gap-2">
|
||||
<button type="submit" className="btn btn-warning">
|
||||
<button
|
||||
type="submit"
|
||||
className="btn btn-warning"
|
||||
onClick={form.handleSubmit(() => {
|
||||
console.log("Alarmieren");
|
||||
})}
|
||||
>
|
||||
<BellRing className="h-4 w-4" /> Alarmieren
|
||||
</button>
|
||||
<button type="submit" className="btn btn-primary btn-block">
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
"use client";
|
||||
import { zodResolver } from "@hookform/resolvers/zod";
|
||||
import { KeywordOptionalDefaultsSchema } from "@repo/db/zod";
|
||||
import { set, useForm } from "react-hook-form";
|
||||
import { useForm } from "react-hook-form";
|
||||
import { z } from "zod";
|
||||
import { BosUse, Country, KEYWORD_CATEGORY, Keyword } from "@repo/db";
|
||||
import { FileText, LocateIcon, PlaneIcon } from "lucide-react";
|
||||
import { KEYWORD_CATEGORY, Keyword } from "@repo/db";
|
||||
import { FileText } from "lucide-react";
|
||||
import { Input } from "../../../../_components/ui/Input";
|
||||
import { useState } from "react";
|
||||
import { deleteKeyword, upsertKeyword } from "../action";
|
||||
@@ -73,7 +73,7 @@ export const KeywordForm = ({ keyword }: { keyword?: Keyword }) => {
|
||||
<ListInput
|
||||
className="input-sm"
|
||||
control={form.control}
|
||||
name="hpgMissionsType"
|
||||
name="hpgMissionTypes"
|
||||
label="HPG Missions presets"
|
||||
/>
|
||||
</div>
|
||||
|
||||
Binary file not shown.
@@ -4,6 +4,9 @@
|
||||
"description": "VAR Databse package",
|
||||
"main": "generated/client/index.js",
|
||||
"types": "generated/client/index.d.ts",
|
||||
"prisma": {
|
||||
"schema": "prisma/schema"
|
||||
},
|
||||
"scripts": {
|
||||
"generate": "npx prisma generate && npx prisma generate zod",
|
||||
"migrate": "npx prisma migrate dev",
|
||||
|
||||
@@ -8,16 +8,17 @@ model Mission {
|
||||
addressCity String?
|
||||
addressZip String?
|
||||
addressOSMways Json[] @default([])
|
||||
missionCategory String?
|
||||
missionKeyword String?
|
||||
missionSummary String?
|
||||
missionKeywordCategory String?
|
||||
missionKeywordName String?
|
||||
missionKeywordAbbreviation String?
|
||||
missionPatientInfo String
|
||||
missionAdditionalInfo String
|
||||
missionStationIds String[]
|
||||
missionStationIds String[] @default([])
|
||||
missionStationUserIds String[] @default([])
|
||||
missionLog Json[] @default([])
|
||||
hpgAmbulanceState HpgState? @default(ready)
|
||||
hpgFireEngineState HpgState? @default(ready)
|
||||
hpgPoliceState HpgState? @default(ready)
|
||||
hpgAmbulanceState HpgState?
|
||||
hpgFireEngineState HpgState?
|
||||
hpgPoliceState HpgState?
|
||||
hpgLocationLat Float? @default(0)
|
||||
hpgLocationLng Float? @default(0)
|
||||
createdAt DateTime @default(now())
|
||||
@@ -25,15 +26,24 @@ model Mission {
|
||||
createdUserId String
|
||||
|
||||
// relations:
|
||||
/**
|
||||
* /**
|
||||
* /**
|
||||
* /**
|
||||
* /**
|
||||
* /**
|
||||
* createdUser User @relation(fields: [createdUserId], references: [id])
|
||||
*/
|
||||
|
||||
CreatedUser User @relation(fields: [createdUserId], references: [id])
|
||||
|
||||
MissionsOnStations MissionsOnStations[]
|
||||
MissionOnStationUsers MissionOnStationUsers[]
|
||||
}
|
||||
|
||||
model MissionOnStationUsers {
|
||||
userId String
|
||||
missionId Int
|
||||
stationId Int
|
||||
|
||||
// relations:
|
||||
User User @relation(fields: [userId], references: [id])
|
||||
Mission Mission @relation(fields: [missionId], references: [id])
|
||||
Station Station @relation(fields: [stationId], references: [id])
|
||||
|
||||
@@unique([userId, missionId, stationId])
|
||||
}
|
||||
|
||||
model MissionsOnStations {
|
||||
|
||||
@@ -34,4 +34,5 @@ model Station {
|
||||
hideRangeRings Boolean
|
||||
|
||||
MissionsOnStations MissionsOnStations[]
|
||||
MissionOnStationUsers MissionOnStationUsers[]
|
||||
}
|
||||
|
||||
@@ -46,6 +46,8 @@ model User {
|
||||
/**
|
||||
* Missions Mission[]
|
||||
*/
|
||||
Mission Mission[]
|
||||
MissionOnStationUsers MissionOnStationUsers[]
|
||||
|
||||
@@map(name: "users")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user