Skip to content

Commit d4ff0fb

Browse files
committed
feat: fix when the user not logged in can view the question
1 parent 95ac32a commit d4ff0fb

1 file changed

Lines changed: 5 additions & 5 deletions

File tree

app/(root)/question/[id]/page.tsx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -44,11 +44,11 @@ const page = async ({ params, searchParams }: URLProps) => {
4444
<Votes
4545
type="Question"
4646
itemId={JSON.stringify(result._id)}
47-
userId={JSON.stringify(mongoUser._id)}
47+
userId={JSON.stringify(mongoUser?._id)}
4848
upvotes={result.upvotes.length}
49-
hasUpvoted={result.upvotes.includes(mongoUser._id)}
49+
hasUpvoted={result.upvotes.includes(mongoUser?._id)}
5050
downvotes={result.downvotes.length}
51-
hasDownvoted={result.downvotes.includes(mongoUser._id)}
51+
hasDownvoted={result.downvotes.includes(mongoUser?._id)}
5252
hasSaved={mongoUser?.saved.includes(result._id)}
5353
/>
5454
</div>
@@ -95,7 +95,7 @@ const page = async ({ params, searchParams }: URLProps) => {
9595

9696
<AllAnswers
9797
questionId={result._id}
98-
userId={mongoUser._id}
98+
userId={mongoUser?._id}
9999
totalAnswers={result.answers.length}
100100
filter={searchParams.filter}
101101
page={searchParams.page}
@@ -104,7 +104,7 @@ const page = async ({ params, searchParams }: URLProps) => {
104104
<Answer
105105
question={result.content}
106106
questionId={JSON.stringify(result._id)}
107-
author={JSON.stringify(mongoUser._id)}
107+
author={JSON.stringify(mongoUser?._id)}
108108
/>
109109
</>
110110
);

0 commit comments

Comments
 (0)