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