Skip to content

Commit

Permalink
fix: フォーム作成時に質問が追加できない不具合の修正
Browse files Browse the repository at this point in the history
  • Loading branch information
rito528 committed May 18, 2024
1 parent b36f51c commit f7cb278
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/app/api/_schemas/RequestSchemas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ export const createQuestionSchema = z.object({
form_id: z.number(),
questions: z
.object({
id: z.number().nullable(),
title: z.string(),
description: z.string(),
question_type: z.enum(['TEXT', 'SINGLE', 'MULTIPLE']),
Expand All @@ -44,6 +43,7 @@ export const updateQuestionSchema = z.object({
form_id: z.number(),
questions: z
.object({
id: z.number().nullable(),
title: z.string(),
description: z.string(),
question_type: z.enum(['TEXT', 'SINGLE', 'MULTIPLE']),
Expand Down
7 changes: 5 additions & 2 deletions src/app/api/questions/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,10 @@ import { NextResponse } from 'next/server';
import { BACKEND_SERVER_URL } from '@/env';
import { getCachedToken } from '@/features/user/api/mcToken';
import { removeUndefinedOrNullRecords } from '@/generic/RecordExtra';
import { createQuestionSchema } from '../_schemas/RequestSchemas';
import {
createQuestionSchema,
updateQuestionSchema,
} from '../_schemas/RequestSchemas';
import { redirectByResponse } from '../util/responseOrErrorResponse';
import type { NextRequest } from 'next/server';

Expand Down Expand Up @@ -76,7 +79,7 @@ export async function PUT(req: NextRequest) {
return NextResponse.redirect('/');
}

const parsedUpdateQuestion = createQuestionSchema.safeParse(await req.json());
const parsedUpdateQuestion = updateQuestionSchema.safeParse(await req.json());

if (!parsedUpdateQuestion.success) {
return NextResponse.json(
Expand Down

0 comments on commit f7cb278

Please sign in to comment.