36 lines
765 B
TypeScript
Executable File
36 lines
765 B
TypeScript
Executable File
import { prisma } from "@/prisma/prismaClient";
|
|
import { redirect } from "next/navigation";
|
|
|
|
export default function CreateGameSystem() {
|
|
async function create(form: FormData) {
|
|
"use server";
|
|
|
|
const name = form.get("name")?.toString();
|
|
if (!name) return;
|
|
const { id } = await prisma.gameSystem.create({
|
|
data: {
|
|
name,
|
|
},
|
|
select: {
|
|
id: true,
|
|
},
|
|
});
|
|
redirect(`/game-systems/${id}`);
|
|
}
|
|
|
|
return (
|
|
<form action={create}>
|
|
<input
|
|
type="text"
|
|
// {...bind}
|
|
name="name"
|
|
placeholder="Create a new game system..."
|
|
className="w-min"
|
|
/>
|
|
<button className="btn-primary p-2 px-2 ml-2" type="submit">
|
|
Create
|
|
</button>
|
|
</form>
|
|
);
|
|
}
|