#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) {
|
||||
|
||||
@@ -10,6 +10,8 @@ import { useQuery } from "@tanstack/react-query";
|
||||
import { getConnectedDispatcherAPI } from "_querys/dispatcher";
|
||||
import { sendReportAPI } from "_querys/report";
|
||||
import { getConnectedAircraftsAPI } from "_querys/aircrafts";
|
||||
import { useDispatchConnectionStore } from "_store/dispatch/connectionStore";
|
||||
import { usePilotConnectionStore } from "_store/pilot/connectionStore";
|
||||
|
||||
export const Report = () => {
|
||||
const { setChatOpen, setReportTabOpen, reportTabOpen, setOwnId } = useLeftMenuStore();
|
||||
@@ -18,6 +20,9 @@ export const Report = () => {
|
||||
const [selectedPlayer, setSelectedPlayer] = useState<string>("default");
|
||||
const [message, setMessage] = useState<string>("");
|
||||
|
||||
const dispatcherConnected = useDispatchConnectionStore((state) => state.status === "connected");
|
||||
const pilotConnected = usePilotConnectionStore((state) => state.status === "connected");
|
||||
|
||||
useEffect(() => {
|
||||
if (!session.data?.user.id) return;
|
||||
setOwnId(session.data.user.id);
|
||||
@@ -36,6 +41,13 @@ export const Report = () => {
|
||||
|
||||
const filteredDispatcher = dispatcher?.filter((d) => d.userId !== session.data?.user.id);
|
||||
const filteredAircrafts = aircrafts?.filter((a) => a.userId !== session.data?.user.id);
|
||||
const btnActive = pilotConnected || dispatcherConnected;
|
||||
|
||||
useEffect(() => {
|
||||
if (!btnActive) {
|
||||
setReportTabOpen(false);
|
||||
}
|
||||
}, [btnActive, setReportTabOpen]);
|
||||
|
||||
return (
|
||||
<div
|
||||
@@ -43,8 +55,12 @@ export const Report = () => {
|
||||
>
|
||||
<div className="indicator">
|
||||
<button
|
||||
className="btn btn-soft btn-sm btn-error"
|
||||
className={cn(
|
||||
"btn btn-soft btn-sm cursor-default",
|
||||
btnActive && "cursor-pointer btn-error",
|
||||
)}
|
||||
onClick={() => {
|
||||
if (!btnActive) return;
|
||||
setChatOpen(false);
|
||||
setReportTabOpen(!reportTabOpen);
|
||||
}}
|
||||
|
||||
Reference in New Issue
Block a user