Merge branch 'main' into 3-fix-aircraftmarkers-missionmarkers

This commit is contained in:
PxlLoewe
2025-04-29 21:42:10 -07:00
12 changed files with 70 additions and 91 deletions

View File

@@ -1,22 +1,15 @@
"use client";
import { ChatBubbleIcon, PaperPlaneIcon } from "@radix-ui/react-icons";
import { useChatStore } from "_store/chatStore";
import { useLeftMenuStore } from "_store/leftMenuStore";
import { useSession } from "next-auth/react";
import { Fragment, useEffect, useRef, useState } from "react";
import { Dispatcher } from "dispatch/_components/navbar/_components/action";
import { cn } from "helpers/cn";
export const getDispatcher = async () => {
const res = await fetch(`
${process.env.NEXT_PUBLIC_DISPATCH_SERVER_URL}/dispatcher`);
const data = await res.json();
return data as Dispatcher[];
};
import { getDispatcher } from "pilot/_components/navbar/action";
export const Chat = () => {
const {
setReportTabOpen,
reportTabOpen,
chatOpen,
setChatOpen,
sendMessage,
@@ -26,7 +19,7 @@ export const Chat = () => {
selectedChat,
setSelectedChat,
setChatNotification,
} = useChatStore();
} = useLeftMenuStore();
const [sending, setSending] = useState(false);
const session = useSession();
const [addTabValue, setAddTabValue] = useState<string>("");
@@ -37,7 +30,7 @@ export const Chat = () => {
useEffect(() => {
if (!session.data?.user.id) return;
setOwnId(session.data.user.id);
}, [session]);
}, [session, setOwnId]);
useEffect(() => {
const fetchDispatcher = async () => {
@@ -56,7 +49,7 @@ export const Chat = () => {
timeout.current = setInterval(() => {
fetchDispatcher();
}, 1000000);
}, 1000);
fetchDispatcher();
return () => {
@@ -93,6 +86,9 @@ export const Chat = () => {
className="dropdown-content card bg-base-200 w-150 shadow-md z-[1100] ml-2 border-1 border-primary"
>
<div className="card-body">
<h2 className="inline-flex items-center gap-2 text-lg font-bold mb-2">
<ChatBubbleIcon /> Chat
</h2>
<div className="join">
<select
className="select select-sm w-full"
@@ -207,7 +203,7 @@ export const Chat = () => {
}}
disabled={sending}
role="button"
onSubmit={(e) => false}
onSubmit={() => false} // prevent submit event for react hook form
>
{sending ? (
<span className="loading loading-spinner loading-sm"></span>

View File

@@ -5,7 +5,9 @@ import { useEffect, useRef, useState } from "react";
import { Dispatcher } from "dispatch/_components/navbar/_components/action";
import { cn } from "helpers/cn";
import { useChatStore } from "_store/chatStore";
import { getDispatcher } from "dispatch/_components/left/Chat";
import {} from "dispatch/_components/left/Chat";
import { serverApi } from "helpers/axios";
import { getDispatcher } from "pilot/_components/navbar/action";
export const Report = () => {
const { setChatOpen, setReportTabOpen, reportTabOpen, setOwnId } =
@@ -43,10 +45,9 @@ export const Report = () => {
if (timeout.current) {
clearInterval(timeout.current);
timeout.current = null;
console.log("cleared");
}
};
}, [selectedPlayer]);
}, [selectedPlayer, session.data?.user.id]);
return (
<div
@@ -72,6 +73,9 @@ export const Report = () => {
className="dropdown-content card bg-base-200 w-150 shadow-md z-[1100] ml-2 border-1 border-error"
>
<div className="card-body">
<h2 className="inline-flex items-center gap-2 text-lg font-bold mb-2">
<ExclamationTriangleIcon /> Report senden
</h2>
<div className="join">
<select
className="select select-sm w-full"
@@ -107,15 +111,12 @@ export const Report = () => {
e.preventDefault();
if (message.length < 1 || !selectedPlayer) return;
setSending(true);
fetch("/api/dispatch/report", {
serverApi("/report", {
method: "POST",
headers: {
"Content-Type": "application/json",
data: {
message,
to: selectedPlayer,
},
body: JSON.stringify({
userId: selectedPlayer,
message: message,
}),
})
.then(() => {
setMessage("");