Fixed docker deploments, moved files to _folders in dispatch app
This commit is contained in:
@@ -49,16 +49,10 @@ export const Login = () => {
|
||||
|
||||
<div className="form-control mt-6">
|
||||
<a
|
||||
href={`${process.env.NEXT_PUBLIC_HUB_URL}/oauth?service=${encodeURIComponent(process.env.NEXT_PUBLIC_SERVICE_ID || "")}&redirect_uri=${encodeURIComponent(`${process.env.NEXT_PUBLIC_PUBLIC_URL}/login`)}`}
|
||||
href={`${process.env.NEXT_PUBLIC_HUB_URL}/oauth?service=${encodeURIComponent(process.env.NEXT_PUBLIC_DISPATCH_SERVICE_ID || "")}&redirect_uri=${encodeURIComponent(`${process.env.NEXT_PUBLIC_DISPATCH_URL}/login`)}`}
|
||||
>
|
||||
<button
|
||||
className="btn btn-primary"
|
||||
name="loginBtn"
|
||||
disabled={isLoading}
|
||||
>
|
||||
{isLoading && (
|
||||
<span className="loading loading-spinner loading-sm"></span>
|
||||
)}
|
||||
<button className="btn btn-primary" name="loginBtn" disabled={isLoading}>
|
||||
{isLoading && <span className="loading loading-spinner loading-sm"></span>}
|
||||
Login{isLoading && "..."}
|
||||
</button>
|
||||
</a>
|
||||
|
||||
@@ -15,7 +15,7 @@ import {
|
||||
ZapOff,
|
||||
} from "lucide-react";
|
||||
import { useAudioStore } from "_store/audioStore";
|
||||
import { cn } from "helpers/cn";
|
||||
import { cn } from "_helpers/cn";
|
||||
import { ConnectionQuality } from "livekit-client";
|
||||
import { ROOMS } from "_data/livekitRooms";
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
"use client";
|
||||
|
||||
import { cn } from "helpers/cn";
|
||||
import { cn } from "_helpers/cn";
|
||||
import { useEffect, useState } from "react";
|
||||
|
||||
type MicrophoneLevelProps = {
|
||||
|
||||
@@ -1,20 +1,11 @@
|
||||
"use client";
|
||||
import {
|
||||
FieldValues,
|
||||
Path,
|
||||
RegisterOptions,
|
||||
UseFormReturn,
|
||||
} from "react-hook-form";
|
||||
import SelectTemplate, {
|
||||
Props as SelectTemplateProps,
|
||||
StylesConfig,
|
||||
} from "react-select";
|
||||
import { cn } from "helpers/cn";
|
||||
import { FieldValues, Path, RegisterOptions, UseFormReturn } from "react-hook-form";
|
||||
import SelectTemplate, { Props as SelectTemplateProps, StylesConfig } from "react-select";
|
||||
import { cn } from "_helpers/cn";
|
||||
import dynamic from "next/dynamic";
|
||||
import { CSSProperties } from "react";
|
||||
|
||||
interface SelectProps<T extends FieldValues>
|
||||
extends Omit<SelectTemplateProps, "form"> {
|
||||
interface SelectProps<T extends FieldValues> extends Omit<SelectTemplateProps, "form"> {
|
||||
label?: any;
|
||||
name: Path<T>;
|
||||
form: UseFormReturn<T> | any;
|
||||
@@ -69,9 +60,7 @@ const SelectCom = <T extends FieldValues>({
|
||||
}: SelectProps<T>) => {
|
||||
return (
|
||||
<div>
|
||||
<span className="label-text text-lg flex items-center gap-2">
|
||||
{label}
|
||||
</span>
|
||||
<span className="label-text text-lg flex items-center gap-2">{label}</span>
|
||||
<SelectTemplate
|
||||
onChange={(newValue: any) => {
|
||||
if (Array.isArray(newValue)) {
|
||||
@@ -88,12 +77,8 @@ const SelectCom = <T extends FieldValues>({
|
||||
}}
|
||||
value={
|
||||
(inputProps as any)?.isMulti
|
||||
? (inputProps as any).options?.filter((o: any) =>
|
||||
form.watch(name)?.includes(o.value),
|
||||
)
|
||||
: (inputProps as any).options?.find(
|
||||
(o: any) => o.value === form.watch(name),
|
||||
)
|
||||
? (inputProps as any).options?.filter((o: any) => form.watch(name)?.includes(o.value))
|
||||
: (inputProps as any).options?.find((o: any) => o.value === form.watch(name))
|
||||
}
|
||||
styles={customStyles as any}
|
||||
className={cn("w-full placeholder:text-neutral-600", className)}
|
||||
@@ -101,17 +86,13 @@ const SelectCom = <T extends FieldValues>({
|
||||
{...inputProps}
|
||||
/>
|
||||
{form.formState.errors[name]?.message && (
|
||||
<p className="text-error">
|
||||
{form.formState.errors[name].message as string}
|
||||
</p>
|
||||
<p className="text-error">{form.formState.errors[name].message as string}</p>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
const SelectWrapper = <T extends FieldValues>(props: SelectProps<T>) => (
|
||||
<SelectCom {...props} />
|
||||
);
|
||||
const SelectWrapper = <T extends FieldValues>(props: SelectProps<T>) => <SelectCom {...props} />;
|
||||
|
||||
export const Select = dynamic(() => Promise.resolve(SelectWrapper), {
|
||||
ssr: false,
|
||||
|
||||
@@ -4,7 +4,7 @@ import { GearIcon } from "@radix-ui/react-icons";
|
||||
import { SettingsIcon, Volume2 } from "lucide-react";
|
||||
import MicVolumeBar from "_components/MicVolumeIndication";
|
||||
import { useMutation, useQuery } from "@tanstack/react-query";
|
||||
import { editUserAPI, getUserAPI } from "querys/user";
|
||||
import { editUserAPI, getUserAPI } from "_querys/user";
|
||||
import { Prisma } from "@repo/db";
|
||||
import { useSession } from "next-auth/react";
|
||||
import { useAudioStore } from "_store/audioStore";
|
||||
|
||||
@@ -1,10 +1,5 @@
|
||||
import { cn } from "helpers/cn";
|
||||
import {
|
||||
RefAttributes,
|
||||
useCallback,
|
||||
useEffect,
|
||||
useImperativeHandle,
|
||||
} from "react";
|
||||
import { cn } from "_helpers/cn";
|
||||
import { RefAttributes, useCallback, useEffect, useImperativeHandle } from "react";
|
||||
import { createContext, Ref, useContext, useState } from "react";
|
||||
import { Popup, PopupProps, useMap } from "react-leaflet";
|
||||
import { Popup as LPopup } from "leaflet";
|
||||
@@ -113,9 +108,9 @@ export const SmartPopup = (
|
||||
const [showContent, setShowContent] = useState(false);
|
||||
const { smartPopupRef, id, className, wrapperClassName, options } = props;
|
||||
|
||||
const [anchor, setAnchor] = useState<
|
||||
"topleft" | "topright" | "bottomleft" | "bottomright"
|
||||
>("topleft");
|
||||
const [anchor, setAnchor] = useState<"topleft" | "topright" | "bottomleft" | "bottomright">(
|
||||
"topleft",
|
||||
);
|
||||
|
||||
const handleConflict = useCallback(() => {
|
||||
const newAnchor = calculateAnchor(id, "popup", options);
|
||||
@@ -160,9 +155,7 @@ export const SmartPopup = (
|
||||
anchor.includes("top") && "-translate-y-1/2",
|
||||
)}
|
||||
/>
|
||||
<PopupContext.Provider value={{ anchor: anchor }}>
|
||||
{props.children}
|
||||
</PopupContext.Provider>
|
||||
<PopupContext.Provider value={{ anchor: anchor }}>{props.children}</PopupContext.Provider>
|
||||
</div>
|
||||
</Popup>
|
||||
);
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { cn } from "helpers/cn";
|
||||
import { cn } from "_helpers/cn";
|
||||
|
||||
export const BaseNotification = ({
|
||||
children,
|
||||
|
||||
@@ -3,10 +3,10 @@ import { ChatBubbleIcon, PaperPlaneIcon } from "@radix-ui/react-icons";
|
||||
import { useLeftMenuStore } from "_store/leftMenuStore";
|
||||
import { useSession } from "next-auth/react";
|
||||
import { Fragment, useEffect, useState } from "react";
|
||||
import { cn } from "helpers/cn";
|
||||
import { cn } from "_helpers/cn";
|
||||
import { asPublicUser } from "@repo/db";
|
||||
import { useQuery } from "@tanstack/react-query";
|
||||
import { getConnectedUserAPI } from "querys/connected-user";
|
||||
import { getConnectedUserAPI } from "_querys/connected-user";
|
||||
|
||||
export const Chat = () => {
|
||||
const {
|
||||
@@ -88,8 +88,7 @@ export const Chat = () => {
|
||||
|
||||
{[
|
||||
...(connectedUser?.filter(
|
||||
(user, idx, arr) =>
|
||||
arr.findIndex((u) => u.userId === user.userId) === idx,
|
||||
(user, idx, arr) => arr.findIndex((u) => u.userId === user.userId) === idx,
|
||||
) || []),
|
||||
].map((user) => (
|
||||
<option key={user.userId} value={user.userId}>
|
||||
@@ -100,9 +99,7 @@ export const Chat = () => {
|
||||
<button
|
||||
className="btn btn-sm btn-soft btn-primary join-item"
|
||||
onClick={() => {
|
||||
const user = connectedUser?.find(
|
||||
(user) => user.userId === addTabValue,
|
||||
);
|
||||
const user = connectedUser?.find((user) => user.userId === addTabValue);
|
||||
if (!user) return;
|
||||
addChat(addTabValue, asPublicUser(user.publicUser).fullName);
|
||||
setSelectedChat(addTabValue);
|
||||
@@ -135,28 +132,21 @@ export const Chat = () => {
|
||||
/>
|
||||
<div className="tab-content bg-base-100 border-base-300 p-6">
|
||||
{chat.messages.map((chatMessage) => {
|
||||
const isSender =
|
||||
chatMessage.senderId === session.data?.user.id;
|
||||
const isSender = chatMessage.senderId === session.data?.user.id;
|
||||
return (
|
||||
<div
|
||||
key={chatMessage.id}
|
||||
className={`chat ${isSender ? "chat-end" : "chat-start"}`}
|
||||
>
|
||||
<p className="chat-footer opacity-50">
|
||||
{new Date(
|
||||
chatMessage.timestamp,
|
||||
).toLocaleTimeString()}
|
||||
{new Date(chatMessage.timestamp).toLocaleTimeString()}
|
||||
</p>
|
||||
<div className="chat-bubble">
|
||||
{chatMessage.text}
|
||||
</div>
|
||||
<div className="chat-bubble">{chatMessage.text}</div>
|
||||
</div>
|
||||
);
|
||||
})}
|
||||
{!chat.messages.length && (
|
||||
<p className="text-xs opacity-50">
|
||||
Noch keine Nachrichten
|
||||
</p>
|
||||
<p className="text-xs opacity-50">Noch keine Nachrichten</p>
|
||||
)}
|
||||
</div>
|
||||
</Fragment>
|
||||
|
||||
@@ -2,17 +2,16 @@
|
||||
import { ExclamationTriangleIcon, PaperPlaneIcon } from "@radix-ui/react-icons";
|
||||
import { useSession } from "next-auth/react";
|
||||
import { useEffect, useState } from "react";
|
||||
import { cn } from "helpers/cn";
|
||||
import { cn } from "_helpers/cn";
|
||||
import { toast } from "react-hot-toast";
|
||||
import { useLeftMenuStore } from "_store/leftMenuStore";
|
||||
import { asPublicUser } from "@repo/db";
|
||||
import { useQuery } from "@tanstack/react-query";
|
||||
import { getConnectedUserAPI } from "querys/connected-user";
|
||||
import { sendReportAPI } from "querys/report";
|
||||
import { getConnectedUserAPI } from "_querys/connected-user";
|
||||
import { sendReportAPI } from "_querys/report";
|
||||
|
||||
export const Report = () => {
|
||||
const { setChatOpen, setReportTabOpen, reportTabOpen, setOwnId } =
|
||||
useLeftMenuStore();
|
||||
const { setChatOpen, setReportTabOpen, reportTabOpen, setOwnId } = useLeftMenuStore();
|
||||
const [sending, setSending] = useState(false);
|
||||
const session = useSession();
|
||||
const [selectedPlayer, setSelectedPlayer] = useState<string>("default");
|
||||
@@ -34,12 +33,7 @@ export const Report = () => {
|
||||
});
|
||||
|
||||
return (
|
||||
<div
|
||||
className={cn(
|
||||
"dropdown dropdown-right",
|
||||
reportTabOpen && "dropdown-open",
|
||||
)}
|
||||
>
|
||||
<div className={cn("dropdown dropdown-right", reportTabOpen && "dropdown-open")}>
|
||||
<div className="indicator">
|
||||
<button
|
||||
className="btn btn-soft btn-sm btn-error"
|
||||
@@ -78,8 +72,7 @@ export const Report = () => {
|
||||
)}
|
||||
{[
|
||||
...(connectedUser?.filter(
|
||||
(user, idx, arr) =>
|
||||
arr.findIndex((u) => u.userId === user.userId) === idx,
|
||||
(user, idx, arr) => arr.findIndex((u) => u.userId === user.userId) === idx,
|
||||
) || []),
|
||||
].map((user) => (
|
||||
<option key={user.userId} value={user.userId}>
|
||||
|
||||
@@ -1,26 +1,10 @@
|
||||
import { Marker, useMap } from "react-leaflet";
|
||||
import { DivIcon, Marker as LMarker, Popup as LPopup } from "leaflet";
|
||||
import { useMapStore } from "_store/mapStore";
|
||||
import {
|
||||
Fragment,
|
||||
useCallback,
|
||||
useEffect,
|
||||
useRef,
|
||||
useState,
|
||||
useMemo,
|
||||
} from "react";
|
||||
import { cn } from "helpers/cn";
|
||||
import {
|
||||
ChevronsRightLeft,
|
||||
House,
|
||||
MessageSquareText,
|
||||
Minimize2,
|
||||
} from "lucide-react";
|
||||
import {
|
||||
SmartPopup,
|
||||
calculateAnchor,
|
||||
useSmartPopup,
|
||||
} from "_components/SmartPopup";
|
||||
import { Fragment, useCallback, useEffect, useRef, useState, useMemo } from "react";
|
||||
import { cn } from "_helpers/cn";
|
||||
import { ChevronsRightLeft, House, MessageSquareText, Minimize2 } from "lucide-react";
|
||||
import { SmartPopup, calculateAnchor, useSmartPopup } from "_components/SmartPopup";
|
||||
import FMSStatusHistory, {
|
||||
FMSStatusSelector,
|
||||
MissionTab,
|
||||
@@ -29,9 +13,9 @@ import FMSStatusHistory, {
|
||||
} from "./_components/AircraftMarkerTabs";
|
||||
import { ConnectedAircraft, Station } from "@repo/db";
|
||||
import { useQuery } from "@tanstack/react-query";
|
||||
import { getConnectedAircraftsAPI } from "querys/aircrafts";
|
||||
import { getMissionsAPI } from "querys/missions";
|
||||
import { checkSimulatorConnected } from "helpers/simulatorConnected";
|
||||
import { getConnectedAircraftsAPI } from "_querys/aircrafts";
|
||||
import { getMissionsAPI } from "_querys/missions";
|
||||
import { checkSimulatorConnected } from "_helpers/simulatorConnected";
|
||||
|
||||
export const FMS_STATUS_COLORS: { [key: string]: string } = {
|
||||
"0": "rgb(140,10,10)",
|
||||
@@ -86,9 +70,7 @@ const AircraftPopupContent = ({
|
||||
aircraft: ConnectedAircraft & { Station: Station };
|
||||
}) => {
|
||||
const setAircraftTab = useMapStore((state) => state.setAircraftTab);
|
||||
const currentTab = useMapStore(
|
||||
(state) => state.aircraftTabs[aircraft.id] || "home",
|
||||
);
|
||||
const currentTab = useMapStore((state) => state.aircraftTabs[aircraft.id] || "home");
|
||||
|
||||
// Memoize the tab change handler to avoid unnecessary re-renders
|
||||
const handleTabChange = useCallback(
|
||||
@@ -126,9 +108,7 @@ const AircraftPopupContent = ({
|
||||
<MissionTab mission={mission} />
|
||||
) : (
|
||||
<div className="flex flex-col items-center justify-center min-h-full">
|
||||
<span className="text-gray-500 my-10 font-semibold">
|
||||
Kein aktiver Einsatz
|
||||
</span>
|
||||
<span className="text-gray-500 my-10 font-semibold">Kein aktiver Einsatz</span>
|
||||
</div>
|
||||
);
|
||||
case "chat":
|
||||
@@ -138,9 +118,7 @@ const AircraftPopupContent = ({
|
||||
}
|
||||
}, [currentTab, aircraft, mission]);
|
||||
|
||||
const setOpenAircraftMarker = useMapStore(
|
||||
(state) => state.setOpenAircraftMarker,
|
||||
);
|
||||
const setOpenAircraftMarker = useMapStore((state) => state.setOpenAircraftMarker);
|
||||
const { anchor } = useSmartPopup();
|
||||
return (
|
||||
<>
|
||||
@@ -278,19 +256,13 @@ const AircraftPopupContent = ({
|
||||
);
|
||||
};
|
||||
|
||||
const AircraftMarker = ({
|
||||
aircraft,
|
||||
}: {
|
||||
aircraft: ConnectedAircraft & { Station: Station };
|
||||
}) => {
|
||||
const AircraftMarker = ({ aircraft }: { aircraft: ConnectedAircraft & { Station: Station } }) => {
|
||||
const [hideMarker, setHideMarker] = useState(false);
|
||||
const map = useMap();
|
||||
const markerRef = useRef<LMarker>(null);
|
||||
const popupRef = useRef<LPopup>(null);
|
||||
|
||||
const { openAircraftMarker, setOpenAircraftMarker } = useMapStore(
|
||||
(store) => store,
|
||||
);
|
||||
const { openAircraftMarker, setOpenAircraftMarker } = useMapStore((store) => store);
|
||||
|
||||
useEffect(() => {
|
||||
const handleClick = () => {
|
||||
@@ -319,9 +291,9 @@ const AircraftMarker = ({
|
||||
};
|
||||
}, [aircraft.id, openAircraftMarker, setOpenAircraftMarker]);
|
||||
|
||||
const [anchor, setAnchor] = useState<
|
||||
"topleft" | "topright" | "bottomleft" | "bottomright"
|
||||
>("topleft");
|
||||
const [anchor, setAnchor] = useState<"topleft" | "topright" | "bottomleft" | "bottomright">(
|
||||
"topleft",
|
||||
);
|
||||
|
||||
const handleConflict = useCallback(() => {
|
||||
const newAnchor = calculateAnchor(`aircraft-${aircraft.id}`, "marker");
|
||||
|
||||
@@ -4,7 +4,7 @@ import { useDispatchConnectionStore } from "_store/dispatch/connectionStore";
|
||||
import { useMapStore } from "_store/mapStore";
|
||||
import { usePannelStore } from "_store/pannelStore";
|
||||
import { MapPin, MapPinned, Radius, Ruler, Search, RulerDimensionLine, Scan } from "lucide-react";
|
||||
import { getOsmAddress } from "querys/osm";
|
||||
import { getOsmAddress } from "_querys/osm";
|
||||
import { useEffect, useState } from "react";
|
||||
import toast from "react-hot-toast";
|
||||
import { Popup, useMap } from "react-leaflet";
|
||||
|
||||
@@ -3,7 +3,7 @@ import { DivIcon, Marker as LMarker, Popup as LPopup } from "leaflet";
|
||||
import { useMapStore } from "_store/mapStore";
|
||||
import { usePannelStore } from "_store/pannelStore";
|
||||
import { Fragment, useCallback, useEffect, useMemo, useRef, useState } from "react";
|
||||
import { cn } from "helpers/cn";
|
||||
import { cn } from "_helpers/cn";
|
||||
import { ClipboardList, Cross, House, Minimize2, SmartphoneNfc, PencilLine } from "lucide-react";
|
||||
import { calculateAnchor, SmartPopup, useSmartPopup } from "_components/SmartPopup";
|
||||
import { Mission, MissionState } from "@repo/db";
|
||||
@@ -13,10 +13,10 @@ import Einsatzdetails, {
|
||||
Rettungsmittel,
|
||||
} from "./_components/MissionMarkerTabs";
|
||||
import { useQuery } from "@tanstack/react-query";
|
||||
import { getMissionsAPI } from "querys/missions";
|
||||
import { getMissionsAPI } from "_querys/missions";
|
||||
import { useDispatchConnectionStore } from "_store/dispatch/connectionStore";
|
||||
import { HPGValidationRequired } from "helpers/hpgValidationRequired";
|
||||
import { getConnectedAircraftsAPI } from "querys/aircrafts";
|
||||
import { HPGValidationRequired } from "_helpers/hpgValidationRequired";
|
||||
import { getConnectedAircraftsAPI } from "_querys/aircrafts";
|
||||
|
||||
export const MISSION_STATUS_COLORS: Record<MissionState | "attention", string> = {
|
||||
draft: "#0092b8",
|
||||
|
||||
@@ -4,7 +4,7 @@ import { Fragment, useEffect, useRef } from "react";
|
||||
import { Marker, Polygon, Popup } from "react-leaflet";
|
||||
import L from "leaflet";
|
||||
import { useQuery } from "@tanstack/react-query";
|
||||
import { getMissionsAPI } from "querys/missions";
|
||||
import { getMissionsAPI } from "_querys/missions";
|
||||
import { OSMWay } from "@repo/db";
|
||||
import { usePannelStore } from "_store/pannelStore";
|
||||
|
||||
|
||||
@@ -13,9 +13,9 @@ import {
|
||||
} from "@repo/db";
|
||||
import { toast } from "react-hot-toast";
|
||||
import { useMutation, useQueryClient } from "@tanstack/react-query";
|
||||
import { editConnectedAircraftAPI } from "querys/aircrafts";
|
||||
import { editConnectedAircraftAPI } from "_querys/aircrafts";
|
||||
import { useDispatchConnectionStore } from "_store/dispatch/connectionStore";
|
||||
import { cn } from "helpers/cn";
|
||||
import { cn } from "_helpers/cn";
|
||||
import { PersonIcon } from "@radix-ui/react-icons";
|
||||
import {
|
||||
Ban,
|
||||
@@ -37,7 +37,7 @@ import {
|
||||
TextSearch,
|
||||
} from "lucide-react";
|
||||
import { useSession } from "next-auth/react";
|
||||
import { editMissionAPI, sendSdsMessageAPI } from "querys/missions";
|
||||
import { editMissionAPI, sendSdsMessageAPI } from "_querys/missions";
|
||||
|
||||
const FMSStatusHistory = ({
|
||||
aircraft,
|
||||
@@ -48,25 +48,18 @@ const FMSStatusHistory = ({
|
||||
}) => {
|
||||
console.log("FMSStatusHistory", mission?.missionLog);
|
||||
const log = ((mission?.missionLog as unknown as MissionLog[]) || [])
|
||||
.filter(
|
||||
(entry) =>
|
||||
entry.type === "station-log" &&
|
||||
entry.data.stationId === aircraft.Station.id,
|
||||
)
|
||||
.filter((entry) => entry.type === "station-log" && entry.data.stationId === aircraft.Station.id)
|
||||
.reverse()
|
||||
.splice(0, 6) as MissionStationLog[];
|
||||
|
||||
const aircraftUser =
|
||||
typeof aircraft.publicUser === "string"
|
||||
? JSON.parse(aircraft.publicUser)
|
||||
: aircraft.publicUser;
|
||||
typeof aircraft.publicUser === "string" ? JSON.parse(aircraft.publicUser) : aircraft.publicUser;
|
||||
|
||||
return (
|
||||
<div className="p-4">
|
||||
<ul className="text-base-content font-semibold">
|
||||
<li className="flex items-center gap-2 mb-1">
|
||||
<PersonIcon className="w-5 h-5" /> {aircraftUser.fullName} (
|
||||
{aircraftUser.publicId})
|
||||
<PersonIcon className="w-5 h-5" /> {aircraftUser.fullName} ({aircraftUser.publicId})
|
||||
</li>
|
||||
</ul>
|
||||
<div className="divider mt-0 mb-0" />
|
||||
@@ -99,8 +92,7 @@ const FMSStatusSelector = ({
|
||||
}: {
|
||||
aircraft: ConnectedAircraft & { Station: Station };
|
||||
}) => {
|
||||
const dispatcherConnected =
|
||||
useDispatchConnectionStore((s) => s.status) === "connected";
|
||||
const dispatcherConnected = useDispatchConnectionStore((s) => s.status) === "connected";
|
||||
const [hoveredStatus, setHoveredStatus] = useState<string | null>(null);
|
||||
const queryClient = useQueryClient();
|
||||
const changeAircraftMutation = useMutation({
|
||||
@@ -299,13 +291,7 @@ const SDSTab = ({
|
||||
const queryClient = useQueryClient();
|
||||
|
||||
const sendSdsMutation = useMutation({
|
||||
mutationFn: async ({
|
||||
id,
|
||||
message,
|
||||
}: {
|
||||
id: number;
|
||||
message: MissionSdsLog;
|
||||
}) => {
|
||||
mutationFn: async ({ id, message }: { id: number; message: MissionSdsLog }) => {
|
||||
await sendSdsMessageAPI(id, message);
|
||||
queryClient.invalidateQueries({
|
||||
queryKey: ["missions"],
|
||||
@@ -318,9 +304,7 @@ const SDSTab = ({
|
||||
?.slice()
|
||||
.reverse()
|
||||
.filter(
|
||||
(entry) =>
|
||||
entry.type === "sds-log" &&
|
||||
entry.data.stationId === aircraft.Station.id,
|
||||
(entry) => entry.type === "sds-log" && entry.data.stationId === aircraft.Station.id,
|
||||
) || [];
|
||||
|
||||
return (
|
||||
|
||||
@@ -5,13 +5,13 @@ import { useDispatchConnectionStore } from "_store/dispatch/connectionStore";
|
||||
import { useMapStore } from "_store/mapStore";
|
||||
import { FMS_STATUS_COLORS, FMS_STATUS_TEXT_COLORS } from "_components/map/AircraftMarker";
|
||||
import { MISSION_STATUS_COLORS, MISSION_STATUS_TEXT_COLORS } from "_components/map/MissionMarkers";
|
||||
import { cn } from "helpers/cn";
|
||||
import { checkSimulatorConnected } from "helpers/simulatorConnected";
|
||||
import { getConnectedAircraftsAPI } from "querys/aircrafts";
|
||||
import { getMissionsAPI } from "querys/missions";
|
||||
import { cn } from "_helpers/cn";
|
||||
import { checkSimulatorConnected } from "_helpers/simulatorConnected";
|
||||
import { getConnectedAircraftsAPI } from "_querys/aircrafts";
|
||||
import { getMissionsAPI } from "_querys/missions";
|
||||
import { useEffect, useMemo, useState } from "react";
|
||||
import { useMap } from "react-leaflet";
|
||||
import { HPGValidationRequired } from "helpers/hpgValidationRequired";
|
||||
import { HPGValidationRequired } from "_helpers/hpgValidationRequired";
|
||||
|
||||
const PopupContent = ({
|
||||
aircrafts,
|
||||
|
||||
@@ -32,13 +32,13 @@ import {
|
||||
import { usePannelStore } from "_store/pannelStore";
|
||||
import { useSession } from "next-auth/react";
|
||||
import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query";
|
||||
import { deleteMissionAPI, editMissionAPI, sendMissionAPI } from "querys/missions";
|
||||
import { getConnectedAircraftsAPI } from "querys/aircrafts";
|
||||
import { getStationsAPI } from "querys/stations";
|
||||
import { deleteMissionAPI, editMissionAPI, sendMissionAPI } from "_querys/missions";
|
||||
import { getConnectedAircraftsAPI } from "_querys/aircrafts";
|
||||
import { getStationsAPI } from "_querys/stations";
|
||||
import { useDispatchConnectionStore } from "_store/dispatch/connectionStore";
|
||||
import { HPGValidationRequired } from "helpers/hpgValidationRequired";
|
||||
import { getOsmAddress } from "querys/osm";
|
||||
import { hpgStateToFMSStatus } from "helpers/hpgStateToFmsStatus";
|
||||
import { HPGValidationRequired } from "_helpers/hpgValidationRequired";
|
||||
import { getOsmAddress } from "_querys/osm";
|
||||
import { hpgStateToFMSStatus } from "_helpers/hpgStateToFmsStatus";
|
||||
|
||||
const Einsatzdetails = ({
|
||||
mission,
|
||||
|
||||
@@ -1,12 +1,9 @@
|
||||
import { ConnectedAircraft, Prisma, Station } from "@repo/db";
|
||||
import axios from "axios";
|
||||
import { serverApi } from "helpers/axios";
|
||||
import { serverApi } from "_helpers/axios";
|
||||
|
||||
export const getConnectedAircraftsAPI = async () => {
|
||||
const res =
|
||||
await axios.get<(ConnectedAircraft & { Station: Station })[]>(
|
||||
"/api/aircrafts",
|
||||
); // return only connected aircrafts
|
||||
const res = await axios.get<(ConnectedAircraft & { Station: Station })[]>("/api/aircrafts"); // return only connected aircrafts
|
||||
if (res.status !== 200) {
|
||||
throw new Error("Failed to fetch stations");
|
||||
}
|
||||
@@ -17,9 +14,6 @@ export const editConnectedAircraftAPI = async (
|
||||
id: number,
|
||||
mission: Prisma.ConnectedAircraftUpdateInput,
|
||||
) => {
|
||||
const respone = await serverApi.patch<ConnectedAircraft>(
|
||||
`/aircrafts/${id}`,
|
||||
mission,
|
||||
);
|
||||
const respone = await serverApi.patch<ConnectedAircraft>(`/aircrafts/${id}`, mission);
|
||||
return respone.data;
|
||||
};
|
||||
@@ -1,6 +1,6 @@
|
||||
import { Mission, MissionSdsLog, Prisma } from "@repo/db";
|
||||
import axios from "axios";
|
||||
import { serverApi } from "helpers/axios";
|
||||
import { serverApi } from "_helpers/axios";
|
||||
|
||||
export const getMissionsAPI = async (filter?: Prisma.MissionWhereInput) => {
|
||||
const res = await axios.get<Mission[]>("/api/missions", {
|
||||
@@ -1,17 +1,11 @@
|
||||
import { Prisma, Report } from "@repo/db";
|
||||
import { serverApi } from "helpers/axios";
|
||||
import { serverApi } from "_helpers/axios";
|
||||
|
||||
export const sendReportAPI = async (
|
||||
report:
|
||||
| (Prisma.Without<
|
||||
Prisma.ReportCreateInput,
|
||||
Prisma.ReportUncheckedCreateInput
|
||||
> &
|
||||
| (Prisma.Without<Prisma.ReportCreateInput, Prisma.ReportUncheckedCreateInput> &
|
||||
Prisma.ReportUncheckedCreateInput)
|
||||
| (Prisma.Without<
|
||||
Prisma.ReportUncheckedCreateInput,
|
||||
Prisma.ReportCreateInput
|
||||
> &
|
||||
| (Prisma.Without<Prisma.ReportUncheckedCreateInput, Prisma.ReportCreateInput> &
|
||||
Prisma.ReportCreateInput),
|
||||
) => {
|
||||
const repsonse = await serverApi.put("/report", report);
|
||||
@@ -1,13 +1,13 @@
|
||||
import { PublicUser } from "@repo/db";
|
||||
import { dispatchSocket } from "dispatch/socket";
|
||||
import { serverApi } from "helpers/axios";
|
||||
import { serverApi } from "_helpers/axios";
|
||||
import {
|
||||
handleActiveSpeakerChange,
|
||||
handleDisconnect,
|
||||
handleLocalTrackUnpublished,
|
||||
handleTrackSubscribed,
|
||||
handleTrackUnsubscribed,
|
||||
} from "helpers/liveKitEventHandler";
|
||||
} from "_helpers/liveKitEventHandler";
|
||||
import { ConnectionQuality, Room, RoomEvent } from "livekit-client";
|
||||
import { pilotSocket } from "pilot/socket";
|
||||
import { create } from "zustand";
|
||||
|
||||
@@ -1,7 +1,4 @@
|
||||
import {
|
||||
AuthOptions,
|
||||
getServerSession as getNextAuthServerSession,
|
||||
} from "next-auth";
|
||||
import { AuthOptions, getServerSession as getNextAuthServerSession } from "next-auth";
|
||||
import { PrismaAdapter } from "@next-auth/prisma-adapter";
|
||||
import Credentials from "next-auth/providers/credentials";
|
||||
import { prisma, PrismaClient } from "@repo/db";
|
||||
@@ -36,10 +33,10 @@ export const options: AuthOptions = {
|
||||
},
|
||||
}),
|
||||
],
|
||||
secret: process.env.NEXTAUTH_SECRET,
|
||||
secret: process.env.AUTH_DISPATCH_SECRET,
|
||||
cookies: {
|
||||
sessionToken: {
|
||||
name: `${process.env.NEXTAUTH_COOKIE_PREFIX}-next-auth.session-token`, // Ändere den Namen für App 1
|
||||
name: `${process.env.AUTH_DISPATCH_COOKIE_PREFIX}-next-auth.session-token`, // Ändere den Namen für App 1
|
||||
options: {
|
||||
httpOnly: true,
|
||||
secure: process.env.NODE_ENV === "production",
|
||||
@@ -47,7 +44,7 @@ export const options: AuthOptions = {
|
||||
},
|
||||
},
|
||||
csrfToken: {
|
||||
name: `${process.env.NEXTAUTH_COOKIE_PREFIX}-next-auth.csrf-token`,
|
||||
name: `${process.env.AUTH_DISPATCH_COOKIE_PREFIX}-next-auth.csrf-token`,
|
||||
options: {
|
||||
httpOnly: true,
|
||||
secure: process.env.NODE_ENV === "production",
|
||||
|
||||
@@ -15,13 +15,13 @@ import {
|
||||
editMissionAPI,
|
||||
sendMissionAPI,
|
||||
startHpgValidation,
|
||||
} from "querys/missions";
|
||||
import { getKeywordsAPI } from "querys/keywords";
|
||||
import { getStationsAPI } from "querys/stations";
|
||||
} from "_querys/missions";
|
||||
import { getKeywordsAPI } from "_querys/keywords";
|
||||
import { getStationsAPI } from "_querys/stations";
|
||||
import { useMapStore } from "_store/mapStore";
|
||||
import { getConnectedAircraftsAPI } from "querys/aircrafts";
|
||||
import { HPGValidationRequired } from "helpers/hpgValidationRequired";
|
||||
import { selectRandomHPGMissionSzenery } from "helpers/selectRandomHPGMission";
|
||||
import { getConnectedAircraftsAPI } from "_querys/aircrafts";
|
||||
import { HPGValidationRequired } from "_helpers/hpgValidationRequired";
|
||||
import { selectRandomHPGMissionSzenery } from "_helpers/selectRandomHPGMission";
|
||||
import { AxiosError } from "axios";
|
||||
|
||||
export const MissionForm = () => {
|
||||
|
||||
@@ -1,15 +1,14 @@
|
||||
import { usePannelStore } from "_store/pannelStore";
|
||||
import { cn } from "helpers/cn";
|
||||
import { cn } from "_helpers/cn";
|
||||
import { MissionForm } from "./MissionForm";
|
||||
import { Rss, Trash2Icon } from "lucide-react";
|
||||
import { useEffect } from "react";
|
||||
import { useQuery } from "@tanstack/react-query";
|
||||
import { getMissionsAPI } from "querys/missions";
|
||||
import { getMissionsAPI } from "_querys/missions";
|
||||
|
||||
export const Pannel = () => {
|
||||
const { setOpen, setMissionFormValues } = usePannelStore();
|
||||
const { isEditingMission, setEditingMission, missionFormValues } =
|
||||
usePannelStore();
|
||||
const { isEditingMission, setEditingMission, missionFormValues } = usePannelStore();
|
||||
const missions = useQuery({
|
||||
queryKey: ["missions"],
|
||||
queryFn: () =>
|
||||
@@ -20,9 +19,7 @@ export const Pannel = () => {
|
||||
|
||||
useEffect(() => {
|
||||
if (isEditingMission && missionFormValues) {
|
||||
const mission = missions.data?.find(
|
||||
(mission) => mission.id === missionFormValues.id,
|
||||
);
|
||||
const mission = missions.data?.find((mission) => mission.id === missionFormValues.id);
|
||||
if (!mission) {
|
||||
setEditingMission(false, null);
|
||||
setMissionFormValues({});
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
import { Pannel } from "dispatch/_components/pannel/Pannel";
|
||||
import { usePannelStore } from "_store/pannelStore";
|
||||
import { cn } from "helpers/cn";
|
||||
import { cn } from "_helpers/cn";
|
||||
import dynamic from "next/dynamic";
|
||||
import { Chat } from "../_components/left/Chat";
|
||||
import { Report } from "../_components/left/Report";
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
"use client";
|
||||
import { io } from "socket.io-client";
|
||||
import { io, Socket } from "socket.io-client";
|
||||
|
||||
import type { Socket } from "socket.io-client";
|
||||
console.log("ENV:", process.env.NEXT_PUBLIC_DISPATCH_SERVER_URL);
|
||||
|
||||
export const dispatchSocket: Socket = io(process.env.NEXT_PUBLIC_DISPATCH_SERVER_URL, {
|
||||
autoConnect: false,
|
||||
|
||||
@@ -2,21 +2,18 @@ import { ConnectedAircraft } from "@repo/db";
|
||||
import { usePilotConnectionStore } from "_store/pilot/connectionStore";
|
||||
import { useMrtStore } from "_store/pilot/MrtStore";
|
||||
import { pilotSocket } from "pilot/socket";
|
||||
import { editConnectedAircraftAPI } from "querys/aircrafts";
|
||||
import { editConnectedAircraftAPI } from "_querys/aircrafts";
|
||||
import { useEffect } from "react";
|
||||
|
||||
export const useButtons = () => {
|
||||
const station = usePilotConnectionStore((state) => state.selectedStation);
|
||||
const connectedAircraft = usePilotConnectionStore(
|
||||
(state) => state.connectedAircraft,
|
||||
);
|
||||
const connectedAircraft = usePilotConnectionStore((state) => state.connectedAircraft);
|
||||
const connectionStatus = usePilotConnectionStore((state) => state.status);
|
||||
|
||||
const { page, setPage } = useMrtStore((state) => state);
|
||||
|
||||
const handleButton =
|
||||
(button: "1" | "2" | "3" | "4" | "5" | "6" | "7" | "8" | "9" | "0") =>
|
||||
() => {
|
||||
(button: "1" | "2" | "3" | "4" | "5" | "6" | "7" | "8" | "9" | "0") => () => {
|
||||
if (connectionStatus !== "connected") return;
|
||||
if (!station) return;
|
||||
if (!connectedAircraft?.id) return;
|
||||
|
||||
@@ -3,7 +3,7 @@ import { useSession } from "next-auth/react";
|
||||
import { usePilotConnectionStore } from "_store/pilot/connectionStore";
|
||||
import { useEffect, useRef, useState } from "react";
|
||||
import { useQuery } from "@tanstack/react-query";
|
||||
import { getStationsAPI } from "querys/stations";
|
||||
import { getStationsAPI } from "_querys/stations";
|
||||
|
||||
export const ConnectionBtn = () => {
|
||||
const modalRef = useRef<HTMLDialogElement>(null);
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
"use client";
|
||||
|
||||
import { io, Socket } from "socket.io-client";
|
||||
|
||||
export const pilotSocket: Socket = io(process.env.NEXT_PUBLIC_DISPATCH_SERVER_URL, {
|
||||
|
||||
Reference in New Issue
Block a user