From bd68daec83744874dce1e1d0fbb1baab94682315 Mon Sep 17 00:00:00 2001 From: AI Date: Wed, 11 Mar 2026 06:04:02 +0000 Subject: [PATCH] Add missing features: Login, Middleware, Tags Management, Edit Listing --- .../admin/listings/[slug]/page.tsx | 349 ++++++++++++++++++ src/app/(protected)/admin/listings/actions.ts | 117 ++++++ src/app/(protected)/admin/tags/actions.ts | 33 ++ src/app/(protected)/admin/tags/page.tsx | 119 ++++++ src/app/(protected)/layout.tsx | 89 +++++ src/app/api/auth/[...nextauth]/route.ts | 3 + src/app/login/page.tsx | 53 +++ src/app/page.tsx | 64 +--- src/middleware.ts | 29 ++ 9 files changed, 794 insertions(+), 62 deletions(-) create mode 100644 src/app/(protected)/admin/listings/[slug]/page.tsx create mode 100644 src/app/(protected)/admin/listings/actions.ts create mode 100644 src/app/(protected)/admin/tags/actions.ts create mode 100644 src/app/(protected)/admin/tags/page.tsx create mode 100644 src/app/(protected)/layout.tsx create mode 100644 src/app/api/auth/[...nextauth]/route.ts create mode 100644 src/app/login/page.tsx create mode 100644 src/middleware.ts 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 + + +
+ + +
+ + +
+ +
+ + +
+ +
+
+ + +
+
+ + +
+
+ +
+
+ + +
+
+ + +
+
+ + +
+
+ +
+
+ + +
+
+ + +
+
+ +
+ + +
+ +
+ +