import { redirect } from "next/navigation"; import { requireUser } from "@/lib/auth/session"; import { createListing } from "@/lib/listings/service"; export const dynamic = "force-dynamic"; /** Crée immédiatement un brouillon puis ouvre le wizard : le brouillon est sauvegardé à chaque étape. */ export default async function Nouvelle({ searchParams }: { searchParams: Promise<{ type?: string; bien?: string }> }) { const u = await requireUser(); const sp = await searchParams; const l = await createListing(u.id, { listingType: sp.type === "RENT" ? "RENT" : sp.type === "SALE" ? "SALE" : undefined, propertyType: (["appartement", "condo", "maison", "jumele", "plex", "chalet", "terrain", "commercial", "autre"] as const).find((x) => x === sp.bien), wizardStep: sp.type ? 1 : 0 }); redirect(`/membre/annonces/${l.id}`); }