parent
bde445859a
commit
048f9d1d31
@ -0,0 +1,49 @@
|
||||
import { ChatBubbleBottomCenterIcon } from '@heroicons/react/24/outline';
|
||||
import { Button } from '@tih/ui';
|
||||
|
||||
import type { CommentEntity } from '~/components/offers/types';
|
||||
|
||||
import { timeSinceNow } from '~/utils/offers/time';
|
||||
|
||||
type Props = Readonly<{
|
||||
comment: CommentEntity;
|
||||
handleReply: (replayingToId: string, userId: string) => void;
|
||||
}>;
|
||||
|
||||
export default function CommentCard({
|
||||
comment: {
|
||||
createdAt,
|
||||
message,
|
||||
// ProfileId,
|
||||
// replies,
|
||||
replyingToId,
|
||||
userId,
|
||||
username,
|
||||
},
|
||||
handleReply,
|
||||
}: Props) {
|
||||
return (
|
||||
<div className="flex pl-4">
|
||||
<div className="flex flex-col">
|
||||
<div className="flex flex-row font-bold">{username}</div>
|
||||
<div className="mt-2 mb-2 flex flex-row ">{message}</div>
|
||||
<div className="flex flex-row items-center justify-end space-x-4 ">
|
||||
<div className="flex flex-col text-sm font-light text-gray-400">{`${timeSinceNow(
|
||||
createdAt,
|
||||
)} ago`}</div>
|
||||
<div className="flex flex-col">
|
||||
<Button
|
||||
// Disabled={isLoading}
|
||||
icon={ChatBubbleBottomCenterIcon}
|
||||
isLabelHidden={true}
|
||||
label="Reply"
|
||||
size="sm"
|
||||
variant="tertiary"
|
||||
onClick={() => handleReply(replyingToId, userId)}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
@ -0,0 +1,30 @@
|
||||
import { Collapsible } from '@tih/ui';
|
||||
|
||||
import CommentCard from '~/components/offers/profile/comments/CommentCard';
|
||||
import type { CommentEntity } from '~/components/offers/types';
|
||||
|
||||
type Props = Readonly<{
|
||||
comment: CommentEntity;
|
||||
handleReply: (replayingToId: string, userId: string) => void;
|
||||
}>;
|
||||
|
||||
export default function ExpandableCommentCard({ comment, handleReply }: Props) {
|
||||
return (
|
||||
<div>
|
||||
<CommentCard comment={comment} handleReply={handleReply} />
|
||||
{comment.replies && (
|
||||
<div className="pl-4">
|
||||
<Collapsible label={`View more replies(${comment.replies.length})`}>
|
||||
{comment.replies.map((reply) => (
|
||||
<CommentCard
|
||||
key={reply.id}
|
||||
comment={reply}
|
||||
handleReply={handleReply}
|
||||
/>
|
||||
))}
|
||||
</Collapsible>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
}
|
Loading…
Reference in new issue