added mok mission
This commit is contained in:
@@ -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">
|
||||
|
||||
Reference in New Issue
Block a user