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

View File

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

View File

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

View File

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