Skip to content

Commit 96c5ad4

Browse files
committed
Debug and partial fix problem creation flow
1 parent e38b7a2 commit 96c5ad4

File tree

3 files changed

+9
-1
lines changed

3 files changed

+9
-1
lines changed

app/api/orgs/[orgId]/problems/route.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,11 @@ export async function POST(
3636
try {
3737
const orgId = await getOrgIdFromNameId(NameIdSchema.parse(params.orgId));
3838
const body = await request.json();
39+
console.log("body", request.body);
3940

4041
const { testCases, ...problemData } = body;
41-
const validatedProblem = createProblemSchema.parse(problemData);
42+
console.log("testCases", testCases);
43+
const validatedProblem = createProblemSchema.parse(body);
4244
const validatedTestCases = z
4345
.array(createTestCaseSchema)
4446
.min(1)
@@ -53,6 +55,7 @@ export async function POST(
5355
return NextResponse.json(problem, { status: 201 });
5456
} catch (error) {
5557
if (error instanceof z.ZodError) {
58+
console.log(error.errors);
5659
return NextResponse.json({ error: error.errors }, { status: 400 });
5760
}
5861
return NextResponse.json(

app/api/orgs/[orgId]/problems/service.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@ export async function createProblem(
3434
);
3535
}
3636

37+
console.log("CREATE problem", problem);
38+
3739
return problem;
3840
});
3941
}

components/problem-editor.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,9 @@ export function ProblemEditor() {
181181
? `/api/orgs/${orgId}/problems/${problemId}`
182182
: `/api/orgs/${orgId}/problems`;
183183

184+
console.log("data.testCases", data.testCases);
185+
console.log("isEdit", isEdit);
186+
184187
// Transform the data to match the API's expected format
185188
const apiData = {
186189
code: data.code,

0 commit comments

Comments
 (0)