-
Hi, I'm unsure what the issue is but I can't create a stage. route.js const prisma = new PrismaClient();
const storage = new SqlDatabase(prisma);
const manager = new BracketsManager(storage);
export async function POST(req: NextRequest) {
try {
const body = await req.json();
const { name, tournamentId, seeding } = body;
const stage = await manager.create.stage({
name,
tournamentId,
type: "single_elimination",
seeding,
});
return NextResponse.json(stage, { status: 200 });
} catch (error) {
console.error("Error creating stage:", error);
return NextResponse.json(
{ error: "Error creating stage" },
{ status: 500 }
);
}
} page.tsx async function createStage() {
try {
const response = await fetch("/api/hello", {
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({
name: "Example stage",
tournamentId: 0,
seeding: [
"Team 1",
"Team 2",
"Team 3",
"Team 4",
"Team 5",
"Team 6",
"Team 7",
"Team 8",
],
}),
});
if (!response.ok) {
throw new Error("Failed to create stage");
}
const data = await response.json();
console.log("Stage created:", data);
} catch (error) {
console.error("Error creating stage:", error);
}
}
export default function MyButton() {
return <button onClick={createStage}>Hello</button>;
} The error I'm getting. Error creating stage: TypeError: Cannot read properties of undefined (reading 'SINGLE_ELIMINATION')
at Object.to (webpack-internal:///(rsc)/./node_modules/brackets-prisma-db/dist/transformers/enum/stage-type.js:34:41)
at Object.to (webpack-internal:///(rsc)/./node_modules/brackets-prisma-db/dist/transformers/model/stage.js:11:44)
at handleStageInsert (webpack-internal:///(rsc)/./node_modules/brackets-prisma-db/dist/storage-handlers/insert-handlers/stage.js:24:48)
at handleInsert (webpack-internal:///(rsc)/./node_modules/brackets-prisma-db/dist/storage-handlers/insert.js:12:60)
at SqlDatabase.insert (webpack-internal:///(rsc)/./node_modules/brackets-prisma-db/dist/storage.js:11:52)
at storage.<computed> [as insert] (webpack-internal:///(rsc)/./node_modules/brackets-manager/dist/manager.js:138:38)
at StageCreator.insertStage (webpack-internal:///(rsc)/./node_modules/brackets-manager/dist/base/stage/creator.js:568:33)
at StageCreator.createStage (webpack-internal:///(rsc)/./node_modules/brackets-manager/dist/base/stage/creator.js:671:36)
at async StageCreator.singleElimination (webpack-internal:///(rsc)/./node_modules/brackets-manager/dist/base/stage/creator.js:100:23)
at async StageCreator.run (webpack-internal:///(rsc)/./node_modules/brackets-manager/dist/base/stage/creator.js:53:25)
at async POST (webpack-internal:///(rsc)/./src/app/api/hello/route.ts:23:23) |
Beta Was this translation helpful? Give feedback.
Answered by
Drarig29
Jun 20, 2024
Replies: 1 comment 14 replies
-
It looks like it's an issue with Prisma. What version of Prisma are you using? And was the stage still inserted in your database? |
Beta Was this translation helpful? Give feedback.
14 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Downgrading to Prisma 4 should work: Drarig29/brackets-storage#8