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 { 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"