Buchungen werden in Connect Modal angezeigt (Pilot), new Booking form improvement

This commit is contained in:
PxlLoewe
2025-09-28 12:19:14 +02:00
parent ebeb2cf93a
commit dc4a3ab4d8
4 changed files with 140 additions and 27 deletions

View File

@@ -1,6 +1,6 @@
"use client";
import { useState, useEffect } from "react";
import { useEffect } from "react";
import { useForm } from "react-hook-form";
import { X, CalendarIcon, Clock } from "lucide-react";
import toast from "react-hot-toast";
@@ -10,15 +10,6 @@ import { createBookingAPI } from "(app)/_querys/bookings";
import { Button } from "@repo/shared-components";
import { useRouter } from "next/navigation";
interface Station {
id: number;
bosCallsign: string;
bosCallsignShort: string;
locationState: string;
operator: string;
aircraft: string;
}
interface NewBookingFormData {
type: "STATION" | "LST_01" | "LST_02" | "LST_03" | "LST_04";
stationId?: number;
@@ -197,7 +188,17 @@ export const NewBookingModal = ({
</label>
<input
type="datetime-local"
{...register("startTime", { required: "Startzeit ist erforderlich" })}
{...register("startTime", {
required: "Startzeit ist erforderlich",
onChange: (e) => {
if (new Date(e.target.value) >= new Date(watch("endTime"))) {
const newEndTime = new Date(
new Date(e.target.value).getTime() + 60 * 60 * 3000,
);
setValue("endTime", newEndTime.toISOString().slice(0, 16));
}
},
})}
className="input input-bordered w-full"
/>
{errors.startTime && (