This commit is contained in:
PxlLoewe
2025-06-02 13:48:11 -07:00
4 changed files with 109 additions and 93 deletions

View File

@@ -290,6 +290,8 @@ const SDSTab = ({
const [note, setNote] = useState(""); const [note, setNote] = useState("");
const queryClient = useQueryClient(); const queryClient = useQueryClient();
const dispatcherConnected = useDispatchConnectionStore((s) => s.status) === "connected";
const sendSdsMutation = useMutation({ const sendSdsMutation = useMutation({
mutationFn: async ({ id, message }: { id: number; message: MissionSdsLog }) => { mutationFn: async ({ id, message }: { id: number; message: MissionSdsLog }) => {
await sendSdsMessageAPI(id, message); await sendSdsMessageAPI(id, message);
@@ -309,65 +311,69 @@ const SDSTab = ({
return ( return (
<div className="p-4"> <div className="p-4">
<div className="flex items-center gap-2"> {dispatcherConnected && (
{!isChatOpen ? ( <div>
<button <div className="flex items-center gap-2">
className="text-base-content text-base cursor-pointer" {!isChatOpen ? (
onClick={() => setIsChatOpen(true)} <button
> className="text-base-content text-base cursor-pointer"
<span className="flex items-center gap-2"> onClick={() => setIsChatOpen(true)}
<Plus size={18} /> Notiz hinzufügen >
</span> <span className="flex items-center gap-2">
</button> <Plus size={18} /> Notiz hinzufügen
) : ( </span>
<div className="flex items-center gap-2 w-full"> </button>
<input ) : (
type="text" <div className="flex items-center gap-2 w-full">
placeholder="" <input
className="input input-sm text-base-content flex-1" type="text"
value={note} placeholder=""
onChange={(e) => setNote(e.target.value)} className="input input-sm text-base-content flex-1"
/> value={note}
<button onChange={(e) => setNote(e.target.value)}
className="btn btn-sm btn-primary btn-outline" />
onClick={() => { <button
if (!mission) return; className="btn btn-sm btn-primary btn-outline"
sendSdsMutation onClick={() => {
.mutateAsync({ if (!mission) return;
id: mission.id, sendSdsMutation
message: { .mutateAsync({
type: "sds-log", id: mission.id,
auto: false, message: {
timeStamp: new Date().toISOString(), type: "sds-log",
data: { auto: false,
stationId: aircraft.Station.id, timeStamp: new Date().toISOString(),
station: aircraft.Station, data: {
message: note, stationId: aircraft.Station.id,
user: getPublicUser(session.data!.user), station: aircraft.Station,
}, message: note,
}, user: getPublicUser(session.data!.user),
}) },
.then(() => { },
})
.then(() => {
setIsChatOpen(false);
setNote("");
});
}}
>
<Plus size={20} />
</button>
<button
className="btn btn-sm btn-outline"
onClick={() => {
setIsChatOpen(false); setIsChatOpen(false);
setNote(""); setNote("");
}); }}
}} >
> <Ban size={20} />
<Plus size={20} /> </button>
</button> </div>
<button )}
className="btn btn-sm btn-outline"
onClick={() => {
setIsChatOpen(false);
setNote("");
}}
>
<Ban size={20} />
</button>
</div> </div>
)} <div className="divider m-0" />
</div> </div>
<div className="divider m-0" /> )}
<ul className="space-y-2 max-h-[300px] overflow-y-auto overflow-x-auto"> <ul className="space-y-2 max-h-[300px] overflow-y-auto overflow-x-auto">
{log.map((entry, index) => { {log.map((entry, index) => {
const sdsEntry = entry as MissionSdsLog; const sdsEntry = entry as MissionSdsLog;

View File

@@ -67,7 +67,7 @@ export const useMrtStore = create<MrtStore>(
page: "home", page: "home",
lines: [ lines: [
{ {
textLeft: `VAR#.${station?.bosCallsign}`, textLeft: `${station?.bosCallsign}`,
style: { fontWeight: "bold" }, style: { fontWeight: "bold" },
textSize: "2", textSize: "2",
}, },
@@ -92,7 +92,7 @@ export const useMrtStore = create<MrtStore>(
page: "sending-status", page: "sending-status",
lines: [ lines: [
{ {
textLeft: `VAR#.${station?.bosCallsign}`, textLeft: `${station?.bosCallsign}`,
style: { fontWeight: "bold" }, style: { fontWeight: "bold" },
textSize: "2", textSize: "2",
}, },
@@ -116,7 +116,7 @@ export const useMrtStore = create<MrtStore>(
page: "new-status", page: "new-status",
lines: [ lines: [
{ {
textLeft: `VAR#.${station?.bosCallsign}`, textLeft: `${station?.bosCallsign}`,
style: { fontWeight: "bold" }, style: { fontWeight: "bold" },
textSize: "2", textSize: "2",
}, },

View File

@@ -75,13 +75,17 @@ export const useDmeStore = create<MrtStore>(
lines: [ lines: [
{ {
textMid: pageData.station.bosCallsign textMid: pageData.station.bosCallsign
? `VAR#.${pageData.station.bosCallsign}` ? `${pageData.station.bosCallsign}`
: "no Data", : "no Data",
style: { fontWeight: "bold" }, style: { fontWeight: "bold" },
}, },
{ textMid: "" }, { textMid: "" },
{ {
textMid: new Date().toLocaleDateString(), textMid: new Date().toLocaleDateString("de-DE", {
year: "numeric",
month: "2-digit",
day: "2-digit",
}),
}, },
{ {
textMid: new Date().toLocaleTimeString(), textMid: new Date().toLocaleTimeString(),
@@ -122,9 +126,7 @@ export const useDmeStore = create<MrtStore>(
lines: [ lines: [
{ {
textLeft: `${pageData.mission.missionKeywordAbbreviation}`, textLeft: `${pageData.mission.missionKeywordAbbreviation}`,
textRight: pageData.mission.Stations.map( textRight: pageData.mission.Stations.map((s) => s.bosCallsignShort).join(","),
(s) => s.bosCallsignShort,
).join(","),
style: { fontWeight: "bold" }, style: { fontWeight: "bold" },
}, },
{ {
@@ -140,16 +142,14 @@ export const useDmeStore = create<MrtStore>(
style: { fontWeight: "bold" }, style: { fontWeight: "bold" },
}, },
{ {
textLeft: textLeft: pageData.mission.missionPatientInfo || "keine Daten",
pageData.mission.missionPatientInfo || "keine Daten",
}, },
{ {
textMid: "Weitere Infos:", textMid: "Weitere Infos:",
style: { fontWeight: "bold" }, style: { fontWeight: "bold" },
}, },
{ {
textLeft: textLeft: pageData.mission.missionAdditionalInfo || "keine Daten",
pageData.mission.missionAdditionalInfo || "keine Daten",
}, },
], ],
}); });

View File

@@ -4,6 +4,7 @@ import { usePilotConnectionStore } from "_store/pilot/connectionStore";
import { useEffect, useRef, useState } from "react"; import { useEffect, useRef, useState } from "react";
import { useQuery } from "@tanstack/react-query"; import { useQuery } from "@tanstack/react-query";
import { getStationsAPI } from "_querys/stations"; import { getStationsAPI } from "_querys/stations";
import toast from "react-hot-toast";
export const ConnectionBtn = () => { export const ConnectionBtn = () => {
const modalRef = useRef<HTMLDialogElement>(null); const modalRef = useRef<HTMLDialogElement>(null);
@@ -15,6 +16,7 @@ export const ConnectionBtn = () => {
logoffTime: null, logoffTime: null,
selectedStationId: null, selectedStationId: null,
}); });
const [logoffDebounce, setLogoffDebounce] = useState<NodeJS.Timeout | null>(null);
const { data: stations } = useQuery({ const { data: stations } = useQuery({
queryKey: ["stations"], queryKey: ["stations"],
@@ -73,37 +75,45 @@ export const ConnectionBtn = () => {
) : ( ) : (
<h3 className="text-lg font-bold mb-5">Als Pilot anmelden</h3> <h3 className="text-lg font-bold mb-5">Als Pilot anmelden</h3>
)} )}
<fieldset className="fieldset w-full"> {connection.status !== "connected" && (
<label className="floating-label w-full text-base"> <fieldset className="fieldset w-full">
<span>Station</span> <label className="floating-label w-full text-base">
<select <span>Station</span>
onChange={(e) => <select
setForm({ onChange={(e) =>
...form, setForm({
selectedStationId: parseInt(e.target.value), ...form,
}) selectedStationId: parseInt(e.target.value),
} })
value={form.selectedStationId ?? ""} }
className="input w-full" value={form.selectedStationId ?? ""}
> className="input w-full"
{stations?.map((station) => ( >
<option key={station.id} value={station.id}> {stations?.map((station) => (
{station.bosCallsign} <option key={station.id} value={station.id}>
</option> {station.bosCallsign}
))} </option>
</select> ))}
</label> </select>
</fieldset> </label>
</fieldset>
)}
<fieldset className="fieldset w-full mt-2"> <fieldset className="fieldset w-full mt-2">
<label className="floating-label w-full text-base"> <label className="floating-label w-full text-base">
<span>Logoff Zeit (UTC+1)</span> <span>Logoff Zeit (UTC+1)</span>
<input <input
onChange={(e) => onChange={(e) => {
const value = e.target.value;
setForm({ setForm({
...form, ...form,
logoffTime: e.target.value, logoffTime: value,
}) });
} if (logoffDebounce) clearTimeout(logoffDebounce);
const timeout = setTimeout(() => {
toast.success("Änderung gespeichert!");
}, 2000);
setLogoffDebounce(timeout);
}}
value={form.logoffTime ?? ""} value={form.logoffTime ?? ""}
type="time" type="time"
className="input w-full" className="input w-full"