Fix lougout-Zeit

This commit is contained in:
PxlLoewe
2025-07-10 23:41:39 -07:00
parent 879c422366
commit 446391679c
6 changed files with 17 additions and 10 deletions

View File

@@ -51,7 +51,9 @@ export const handleConnectDispatch =
data: {
publicUser: getPublicUser(user) as any,
esimatedLogoutTime:
logoffHours && logoffMinutes ? getNextDateWithTime(logoffHours, logoffMinutes) : null,
logoffHours !== undefined && logoffMinutes !== undefined
? getNextDateWithTime(logoffHours, logoffMinutes)
: null,
lastHeartbeat: new Date().toISOString(),
userId: user.id,
zone: selectedZone,

View File

@@ -79,7 +79,9 @@ export const handleConnectPilot =
data: {
publicUser: getPublicUser(user) as any,
esimatedLogoutTime:
logoffHours && logoffMinutes ? getNextDateWithTime(logoffHours, logoffMinutes) : null,
logoffHours !== undefined && logoffMinutes !== undefined
? getNextDateWithTime(logoffHours, logoffMinutes)
: null,
userId: userId,
stationId: parseInt(stationId),
lastHeartbeat: debug ? nowPlus2h.toISOString() : undefined,

View File

@@ -22,9 +22,6 @@ export const ConnectionBtn = () => {
const session = useSession();
const uid = session.data?.user?.id;
// useEffect für die Logoff-Zeit
const [logoffHours, logoffMinutes] = form.logoffTime?.split(":").map(Number) || [];
useEffect(() => {
// Disconnect the socket when the component unmounts
return () => {
@@ -101,11 +98,13 @@ export const ConnectionBtn = () => {
className="btn"
onClick={async () => {
if (!connection.connectedDispatcher?.id) return;
const [logoffHours, logoffMinutes] =
form.logoffTime?.split(":").map(Number) || [];
await changeDispatcherMutation.mutateAsync({
id: connection.connectedDispatcher?.id,
data: {
esimatedLogoutTime:
logoffHours && logoffMinutes
logoffHours !== undefined && logoffMinutes !== undefined
? getNextDateWithTime(logoffHours, logoffMinutes)
: null,
},

View File

@@ -54,8 +54,6 @@ export const ConnectionBtn = () => {
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [connection.disconnect]);
const [logoffHours, logoffMinutes] = form.logoffTime?.split(":").map(Number) || [];
const { data: connectedAircrafts } = useQuery({
queryKey: ["aircrafts"],
queryFn: () => getConnectedAircraftsAPI(),
@@ -182,11 +180,15 @@ export const ConnectionBtn = () => {
className="btn"
onClick={async () => {
if (!connection.connectedAircraft) return;
const [logoffHours, logoffMinutes] =
form.logoffTime?.split(":").map(Number) || [];
console.log(logoffHours, logoffMinutes, form.logoffTime);
await aircraftMutation.mutateAsync({
sessionId: connection.connectedAircraft.id,
change: {
esimatedLogoutTime:
logoffHours && logoffMinutes
logoffHours !== undefined && logoffMinutes !== undefined
? getNextDateWithTime(logoffHours, logoffMinutes)
: null,
},
@@ -202,6 +204,7 @@ export const ConnectionBtn = () => {
onSubmit={() => false}
onClick={() => {
connection.disconnect();
modalRef.current?.close();
}}
>
Verbindung Trennen

View File

@@ -1,3 +1,4 @@
"use client";
import { DatabaseBackupIcon } from "lucide-react";
import { PaginatedTable } from "../../../_components/PaginatedTable";
import Link from "next/link";

View File

@@ -10,7 +10,7 @@ const page = () => {
<>
<PaginatedTable
prismaModel="station"
searchFields={["bosCallsign", "bosUse", "country", "operator"]}
searchFields={["bosCallsign", "operator"]}
columns={
[
{