Fix lougout-Zeit
This commit is contained in:
@@ -51,7 +51,9 @@ export const handleConnectDispatch =
|
|||||||
data: {
|
data: {
|
||||||
publicUser: getPublicUser(user) as any,
|
publicUser: getPublicUser(user) as any,
|
||||||
esimatedLogoutTime:
|
esimatedLogoutTime:
|
||||||
logoffHours && logoffMinutes ? getNextDateWithTime(logoffHours, logoffMinutes) : null,
|
logoffHours !== undefined && logoffMinutes !== undefined
|
||||||
|
? getNextDateWithTime(logoffHours, logoffMinutes)
|
||||||
|
: null,
|
||||||
lastHeartbeat: new Date().toISOString(),
|
lastHeartbeat: new Date().toISOString(),
|
||||||
userId: user.id,
|
userId: user.id,
|
||||||
zone: selectedZone,
|
zone: selectedZone,
|
||||||
|
|||||||
@@ -79,7 +79,9 @@ export const handleConnectPilot =
|
|||||||
data: {
|
data: {
|
||||||
publicUser: getPublicUser(user) as any,
|
publicUser: getPublicUser(user) as any,
|
||||||
esimatedLogoutTime:
|
esimatedLogoutTime:
|
||||||
logoffHours && logoffMinutes ? getNextDateWithTime(logoffHours, logoffMinutes) : null,
|
logoffHours !== undefined && logoffMinutes !== undefined
|
||||||
|
? getNextDateWithTime(logoffHours, logoffMinutes)
|
||||||
|
: null,
|
||||||
userId: userId,
|
userId: userId,
|
||||||
stationId: parseInt(stationId),
|
stationId: parseInt(stationId),
|
||||||
lastHeartbeat: debug ? nowPlus2h.toISOString() : undefined,
|
lastHeartbeat: debug ? nowPlus2h.toISOString() : undefined,
|
||||||
|
|||||||
@@ -22,9 +22,6 @@ export const ConnectionBtn = () => {
|
|||||||
const session = useSession();
|
const session = useSession();
|
||||||
const uid = session.data?.user?.id;
|
const uid = session.data?.user?.id;
|
||||||
|
|
||||||
// useEffect für die Logoff-Zeit
|
|
||||||
const [logoffHours, logoffMinutes] = form.logoffTime?.split(":").map(Number) || [];
|
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
// Disconnect the socket when the component unmounts
|
// Disconnect the socket when the component unmounts
|
||||||
return () => {
|
return () => {
|
||||||
@@ -101,11 +98,13 @@ export const ConnectionBtn = () => {
|
|||||||
className="btn"
|
className="btn"
|
||||||
onClick={async () => {
|
onClick={async () => {
|
||||||
if (!connection.connectedDispatcher?.id) return;
|
if (!connection.connectedDispatcher?.id) return;
|
||||||
|
const [logoffHours, logoffMinutes] =
|
||||||
|
form.logoffTime?.split(":").map(Number) || [];
|
||||||
await changeDispatcherMutation.mutateAsync({
|
await changeDispatcherMutation.mutateAsync({
|
||||||
id: connection.connectedDispatcher?.id,
|
id: connection.connectedDispatcher?.id,
|
||||||
data: {
|
data: {
|
||||||
esimatedLogoutTime:
|
esimatedLogoutTime:
|
||||||
logoffHours && logoffMinutes
|
logoffHours !== undefined && logoffMinutes !== undefined
|
||||||
? getNextDateWithTime(logoffHours, logoffMinutes)
|
? getNextDateWithTime(logoffHours, logoffMinutes)
|
||||||
: null,
|
: null,
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -54,8 +54,6 @@ export const ConnectionBtn = () => {
|
|||||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||||
}, [connection.disconnect]);
|
}, [connection.disconnect]);
|
||||||
|
|
||||||
const [logoffHours, logoffMinutes] = form.logoffTime?.split(":").map(Number) || [];
|
|
||||||
|
|
||||||
const { data: connectedAircrafts } = useQuery({
|
const { data: connectedAircrafts } = useQuery({
|
||||||
queryKey: ["aircrafts"],
|
queryKey: ["aircrafts"],
|
||||||
queryFn: () => getConnectedAircraftsAPI(),
|
queryFn: () => getConnectedAircraftsAPI(),
|
||||||
@@ -182,11 +180,15 @@ export const ConnectionBtn = () => {
|
|||||||
className="btn"
|
className="btn"
|
||||||
onClick={async () => {
|
onClick={async () => {
|
||||||
if (!connection.connectedAircraft) return;
|
if (!connection.connectedAircraft) return;
|
||||||
|
const [logoffHours, logoffMinutes] =
|
||||||
|
form.logoffTime?.split(":").map(Number) || [];
|
||||||
|
|
||||||
|
console.log(logoffHours, logoffMinutes, form.logoffTime);
|
||||||
await aircraftMutation.mutateAsync({
|
await aircraftMutation.mutateAsync({
|
||||||
sessionId: connection.connectedAircraft.id,
|
sessionId: connection.connectedAircraft.id,
|
||||||
change: {
|
change: {
|
||||||
esimatedLogoutTime:
|
esimatedLogoutTime:
|
||||||
logoffHours && logoffMinutes
|
logoffHours !== undefined && logoffMinutes !== undefined
|
||||||
? getNextDateWithTime(logoffHours, logoffMinutes)
|
? getNextDateWithTime(logoffHours, logoffMinutes)
|
||||||
: null,
|
: null,
|
||||||
},
|
},
|
||||||
@@ -202,6 +204,7 @@ export const ConnectionBtn = () => {
|
|||||||
onSubmit={() => false}
|
onSubmit={() => false}
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
connection.disconnect();
|
connection.disconnect();
|
||||||
|
modalRef.current?.close();
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
Verbindung Trennen
|
Verbindung Trennen
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
"use client";
|
||||||
import { DatabaseBackupIcon } from "lucide-react";
|
import { DatabaseBackupIcon } from "lucide-react";
|
||||||
import { PaginatedTable } from "../../../_components/PaginatedTable";
|
import { PaginatedTable } from "../../../_components/PaginatedTable";
|
||||||
import Link from "next/link";
|
import Link from "next/link";
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ const page = () => {
|
|||||||
<>
|
<>
|
||||||
<PaginatedTable
|
<PaginatedTable
|
||||||
prismaModel="station"
|
prismaModel="station"
|
||||||
searchFields={["bosCallsign", "bosUse", "country", "operator"]}
|
searchFields={["bosCallsign", "operator"]}
|
||||||
columns={
|
columns={
|
||||||
[
|
[
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user