diff --git a/apps/portal/src/components/questions/CommentListItem.tsx b/apps/portal/src/components/questions/AnswerCommentListItem.tsx similarity index 63% rename from apps/portal/src/components/questions/CommentListItem.tsx rename to apps/portal/src/components/questions/AnswerCommentListItem.tsx index 1da9c7de..c65a379f 100644 --- a/apps/portal/src/components/questions/CommentListItem.tsx +++ b/apps/portal/src/components/questions/AnswerCommentListItem.tsx @@ -1,8 +1,11 @@ import { format } from 'date-fns'; +import { useAnswerCommentVote } from '~/utils/questions/useVote'; + import VotingButtons from './VotingButtons'; -export type CommentListItemProps = { +export type AnswerCommentListItemProps = { + answerCommentId: string; authorImageUrl: string; authorName: string; content: string; @@ -10,16 +13,26 @@ export type CommentListItemProps = { upvoteCount: number; }; -export default function CommentListItem({ +export default function AnswerCommentListItem({ authorImageUrl, authorName, content, createdAt, upvoteCount, -}: CommentListItemProps) { + answerCommentId, +}: AnswerCommentListItemProps) { + const { handleDownvote, handleUpvote, vote } = + useAnswerCommentVote(answerCommentId); + return (
- +
void; onUpvote: () => void; - voteState: VoteState; + vote: BackendVote | null; }; export type VotingButtonsProps = VotingButtonsCallbackProps & { @@ -17,16 +21,16 @@ export type VotingButtonsProps = VotingButtonsCallbackProps & { }; export default function VotingButtons({ - voteState, + vote, onDownvote, onUpvote, upvoteCount, size = 'md', }: VotingButtonsProps) { - const upvoteButtonVarient = - voteState === VoteState.UPVOTE ? 'secondary' : 'tertiary'; - const downvoteButtonVarient = - voteState === VoteState.DOWNVOTE ? 'secondary' : 'tertiary'; + const upvoteButtonVariant = + vote?.vote === 'UPVOTE' ? 'secondary' : 'tertiary'; + const downvoteButtonVariant = + vote?.vote === 'DOWNVOTE' ? 'secondary' : 'tertiary'; return (