#46 Einsatz-Marker & Chat/Report disabled wenn nicht verbunden

This commit is contained in:
PxlLoewe
2025-07-18 15:59:26 -07:00
parent 85fdfb3bb1
commit b0facf0941
7 changed files with 58 additions and 8 deletions

View File

@@ -9,6 +9,7 @@ import { useQuery } from "@tanstack/react-query";
import { getConnectedDispatcherAPI } from "_querys/dispatcher";
import { getConnectedAircraftsAPI } from "_querys/aircrafts";
import { useDispatchConnectionStore } from "_store/dispatch/connectionStore";
import { usePilotConnectionStore } from "_store/pilot/connectionStore";
export const Chat = () => {
const {
@@ -28,6 +29,7 @@ export const Chat = () => {
const [addTabValue, setAddTabValue] = useState<string>("default");
const [message, setMessage] = useState<string>("");
const dispatcherConnected = useDispatchConnectionStore((state) => state.status === "connected");
const pilotConnected = usePilotConnectionStore((state) => state.status === "connected");
const { data: dispatcher } = useQuery({
queryKey: ["dispatcher"],
@@ -51,6 +53,14 @@ export const Chat = () => {
(a) => a.userId !== session.data?.user.id && dispatcherConnected,
);
const btnActive = pilotConnected || dispatcherConnected;
useEffect(() => {
if (!btnActive) {
setChatOpen(false);
}
}, [btnActive, setChatOpen]);
return (
<div className={cn("dropdown dropdown-right dropdown-center", chatOpen && "dropdown-open")}>
<div className="indicator">
@@ -58,8 +68,12 @@ export const Chat = () => {
<span className="indicator-item status status-info animate-ping"></span>
)}
<button
className="btn btn-soft btn-sm btn-primary"
className={cn(
"btn btn-soft btn-sm cursor-default",
btnActive && "btn-primary cursor-pointer",
)}
onClick={() => {
if (!btnActive) return;
setReportTabOpen(false);
setChatOpen(!chatOpen);
if (selectedChat) {