parent
96b1a4c23f
commit
c0b3313acc
@ -0,0 +1,28 @@
|
||||
import { useAnswerCommentVote } from '~/utils/questions/useVote';
|
||||
|
||||
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 (
|
||||
<CommentListItem
|
||||
vote={vote}
|
||||
onDownvote={handleDownvote}
|
||||
onUpvote={handleUpvote}
|
||||
{...restProps}
|
||||
/>
|
||||
);
|
||||
}
|
@ -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 (
|
||||
<div className="flex gap-4 rounded-md border bg-white p-2">
|
||||
<VotingButtons
|
||||
size="sm"
|
||||
upvoteCount={upvoteCount}
|
||||
vote={vote}
|
||||
onDownvote={handleDownvote}
|
||||
onUpvote={handleUpvote}
|
||||
onDownvote={onDownvote}
|
||||
onUpvote={onUpvote}
|
||||
/>
|
||||
<div className="mt-1 flex flex-col gap-1">
|
||||
<div className="flex items-center gap-2">
|
@ -0,0 +1,28 @@
|
||||
import { useQuestionCommentVote } from '~/utils/questions/useVote';
|
||||
|
||||
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 (
|
||||
<CommentListItem
|
||||
vote={vote}
|
||||
onDownvote={handleDownvote}
|
||||
onUpvote={handleUpvote}
|
||||
{...restProps}
|
||||
/>
|
||||
);
|
||||
}
|
Loading…
Reference in new issue