Moved Dispatch NAvbar component, to remove code dupl.; Fixed timezone bug in hub

This commit is contained in:
PxlLoewe
2026-01-31 22:11:46 +01:00
parent 580dc32ad0
commit d1c49a3208
18 changed files with 155 additions and 225 deletions

View File

@@ -9,6 +9,7 @@ import { Button } from "@repo/shared-components";
import { formatTimeRange } from "../../helper/timerange";
import toast from "react-hot-toast";
import Link from "next/link";
import { error } from "console";
interface BookingTimelineModalProps {
isOpen: boolean;
@@ -318,12 +319,7 @@ export const BookingTimelineModal = ({
{canDeleteBooking(booking.User.publicId) && (
<Button
onClick={() => deleteBooking(booking.id)}
className={`btn btn-xs ${
currentUser?.permissions.includes("ADMIN_EVENT") &&
booking.User.publicId !== currentUser.publicId
? "btn-error"
: "btn-neutral"
}`}
className={`btn btn-xs btn-error`}
title="Buchung löschen"
>
<Trash2 size={12} />

View File

@@ -5,13 +5,14 @@ import { getServerSession } from "../../auth/[...nextauth]/auth";
// DELETE /api/booking/[id] - Delete a booking
export const DELETE = async (req: NextRequest, { params }: { params: { id: string } }) => {
try {
console.log(params);
const session = await getServerSession();
if (!session?.user) {
return NextResponse.json({ error: "Not authenticated" }, { status: 401 });
}
const bookingId = params.id;
const bookingId = (await params).id;
console.log("Attempting to delete booking with ID:", bookingId);
// Find the booking
const booking = await prisma.booking.findUnique({
@@ -40,14 +41,14 @@ export const DELETE = async (req: NextRequest, { params }: { params: { id: strin
};
// PUT /api/booking/[id] - Update a booking
export const PUT = async (req: NextRequest, { params }: { params: { id: string } }) => {
export const PATCH = async (req: NextRequest, { params }: { params: { id: string } }) => {
try {
const session = await getServerSession();
if (!session?.user) {
return NextResponse.json({ error: "Not authenticated" }, { status: 401 });
}
const bookingId = params.id;
const bookingId = (await params).id;
const body = await req.json();
const { type, stationId, startTime, endTime } = body;

View File

@@ -3,9 +3,9 @@ import { Booking } from "@repo/db";
export const formatTimeRange = (booking: Booking, options?: { includeDate?: boolean }) => {
const start = new Date(booking.startTime);
const end = new Date(booking.endTime);
const timeRange = `${start.toLocaleTimeString("de-DE", { hour: "2-digit", minute: "2-digit" })} - ${end.toLocaleTimeString("de-DE", { hour: "2-digit", minute: "2-digit" })}`;
const timeRange = `${start.toLocaleTimeString("de-DE", { hour: "2-digit", minute: "2-digit", timeZone: "Europe/Berlin" })} - ${end.toLocaleTimeString("de-DE", { hour: "2-digit", minute: "2-digit", timeZone: "Europe/Berlin" })}`;
if (options?.includeDate) {
return `${start.toLocaleDateString("de-DE")} ${timeRange}`;
return `${start.toLocaleDateString("de-DE", { timeZone: "Europe/Berlin" })} ${timeRange}`;
}
return timeRange;
};