diff --git a/web/app/routes/resources+/comment/components/CommentForm.tsx b/web/app/routes/resources+/comment/components/CommentForm.tsx index 9619c218..f0d7678d 100644 --- a/web/app/routes/resources+/comment/components/CommentForm.tsx +++ b/web/app/routes/resources+/comment/components/CommentForm.tsx @@ -21,7 +21,7 @@ export function CommentForm({ shouldValidate: "onInput", defaultValue: { pageId: pageId, - content: "", + text: "", }, }); @@ -36,7 +36,7 @@ export function CommentForm({ - {fields.content.errors && ( - - {fields.content.errors?.join(", ")} - + {fields.text.errors && ( + {fields.text.errors?.join(", ")} )} > ); diff --git a/web/app/routes/resources+/comment/components/CommentList.tsx b/web/app/routes/resources+/comment/components/CommentList.tsx index 9b73daba..e7a21d12 100644 --- a/web/app/routes/resources+/comment/components/CommentList.tsx +++ b/web/app/routes/resources+/comment/components/CommentList.tsx @@ -72,7 +72,7 @@ export function CommentList({ - {comment.content} + {comment.text} ))} diff --git a/web/app/routes/resources+/comment/route.test.tsx b/web/app/routes/resources+/comment/route.test.tsx index 4eef8b26..de4bc857 100644 --- a/web/app/routes/resources+/comment/route.test.tsx +++ b/web/app/routes/resources+/comment/route.test.tsx @@ -36,7 +36,7 @@ describe("resource+/comment/route.ts action", () => { // prisma.create の返り値モック const mockComment = { id: 1, - content: "Hello", + text: "Hello", pageId: 1, userId: 123, createdAt: new Date(), @@ -52,7 +52,7 @@ describe("resource+/comment/route.ts action", () => { const formData = new FormData(); formData.append("intent", "create"); formData.append("pageId", "1"); - formData.append("content", "Hello"); + formData.append("text", "Hello"); const request = new Request("http://test.com/comment", { method: "POST", @@ -64,7 +64,7 @@ describe("resource+/comment/route.ts action", () => { // 正しい引数で create が呼ばれたか expect(prisma.comment.create).toHaveBeenCalledWith({ data: { - content: "Hello", + text: "Hello", pageId: 1, userId: 123, }, @@ -129,7 +129,7 @@ describe("resource+/comment/route.ts action", () => { vi.mocked(prisma.comment.findUnique).mockResolvedValueOnce({ id: 10, userId: 999, - content: "Hello", + text: "Hello", pageId: 1, createdAt: new Date(), updatedAt: new Date(), @@ -171,7 +171,7 @@ describe("resource+/comment/route.ts action", () => { vi.mocked(prisma.comment.findUnique).mockResolvedValueOnce({ id: 10, userId: 123, - content: "Hello", + text: "Hello", pageId: 1, createdAt: new Date(), updatedAt: new Date(), diff --git a/web/app/routes/resources+/comment/route.tsx b/web/app/routes/resources+/comment/route.tsx index f8eddce3..ed8f1fa6 100644 --- a/web/app/routes/resources+/comment/route.tsx +++ b/web/app/routes/resources+/comment/route.tsx @@ -6,7 +6,7 @@ import { prisma } from "~/utils/prisma"; export const createCommentSchema = z.object({ pageId: z.number(), - content: z.string().min(1, "Comment cannot be empty"), + text: z.string().min(1, "Comment cannot be empty"), intent: z.literal("create"), }); @@ -38,7 +38,7 @@ export async function action({ request }: ActionFunctionArgs) { case "create": { const comment = await prisma.comment.create({ data: { - content: submission.value.content, + text: submission.value.text, pageId: submission.value.pageId, userId: currentUser.id, },
- {fields.content.errors?.join(", ")} -
{fields.text.errors?.join(", ")}