#46 Einsatz-Marker & Chat/Report disabled wenn nicht verbunden
This commit is contained in:
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user