minor fixes Pilot navbar

This commit is contained in:
nocnico
2025-06-02 22:21:54 +02:00
parent 8a2ffd8cfc
commit c884fedb62

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"