Skip to content

Commit f4f98f5

Browse files
committedSep 27, 2024
refactor(core): 🔥 remove unused variable
1 parent 3af997d commit f4f98f5

File tree

9 files changed

+9
-19
lines changed

9 files changed

+9
-19
lines changed
 

‎app/[slug]/[board]/(main)/[...post]/page.tsx

+4-3
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,8 @@ export default async function PostPage({
3939
return <div>Post not found</div>;
4040
}
4141

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,
4444
);
4545

4646
return (
@@ -55,7 +55,8 @@ export default async function PostPage({
5555
<UpvoteButton
5656
isUpvoted={isUpvoted}
5757
postId={post.id}
58-
upvoteCount={post._count.upvotes}
58+
upvoteCount={post?._count.upvotes}
59+
userId={session?.user?.id as string}
5960
/>
6061
<div className="ml-0 mt-4 sm:ml-4 sm:mt-0">
6162
<h2 className="text-xl font-bold text-gray-800 dark:text-gray-200 sm:text-2xl">

‎app/api/boards/[id]/route.ts

+1-5
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,7 @@ export async function GET(
1919
user: true,
2020
project: true,
2121
board: true,
22-
upvotes: {
23-
where: {
24-
isActive: true,
25-
},
26-
},
22+
upvotes: true,
2723
replies: true,
2824
},
2925
});

‎app/api/upvote/[id]/route.ts

+1-2
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,11 @@ export async function GET(
2727
const upvoteCount = await db.upvote.count({
2828
where: {
2929
postId: id,
30-
isActive: true,
3130
},
3231
});
3332

3433
return NextResponse.json({
35-
isUpvoted: upvote?.isActive ?? false,
34+
isUpvoted: upvote ? true : false,
3635
count: upvoteCount,
3736
});
3837
}

‎app/api/upvote/route.ts

-3
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ export async function POST(request: NextRequest): Promise<NextResponse> {
3535
const upvoteCount = await db.upvote.count({
3636
where: {
3737
postId: postId,
38-
isActive: true,
3938
},
4039
});
4140

@@ -45,14 +44,12 @@ export async function POST(request: NextRequest): Promise<NextResponse> {
4544
data: {
4645
postId: postId,
4746
userId: user.id,
48-
isActive: true,
4947
},
5048
});
5149

5250
const upvoteCount = await db.upvote.count({
5351
where: {
5452
postId: postId,
55-
isActive: true,
5653
},
5754
});
5855

‎components/common/roadmap.tsx

+1
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ export const Roadmap = async ({ projectId }: { projectId: string }) => {
7575
isUpvoted={post.isUpvoted}
7676
postId={post.id}
7777
upvoteCount={post.upvotes.length}
78+
userId={post.userId}
7879
/>
7980
<div className="flex flex-col">
8081
<CardTitle className="ml-2 font-sans text-sm font-medium">

‎components/posts/card.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ export const PostsCard: React.FC<PostsCardProps> = ({
4141
}) => {
4242
const upvoteCount = post?.upvoteCount ? post.upvoteCount : 0;
4343
const isUpvoted = post?.upvotes.some(
44-
(upvote) => upvote.userId === currentUserId && upvote.isActive,
44+
(upvote) => upvote.userId === currentUserId,
4545
);
4646

4747
const ListLayout = () => (

‎helpers/posts/findPostById.ts

-3
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,6 @@ export const findPostById = async (id: string) => {
1212
},
1313
},
1414
upvotes: {
15-
where: {
16-
isActive: true,
17-
},
1815
include: {
1916
user: {
2017
select: {

‎package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"commit": "gacp",
77
"dev": "next dev --turbo",
88
"build": "next build",
9-
"start": "PORT=56928 next start",
9+
"start": "next start",
1010
"lint": "eslint . --ext .ts,.tsx --fix -c .eslintrc.json",
1111
"postinstall": "npx prisma generate",
1212
"format": "prettier --write .",

‎types/upvote.ts

-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ export type Upvote = {
22
id: string;
33
postId: string;
44
userId: string;
5-
isActive: boolean;
65
createdAt: Date;
76
updatedAt: Date;
87
};

0 commit comments

Comments
 (0)
Please sign in to comment.