File tree 9 files changed +9
-19
lines changed
[slug]/[board]/(main)/[...post]
9 files changed +9
-19
lines changed Original file line number Diff line number Diff line change @@ -39,8 +39,8 @@ export default async function PostPage({
39
39
return < div > Post not found</ div > ;
40
40
}
41
41
42
- const isUpvoted = post . upvotes . some (
43
- ( upvote ) => upvote . user . id === session ?. user ?. id && upvote . isActive ,
42
+ const isUpvoted = post ? .upvotes . some (
43
+ ( upvote ) => upvote . user . id === session ?. user ?. id ,
44
44
) ;
45
45
46
46
return (
@@ -55,7 +55,8 @@ export default async function PostPage({
55
55
< UpvoteButton
56
56
isUpvoted = { isUpvoted }
57
57
postId = { post . id }
58
- upvoteCount = { post . _count . upvotes }
58
+ upvoteCount = { post ?. _count . upvotes }
59
+ userId = { session ?. user ?. id as string }
59
60
/>
60
61
< div className = "ml-0 mt-4 sm:ml-4 sm:mt-0" >
61
62
< h2 className = "text-xl font-bold text-gray-800 dark:text-gray-200 sm:text-2xl" >
Original file line number Diff line number Diff line change @@ -19,11 +19,7 @@ export async function GET(
19
19
user : true ,
20
20
project : true ,
21
21
board : true ,
22
- upvotes : {
23
- where : {
24
- isActive : true ,
25
- } ,
26
- } ,
22
+ upvotes : true ,
27
23
replies : true ,
28
24
} ,
29
25
} ) ;
Original file line number Diff line number Diff line change @@ -27,12 +27,11 @@ export async function GET(
27
27
const upvoteCount = await db . upvote . count ( {
28
28
where : {
29
29
postId : id ,
30
- isActive : true ,
31
30
} ,
32
31
} ) ;
33
32
34
33
return NextResponse . json ( {
35
- isUpvoted : upvote ?. isActive ?? false ,
34
+ isUpvoted : upvote ? true : false ,
36
35
count : upvoteCount ,
37
36
} ) ;
38
37
}
Original file line number Diff line number Diff line change @@ -35,7 +35,6 @@ export async function POST(request: NextRequest): Promise<NextResponse> {
35
35
const upvoteCount = await db . upvote . count ( {
36
36
where : {
37
37
postId : postId ,
38
- isActive : true ,
39
38
} ,
40
39
} ) ;
41
40
@@ -45,14 +44,12 @@ export async function POST(request: NextRequest): Promise<NextResponse> {
45
44
data : {
46
45
postId : postId ,
47
46
userId : user . id ,
48
- isActive : true ,
49
47
} ,
50
48
} ) ;
51
49
52
50
const upvoteCount = await db . upvote . count ( {
53
51
where : {
54
52
postId : postId ,
55
- isActive : true ,
56
53
} ,
57
54
} ) ;
58
55
Original file line number Diff line number Diff line change @@ -75,6 +75,7 @@ export const Roadmap = async ({ projectId }: { projectId: string }) => {
75
75
isUpvoted = { post . isUpvoted }
76
76
postId = { post . id }
77
77
upvoteCount = { post . upvotes . length }
78
+ userId = { post . userId }
78
79
/>
79
80
< div className = "flex flex-col" >
80
81
< CardTitle className = "ml-2 font-sans text-sm font-medium" >
Original file line number Diff line number Diff line change @@ -41,7 +41,7 @@ export const PostsCard: React.FC<PostsCardProps> = ({
41
41
} ) => {
42
42
const upvoteCount = post ?. upvoteCount ? post . upvoteCount : 0 ;
43
43
const isUpvoted = post ?. upvotes . some (
44
- ( upvote ) => upvote . userId === currentUserId && upvote . isActive ,
44
+ ( upvote ) => upvote . userId === currentUserId ,
45
45
) ;
46
46
47
47
const ListLayout = ( ) => (
Original file line number Diff line number Diff line change @@ -12,9 +12,6 @@ export const findPostById = async (id: string) => {
12
12
} ,
13
13
} ,
14
14
upvotes : {
15
- where : {
16
- isActive : true ,
17
- } ,
18
15
include : {
19
16
user : {
20
17
select : {
Original file line number Diff line number Diff line change 6
6
"commit" : " gacp" ,
7
7
"dev" : " next dev --turbo" ,
8
8
"build" : " next build" ,
9
- "start" : " PORT=56928 next start" ,
9
+ "start" : " next start" ,
10
10
"lint" : " eslint . --ext .ts,.tsx --fix -c .eslintrc.json" ,
11
11
"postinstall" : " npx prisma generate" ,
12
12
"format" : " prettier --write ." ,
Original file line number Diff line number Diff line change @@ -2,7 +2,6 @@ export type Upvote = {
2
2
id : string ;
3
3
postId : string ;
4
4
userId : string ;
5
- isActive : boolean ;
6
5
createdAt : Date ;
7
6
updatedAt : Date ;
8
7
} ;
You can’t perform that action at this time.
0 commit comments