implemented #76

This commit is contained in:
PxlLoewe
2025-07-23 19:06:35 -07:00
parent 115296d7f7
commit 0b0f4fac2f
6 changed files with 45 additions and 6 deletions

View File

@@ -7,6 +7,7 @@ import { useMutation } from "@tanstack/react-query";
import { Prisma } from "@repo/db";
import { changeDispatcherAPI } from "_querys/dispatcher";
import { Button, getNextDateWithTime } from "@repo/shared-components";
import { Ghost } from "lucide-react";
export const ConnectionBtn = () => {
const modalRef = useRef<HTMLDialogElement>(null);
@@ -14,6 +15,7 @@ export const ConnectionBtn = () => {
const [form, setForm] = useState({
logoffTime: "",
selectedZone: "LST_01",
ghostMode: false,
});
const changeDispatcherMutation = useMutation({
mutationFn: ({ id, data }: { id: number; data: Prisma.ConnectedDispatcherUpdateInput }) =>
@@ -45,7 +47,7 @@ export const ConnectionBtn = () => {
modalRef.current?.showModal();
}}
>
Verbunden
Verbunden {connection.ghostMode && <Ghost />}
</button>
) : (
<button
@@ -89,6 +91,21 @@ export const ConnectionBtn = () => {
<p className="fieldset-label">Du kannst diese Zeit später noch anpassen.</p>
)}
</fieldset>
{session.data?.user.permissions.includes("ADMIN_KICK") &&
connection.status === "disconnected" && (
<fieldset className="fieldset bg-base-100 border-base-300 rounded-box w-full border p-4">
<legend className="fieldset-legend">Ghost-Mode</legend>
<label className="label">
<input
checked={form.ghostMode}
onChange={(e) => setForm({ ...form, ghostMode: e.target.checked })}
type="checkbox"
className="checkbox"
/>
Vesteckt deine Verbindung auf dem Tracker
</label>
</fieldset>
)}
<div className="modal-action flex w-full justify-between">
<form method="dialog" className="flex w-full justify-between">
<button className="btn btn-soft">Zurück</button>
@@ -138,6 +155,7 @@ export const ConnectionBtn = () => {
form.logoffTime && logoffHours !== undefined && logoffMinutes !== undefined
? getNextDateWithTime(logoffHours, logoffMinutes).toISOString()
: "",
form.ghostMode,
);
}}
className="btn btn-soft btn-info"