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 { 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 CommentListItemProps = {
|
||||||
|
|
||||||
export type AnswerCommentListItemProps = {
|
|
||||||
answerCommentId: string;
|
|
||||||
authorImageUrl: string;
|
authorImageUrl: string;
|
||||||
authorName: string;
|
authorName: string;
|
||||||
content: string;
|
content: string;
|
||||||
createdAt: Date;
|
createdAt: Date;
|
||||||
|
onDownvote: () => void;
|
||||||
|
onUpvote: () => void;
|
||||||
upvoteCount: number;
|
upvoteCount: number;
|
||||||
|
vote: BackendVote;
|
||||||
};
|
};
|
||||||
|
|
||||||
export default function AnswerCommentListItem({
|
export default function CommentListItem({
|
||||||
authorImageUrl,
|
authorImageUrl,
|
||||||
authorName,
|
authorName,
|
||||||
content,
|
content,
|
||||||
createdAt,
|
createdAt,
|
||||||
upvoteCount,
|
upvoteCount,
|
||||||
answerCommentId,
|
vote,
|
||||||
}: AnswerCommentListItemProps) {
|
onDownvote,
|
||||||
const { handleDownvote, handleUpvote, vote } =
|
onUpvote,
|
||||||
useAnswerCommentVote(answerCommentId);
|
}: CommentListItemProps) {
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="flex gap-4 rounded-md border bg-white p-2">
|
<div className="flex gap-4 rounded-md border bg-white p-2">
|
||||||
<VotingButtons
|
<VotingButtons
|
||||||
size="sm"
|
size="sm"
|
||||||
upvoteCount={upvoteCount}
|
upvoteCount={upvoteCount}
|
||||||
vote={vote}
|
vote={vote}
|
||||||
onDownvote={handleDownvote}
|
onDownvote={onDownvote}
|
||||||
onUpvote={handleUpvote}
|
onUpvote={onUpvote}
|
||||||
/>
|
/>
|
||||||
<div className="mt-1 flex flex-col gap-1">
|
<div className="mt-1 flex flex-col gap-1">
|
||||||
<div className="flex items-center gap-2">
|
<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