fix newFormModal when selecting code form

This commit is contained in:
Matthias Nannt
2022-06-24 13:20:06 +09:00
parent 28bb9ba48d
commit 8648d0bb12
7 changed files with 9 additions and 18 deletions

View File

@@ -75,7 +75,7 @@ cp .env.example .env
```
npx prisma migrate dev
yarn prisma migrate dev
```

View File

@@ -35,10 +35,6 @@ export default function FormList() {
}
};
{
console.log(JSON.stringify(forms, null, 2));
}
return (
<>
<div>

View File

@@ -123,10 +123,6 @@ export default function Builder({ formId }) {
return <Loading />;
}
{
console.log("loaded nocode");
}
return (
<>
<SecondNavBar>

View File

@@ -38,7 +38,7 @@ export default function NewFormModal({
const [name, setName] = useState("");
const [formType, setFormType] = useState(formTypes[0]);
const submitForm = async (e) => {
const createFormAction = async (e) => {
e.preventDefault();
const form = await createForm({
name,
@@ -93,7 +93,7 @@ export default function NewFormModal({
</h2>
</div>
<form
onSubmit={(e) => submitForm(e)}
onSubmit={(e) => createFormAction(e)}
className="inline-block w-full p-2 overflow-hidden text-left align-bottom transition-all transform sm:align-middle"
>
<div>

View File

@@ -37,7 +37,7 @@ export default async function handle(
// Required fields in body: -
// Optional fields in body: title, elements, elementsDraft
else if (req.method === "POST") {
const { name, schema } = req.body;
const form = req.body;
const session = await getSession({ req });
// get unique alphanumeric ID
@@ -50,9 +50,8 @@ export default async function handle(
// create form in database
const result = await prisma.form.create({
data: {
...form,
id,
name: name || "",
schema: schema || {},
owner: { connect: { email: session?.user?.email } },
},
});

View File

@@ -11,9 +11,9 @@ CREATE TABLE "Form" (
"updatedAt" TIMESTAMP(3) NOT NULL,
"ownerId" INTEGER NOT NULL,
"formType" "FormType" NOT NULL DEFAULT E'NOCODE',
"name" TEXT NOT NULL,
"name" TEXT NOT NULL DEFAULT E'',
"published" BOOLEAN NOT NULL DEFAULT false,
"schema" JSONB NOT NULL,
"schema" JSONB NOT NULL DEFAULT '{}',
CONSTRAINT "Form_pkey" PRIMARY KEY ("id")
);

View File

@@ -23,9 +23,9 @@ model Form {
owner User @relation(fields: [ownerId], references: [id])
ownerId Int
formType FormType @default(NOCODE)
name String
name String @default("")
published Boolean @default(false)
schema Json
schema Json @default("{}")
submissionSessions SubmissionSession[]
pipelines Pipeline[]
noCodeForm NoCodeForm?