diff --git a/src/app/(protected)/admin/listings/[slug]/page.tsx b/src/app/(protected)/admin/listings/[slug]/page.tsx new file mode 100644 index 0000000..c1a1ebf --- /dev/null +++ b/src/app/(protected)/admin/listings/[slug]/page.tsx @@ -0,0 +1,349 @@ +import { prisma } from "@/lib/prisma"; +import { redirect } from "next/navigation"; +import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card"; +import { Button } from "@/components/ui/button"; +import { Input } from "@/components/ui/input"; +import { Label } from "@/components/ui/label"; +import { updateListing, deleteListing, addNote, addTagToListing, removeTagFromListing } from "../actions"; + +export default async function EditListingPage({ + params, +}: { + params: { slug: string }; +}) { + const listing = await prisma.listing.findUnique({ + where: { slug: params.slug }, + include: { + tags: { + include: { tag: true }, + }, + notes: { + orderBy: { createdAt: "desc" }, + }, + }, + }); + + if (!listing) { + redirect("/listings"); + } + + const allTags = await prisma.tag.findMany({ + orderBy: { name: "asc" }, + }); + + const listingTagIds = listing.tags.map((t) => t.tagId); + const availableTags = allTags.filter((t) => !listingTagIds.includes(t.id)); + + return ( +
+
+
+

✏️ Listing bearbeiten

+ + ← Zurück zur Detailseite + +
+ +
+ {/* Main Form */} +
+ + + Grunddaten + + +
+ + +
+ + +
+ +
+ + +
+ +
+
+ + +
+
+ + +
+
+ +
+
+ + +
+
+ + +
+
+ + +
+
+ +
+
+ + +
+
+ + +
+
+ +
+ + +
+ +
+ +