getNextHourTime zu shared library hinzugefügt
This commit is contained in:
@@ -8,6 +8,7 @@ import toast from "react-hot-toast";
|
||||
import { editConnectedAircraftAPI } from "_querys/aircrafts";
|
||||
import { Prisma } from "@repo/db";
|
||||
import { debug } from "console";
|
||||
import { getNextDateWithTime } from "@repo/shared-components";
|
||||
|
||||
export const ConnectionBtn = () => {
|
||||
const modalRef = useRef<HTMLDialogElement>(null);
|
||||
@@ -53,10 +54,10 @@ export const ConnectionBtn = () => {
|
||||
};
|
||||
}, [connection.disconnect]);
|
||||
|
||||
const logoffTime = form.logoffTime;
|
||||
const [logoffHours, logoffMinutes] = form.logoffTime?.split(":").map(Number) || [];
|
||||
|
||||
useEffect(() => {
|
||||
if (!logoffTime || !connection.connectedAircraft) return;
|
||||
if (!logoffHours || !logoffMinutes || !connection.connectedAircraft) return;
|
||||
|
||||
if (logoffDebounce) clearTimeout(logoffDebounce);
|
||||
|
||||
@@ -65,9 +66,8 @@ export const ConnectionBtn = () => {
|
||||
await aircraftMutation.mutateAsync({
|
||||
sessionId: connection.connectedAircraft.id,
|
||||
change: {
|
||||
esimatedLogoutTime: logoffTime
|
||||
? new Date(new Date().toDateString() + " " + logoffTime).toISOString()
|
||||
: null,
|
||||
esimatedLogoutTime:
|
||||
logoffHours && logoffMinutes ? getNextDateWithTime(logoffHours, logoffMinutes) : null,
|
||||
},
|
||||
});
|
||||
modalRef.current?.close();
|
||||
@@ -80,7 +80,7 @@ export const ConnectionBtn = () => {
|
||||
return () => {
|
||||
if (logoffDebounce) clearTimeout(logoffDebounce);
|
||||
};
|
||||
}, [logoffTime, connection.connectedAircraft]);
|
||||
}, [logoffHours, logoffMinutes, connection.connectedAircraft]);
|
||||
|
||||
const session = useSession();
|
||||
const uid = session.data?.user?.id;
|
||||
|
||||
Reference in New Issue
Block a user