File tree Expand file tree Collapse file tree 4 files changed +12
-14
lines changed Expand file tree Collapse file tree 4 files changed +12
-14
lines changed Original file line number Diff line number Diff line change @@ -21,7 +21,7 @@ export function CommentForm({
21
21
shouldValidate : "onInput" ,
22
22
defaultValue : {
23
23
pageId : pageId ,
24
- content : "" ,
24
+ text : "" ,
25
25
} ,
26
26
} ) ;
27
27
@@ -36,7 +36,7 @@ export function CommentForm({
36
36
< input type = "hidden" name = "pageId" value = { pageId } />
37
37
< input type = "hidden" name = "intent" value = "create" />
38
38
< Textarea
39
- { ...getTextareaProps ( fields . content ) }
39
+ { ...getTextareaProps ( fields . text ) }
40
40
placeholder = "comment"
41
41
className = { `min-h-[100px] ${ ! currentUserName && "bg-muted" } ` }
42
42
disabled = { ! currentUserName }
@@ -52,10 +52,8 @@ export function CommentForm({
52
52
{ fetcher . state !== "idle" ? "posting" : "post" }
53
53
</ Button >
54
54
</ fetcher . Form >
55
- { fields . content . errors && (
56
- < p className = "text-sm text-red-500" >
57
- { fields . content . errors ?. join ( ", " ) }
58
- </ p >
55
+ { fields . text . errors && (
56
+ < p className = "text-sm text-red-500" > { fields . text . errors ?. join ( ", " ) } </ p >
59
57
) }
60
58
</ >
61
59
) ;
Original file line number Diff line number Diff line change @@ -72,7 +72,7 @@ export function CommentList({
72
72
</ div >
73
73
</ div >
74
74
</ div >
75
- < div className = "mt-2 whitespace-pre-wrap" > { comment . content } </ div >
75
+ < div className = "mt-2 whitespace-pre-wrap" > { comment . text } </ div >
76
76
</ div >
77
77
) ) }
78
78
</ div >
Original file line number Diff line number Diff line change @@ -36,7 +36,7 @@ describe("resource+/comment/route.ts action", () => {
36
36
// prisma.create の返り値モック
37
37
const mockComment = {
38
38
id : 1 ,
39
- content : "Hello" ,
39
+ text : "Hello" ,
40
40
pageId : 1 ,
41
41
userId : 123 ,
42
42
createdAt : new Date ( ) ,
@@ -52,7 +52,7 @@ describe("resource+/comment/route.ts action", () => {
52
52
const formData = new FormData ( ) ;
53
53
formData . append ( "intent" , "create" ) ;
54
54
formData . append ( "pageId" , "1" ) ;
55
- formData . append ( "content " , "Hello" ) ;
55
+ formData . append ( "text " , "Hello" ) ;
56
56
57
57
const request = new Request ( "http://test.com/comment" , {
58
58
method : "POST" ,
@@ -64,7 +64,7 @@ describe("resource+/comment/route.ts action", () => {
64
64
// 正しい引数で create が呼ばれたか
65
65
expect ( prisma . comment . create ) . toHaveBeenCalledWith ( {
66
66
data : {
67
- content : "Hello" ,
67
+ text : "Hello" ,
68
68
pageId : 1 ,
69
69
userId : 123 ,
70
70
} ,
@@ -129,7 +129,7 @@ describe("resource+/comment/route.ts action", () => {
129
129
vi . mocked ( prisma . comment . findUnique ) . mockResolvedValueOnce ( {
130
130
id : 10 ,
131
131
userId : 999 ,
132
- content : "Hello" ,
132
+ text : "Hello" ,
133
133
pageId : 1 ,
134
134
createdAt : new Date ( ) ,
135
135
updatedAt : new Date ( ) ,
@@ -171,7 +171,7 @@ describe("resource+/comment/route.ts action", () => {
171
171
vi . mocked ( prisma . comment . findUnique ) . mockResolvedValueOnce ( {
172
172
id : 10 ,
173
173
userId : 123 ,
174
- content : "Hello" ,
174
+ text : "Hello" ,
175
175
pageId : 1 ,
176
176
createdAt : new Date ( ) ,
177
177
updatedAt : new Date ( ) ,
Original file line number Diff line number Diff line change @@ -6,7 +6,7 @@ import { prisma } from "~/utils/prisma";
6
6
7
7
export const createCommentSchema = z . object ( {
8
8
pageId : z . number ( ) ,
9
- content : z . string ( ) . min ( 1 , "Comment cannot be empty" ) ,
9
+ text : z . string ( ) . min ( 1 , "Comment cannot be empty" ) ,
10
10
intent : z . literal ( "create" ) ,
11
11
} ) ;
12
12
@@ -38,7 +38,7 @@ export async function action({ request }: ActionFunctionArgs) {
38
38
case "create" : {
39
39
const comment = await prisma . comment . create ( {
40
40
data : {
41
- content : submission . value . content ,
41
+ text : submission . value . text ,
42
42
pageId : submission . value . pageId ,
43
43
userId : currentUser . id ,
44
44
} ,
You can’t perform that action at this time.
0 commit comments