ported schema builder
This commit is contained in:
23
actions/Schemas/create.ts
Normal file
23
actions/Schemas/create.ts
Normal file
@@ -0,0 +1,23 @@
|
||||
"use server";
|
||||
|
||||
import { prisma } from "@/prisma/prismaClient";
|
||||
import { redirect } from "next/navigation";
|
||||
|
||||
export const createSchema = async (form: FormData) => {
|
||||
const name = form.get("name")?.toString();
|
||||
const gsId = form.get("gsId")?.toString();
|
||||
|
||||
if (!name || !gsId) return;
|
||||
|
||||
const { id } = await prisma.schema.create({
|
||||
data: {
|
||||
name,
|
||||
schema: "{}",
|
||||
types: "{}",
|
||||
version: 0,
|
||||
gameSystemId: gsId,
|
||||
},
|
||||
select: { id: true },
|
||||
});
|
||||
redirect(`/game-systems/${gsId}/schema/${id}`);
|
||||
};
|
Reference in New Issue
Block a user