import { PrinterReserveForm } from "@/app/printer/[printerId]/reserve/form";
import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card";
import { validateRequest } from "@/server/auth";
import { redirect } from "next/navigation";

import type { Metadata } from "next";

export const metadata: Metadata = {
	title: "Drucker reservieren",
};

interface PrinterReservePageProps {
	params: {
		printerId: string;
	};
}

export default async function PrinterReservePage(props: PrinterReservePageProps) {
	const { user } = await validateRequest();
	const { printerId } = props.params;

	if (!user) {
		return redirect("/");
	}

	return (
		<Card>
			<CardHeader>
				<CardTitle>Drucker reservieren</CardTitle>
			</CardHeader>
			<CardContent>
				<PrinterReserveForm userId={user?.id} printerId={printerId} />
			</CardContent>
		</Card>
	);
}
