diff --git a/apps/portal/src/components/questions/card/AnswerCard.tsx b/apps/portal/src/components/questions/card/AnswerCard.tsx
index 5407e95e..68e94d17 100644
--- a/apps/portal/src/components/questions/card/AnswerCard.tsx
+++ b/apps/portal/src/components/questions/card/AnswerCard.tsx
@@ -1,7 +1,7 @@
import { format } from 'date-fns';
import { ChatBubbleLeftRightIcon } from '@heroicons/react/24/outline';
-import { useAnswerVote } from '~/utils/questions/useVote';
+import useAnswerVote from '~/utils/questions/vote/useAnswerVote';
import type { VotingButtonsProps } from '../VotingButtons';
import VotingButtons from '../VotingButtons';
diff --git a/apps/portal/src/components/questions/card/question/BaseQuestionCard.tsx b/apps/portal/src/components/questions/card/question/BaseQuestionCard.tsx
index a917bc87..77b7f5c9 100644
--- a/apps/portal/src/components/questions/card/question/BaseQuestionCard.tsx
+++ b/apps/portal/src/components/questions/card/question/BaseQuestionCard.tsx
@@ -10,7 +10,7 @@ import type { QuestionsQuestionType } from '@prisma/client';
import { Button } from '@tih/ui';
import { useProtectedCallback } from '~/utils/questions/useProtectedCallback';
-import { useQuestionVote } from '~/utils/questions/useVote';
+import { useQuestionVote } from '~/utils/questions/vote/useQuestionVote';
import AddToListDropdown from '../../AddToListDropdown';
import type { CreateQuestionEncounterData } from '../../forms/CreateQuestionEncounterForm';
diff --git a/apps/portal/src/components/questions/comments/AnswerCommentListItem.tsx b/apps/portal/src/components/questions/comments/AnswerCommentListItem.tsx
new file mode 100644
index 00000000..0a4f76b6
--- /dev/null
+++ b/apps/portal/src/components/questions/comments/AnswerCommentListItem.tsx
@@ -0,0 +1,28 @@
+import useAnswerCommentVote from '~/utils/questions/vote/useAnswerCommentVote';
+
+import type { CommentListItemProps } from './CommentListItem';
+import CommentListItem from './CommentListItem';
+
+export type AnswerCommentListItemProps = Omit<
+ CommentListItemProps,
+ 'onDownvote' | 'onUpvote' | 'vote'
+> & {
+ answerCommentId: string;
+};
+
+export default function AnswerCommentListItem({
+ answerCommentId,
+ ...restProps
+}: AnswerCommentListItemProps) {
+ const { handleDownvote, handleUpvote, vote } =
+ useAnswerCommentVote(answerCommentId);
+
+ return (
+
+ );
+}
diff --git a/apps/portal/src/components/questions/AnswerCommentListItem.tsx b/apps/portal/src/components/questions/comments/CommentListItem.tsx
similarity index 67%
rename from apps/portal/src/components/questions/AnswerCommentListItem.tsx
rename to apps/portal/src/components/questions/comments/CommentListItem.tsx
index a51cd291..1039e51c 100644
--- a/apps/portal/src/components/questions/AnswerCommentListItem.tsx
+++ b/apps/portal/src/components/questions/comments/CommentListItem.tsx
@@ -1,37 +1,37 @@
import { format } from 'date-fns';
-import { useAnswerCommentVote } from '~/utils/questions/useVote';
+import type { BackendVote } from '../VotingButtons';
+import VotingButtons from '../VotingButtons';
-import VotingButtons from './VotingButtons';
-
-export type AnswerCommentListItemProps = {
- answerCommentId: string;
+export type CommentListItemProps = {
authorImageUrl: string;
authorName: string;
content: string;
createdAt: Date;
+ onDownvote: () => void;
+ onUpvote: () => void;
upvoteCount: number;
+ vote: BackendVote;
};
-export default function AnswerCommentListItem({
+export default function CommentListItem({
authorImageUrl,
authorName,
content,
createdAt,
upvoteCount,
- answerCommentId,
-}: AnswerCommentListItemProps) {
- const { handleDownvote, handleUpvote, vote } =
- useAnswerCommentVote(answerCommentId);
-
+ vote,
+ onDownvote,
+ onUpvote,
+}: CommentListItemProps) {
return (
diff --git a/apps/portal/src/components/questions/comments/QuestionCommentListItem.tsx b/apps/portal/src/components/questions/comments/QuestionCommentListItem.tsx
new file mode 100644
index 00000000..0a8cabd6
--- /dev/null
+++ b/apps/portal/src/components/questions/comments/QuestionCommentListItem.tsx
@@ -0,0 +1,28 @@
+import useQuestionCommentVote from '~/utils/questions/vote/useQuestionCommentVote';
+
+import type { CommentListItemProps } from './CommentListItem';
+import CommentListItem from './CommentListItem';
+
+export type QuestionCommentListItemProps = Omit<
+ CommentListItemProps,
+ 'onDownvote' | 'onUpvote' | 'vote'
+> & {
+ questionCommentId: string;
+};
+
+export default function QuestionCommentListItem({
+ questionCommentId,
+ ...restProps
+}: QuestionCommentListItemProps) {
+ const { handleDownvote, handleUpvote, vote } =
+ useQuestionCommentVote(questionCommentId);
+
+ return (
+
+ );
+}
diff --git a/apps/portal/src/pages/questions/[questionId]/[questionSlug]/answer/[answerId]/[answerSlug]/index.tsx b/apps/portal/src/pages/questions/[questionId]/[questionSlug]/answer/[answerId]/[answerSlug]/index.tsx
index 1fa4d2e0..410f03dc 100644
--- a/apps/portal/src/pages/questions/[questionId]/[questionSlug]/answer/[answerId]/[answerSlug]/index.tsx
+++ b/apps/portal/src/pages/questions/[questionId]/[questionSlug]/answer/[answerId]/[answerSlug]/index.tsx
@@ -5,8 +5,8 @@ import { useForm } from 'react-hook-form';
import { Button, TextArea } from '@tih/ui';
import { useGoogleAnalytics } from '~/components/global/GoogleAnalytics';
-import AnswerCommentListItem from '~/components/questions/AnswerCommentListItem';
import FullAnswerCard from '~/components/questions/card/FullAnswerCard';
+import AnswerCommentListItem from '~/components/questions/comments/AnswerCommentListItem';
import FullScreenSpinner from '~/components/questions/FullScreenSpinner';
import BackButtonLayout from '~/components/questions/layout/BackButtonLayout';
import PaginationLoadMoreButton from '~/components/questions/PaginationLoadMoreButton';
@@ -158,19 +158,18 @@ export default function QuestionPage() {
{/* TODO: Allow to load more pages */}
- {(answerCommentsData?.pages ?? []).flatMap(
- ({ processedQuestionAnswerCommentsData: comments }) =>
- comments.map((comment) => (
-
- )),
+ {(answerCommentsData?.pages ?? []).flatMap(({ data: comments }) =>
+ comments.map((comment) => (
+
+ )),
)}
diff --git a/apps/portal/src/pages/questions/[questionId]/[questionSlug]/index.tsx b/apps/portal/src/pages/questions/[questionId]/[questionSlug]/index.tsx
index c4db487d..9fdee125 100644
--- a/apps/portal/src/pages/questions/[questionId]/[questionSlug]/index.tsx
+++ b/apps/portal/src/pages/questions/[questionId]/[questionSlug]/index.tsx
@@ -5,9 +5,9 @@ import { useForm } from 'react-hook-form';
import { Button, Collapsible, HorizontalDivider, TextArea } from '@tih/ui';
import { useGoogleAnalytics } from '~/components/global/GoogleAnalytics';
-import AnswerCommentListItem from '~/components/questions/AnswerCommentListItem';
import FullQuestionCard from '~/components/questions/card/question/FullQuestionCard';
import QuestionAnswerCard from '~/components/questions/card/QuestionAnswerCard';
+import QuestionCommentListItem from '~/components/questions/comments/QuestionCommentListItem';
import FullScreenSpinner from '~/components/questions/FullScreenSpinner';
import BackButtonLayout from '~/components/questions/layout/BackButtonLayout';
import PaginationLoadMoreButton from '~/components/questions/PaginationLoadMoreButton';
@@ -245,19 +245,18 @@ export default function QuestionPage() {
/>
- {(commentData?.pages ?? []).flatMap(
- ({ processedQuestionCommentsData: comments }) =>
- comments.map((comment) => (
-
- )),
+ {(commentData?.pages ?? []).flatMap(({ data: comments }) =>
+ comments.map((comment) => (
+
+ )),
)}