41 lines
1.1 KiB
TypeScript
41 lines
1.1 KiB
TypeScript
import { db } from "@/db";
|
|
import FormEditorClient from "./client";
|
|
import { notFound } from "next/navigation";
|
|
|
|
export const dynamic = "force-dynamic";
|
|
|
|
export default async function AdminDashboardPage(
|
|
props: {
|
|
params: Promise<{ id: string }>;
|
|
}
|
|
) {
|
|
const params = await props.params;
|
|
const form = await db.query.forms.findFirst({
|
|
where: (f, { eq }) => eq(f.id, params.id),
|
|
});
|
|
|
|
if (!form) {
|
|
return notFound();
|
|
}
|
|
|
|
const questionsList = await db.query.questions.findMany({
|
|
where: (q, { eq }) => eq(q.formId, form.id),
|
|
orderBy: (q, { asc }) => [asc(q.displayOrder)],
|
|
});
|
|
|
|
return (
|
|
<div className="space-y-6 w-full max-w-6xl mx-auto p-4 md:p-6 pb-12">
|
|
<div className="flex items-center justify-between">
|
|
<div>
|
|
<h1 className="text-3xl font-bold tracking-tight">Edit Form</h1>
|
|
<p className="text-muted-foreground mt-1">
|
|
Customize form settings, add/edit questions, or upload images.
|
|
</p>
|
|
</div>
|
|
</div>
|
|
|
|
<FormEditorClient form={form} initialQuestions={questionsList} />
|
|
</div>
|
|
);
|
|
}
|