import type { Metadata } from "next"; import Link from "next/link"; import { notFound, redirect } from "next/navigation"; import { ActionForm, SubmitButton } from "@/components/forms"; import { PageHeader } from "@/components/status"; import { Card, CardContent, CardDescription, CardHeader, CardTitle } from "@/components/ui/card"; import { FieldGroup } from "@/components/ui/field"; import { api, getMe, unwrap } from "@/lib/api"; import { closeRoom, saveRoom } from "../../actions"; import { RoomFields } from "../../room-fields"; export const metadata: Metadata = { title: "Edit room" }; export default async function EditRoom({ params }: { params: Promise<{ n: string }> }) { const { n } = await params; if (!/^[0-9]{1,9}$/.test(n)) notFound(); const me = await getMe(); if (!me) redirect(`/signin?next=/rooms/${n}/edit`); const [{ rooms }, { links }] = await Promise.all([ api["hosted-rooms"].get({ query: { mine: "1" } }).then(unwrap), api.account.get().then(unwrap), ]); const room = rooms.find((r) => String(r.n) === n); if (!room) notFound(); return (
Back to rooms Owned by {room.ownerName} · {room.occupancy} here now l.adult)} />
Save
Close room Everyone in it is sent out. It can't be opened again. Close room
); }