|
|
@ -1,14 +1,9 @@
|
|
|
|
import { signIn, useSession } from 'next-auth/react';
|
|
|
|
import { signIn, useSession } from 'next-auth/react';
|
|
|
|
import { useState } from 'react';
|
|
|
|
import { useState } from 'react';
|
|
|
|
import {
|
|
|
|
import { Button, Dialog, TextArea, useToast } from '@tih/ui';
|
|
|
|
ChatBubbleBottomCenterIcon,
|
|
|
|
|
|
|
|
TrashIcon,
|
|
|
|
|
|
|
|
} from '@heroicons/react/24/outline';
|
|
|
|
|
|
|
|
import { Button, Dialog, HorizontalDivider, TextArea, useToast } from '@tih/ui';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import { timeSinceNow } from '~/utils/offers/time';
|
|
|
|
import { timeSinceNow } from '~/utils/offers/time';
|
|
|
|
|
|
|
|
import { trpc } from '~/utils/trpc';
|
|
|
|
import { trpc } from '../../../../utils/trpc';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import type { Reply } from '~/types/offers';
|
|
|
|
import type { Reply } from '~/types/offers';
|
|
|
|
|
|
|
|
|
|
|
@ -125,48 +120,59 @@ export default function CommentCard({
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
return (
|
|
|
|
<>
|
|
|
|
<div className="flex space-x-3">
|
|
|
|
<div className="flex pl-2">
|
|
|
|
{/* <div className="flex-shrink-0">
|
|
|
|
<div className="flex w-full flex-col">
|
|
|
|
<img
|
|
|
|
<div className="flex flex-row font-bold">
|
|
|
|
alt=""
|
|
|
|
|
|
|
|
className="h-10 w-10 rounded-full"
|
|
|
|
|
|
|
|
src={`https://images.unsplash.com/photo-${comment.imageId}?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=facearea&facepad=2&w=256&h=256&q=80`}
|
|
|
|
|
|
|
|
/>
|
|
|
|
|
|
|
|
</div> */}
|
|
|
|
|
|
|
|
<div>
|
|
|
|
|
|
|
|
<div className="text-sm">
|
|
|
|
|
|
|
|
<p className="font-medium text-slate-900">
|
|
|
|
{user?.name ?? 'unknown user'}
|
|
|
|
{user?.name ?? 'unknown user'}
|
|
|
|
|
|
|
|
</p>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div className="mt-2 mb-2 flex flex-row ">{message}</div>
|
|
|
|
<div className="mt-1 text-sm text-slate-700">
|
|
|
|
<div className="flex flex-row items-center justify-start space-x-4 ">
|
|
|
|
<p className="break-all">{message}</p>
|
|
|
|
<div className="flex flex-col text-sm font-light text-slate-400">{`${timeSinceNow(
|
|
|
|
</div>
|
|
|
|
createdAt,
|
|
|
|
<div className="mt-2 space-x-2 text-sm">
|
|
|
|
)} ago`}</div>
|
|
|
|
<span className="font-medium text-slate-500">
|
|
|
|
|
|
|
|
{timeSinceNow(createdAt)} ago
|
|
|
|
|
|
|
|
</span>{' '}
|
|
|
|
|
|
|
|
<span className="font-medium text-slate-500">·</span>{' '}
|
|
|
|
{replyLength > 0 && (
|
|
|
|
{replyLength > 0 && (
|
|
|
|
<div
|
|
|
|
<>
|
|
|
|
className="text-primary-600 flex cursor-pointer flex-col text-sm hover:underline"
|
|
|
|
<button
|
|
|
|
|
|
|
|
className="font-medium text-slate-900"
|
|
|
|
|
|
|
|
type="button"
|
|
|
|
onClick={handleExpanded}>
|
|
|
|
onClick={handleExpanded}>
|
|
|
|
{isExpanded ? `Hide replies` : `View replies (${replyLength})`}
|
|
|
|
{isExpanded ? `Hide replies` : `View replies (${replyLength})`}
|
|
|
|
</div>
|
|
|
|
</button>
|
|
|
|
|
|
|
|
<span className="font-medium text-slate-500">·</span>{' '}
|
|
|
|
|
|
|
|
</>
|
|
|
|
)}
|
|
|
|
)}
|
|
|
|
{!disableReply && (
|
|
|
|
{!disableReply && (
|
|
|
|
<div className="flex flex-col">
|
|
|
|
<>
|
|
|
|
<Button
|
|
|
|
<button
|
|
|
|
icon={ChatBubbleBottomCenterIcon}
|
|
|
|
className="font-medium text-slate-900"
|
|
|
|
isLabelHidden={true}
|
|
|
|
type="button"
|
|
|
|
label="Reply"
|
|
|
|
onClick={() => setIsReplying(!isReplying)}>
|
|
|
|
size="sm"
|
|
|
|
Reply
|
|
|
|
variant="tertiary"
|
|
|
|
</button>
|
|
|
|
onClick={() => setIsReplying(!isReplying)}
|
|
|
|
<span className="font-medium text-slate-500">·</span>{' '}
|
|
|
|
/>
|
|
|
|
</>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
)}
|
|
|
|
)}
|
|
|
|
{deletable && (
|
|
|
|
{deletable && (
|
|
|
|
<>
|
|
|
|
<>
|
|
|
|
<Button
|
|
|
|
<button
|
|
|
|
|
|
|
|
className="font-medium text-slate-900"
|
|
|
|
disabled={deleteCommentMutation.isLoading}
|
|
|
|
disabled={deleteCommentMutation.isLoading}
|
|
|
|
icon={TrashIcon}
|
|
|
|
type="button"
|
|
|
|
isLabelHidden={true}
|
|
|
|
onClick={() => setIsDialogOpen(true)}>
|
|
|
|
isLoading={deleteCommentMutation.isLoading}
|
|
|
|
{deleteCommentMutation.isLoading ? 'Deleting...' : 'Delete'}
|
|
|
|
label="Delete"
|
|
|
|
</button>
|
|
|
|
size="sm"
|
|
|
|
|
|
|
|
variant="tertiary"
|
|
|
|
|
|
|
|
onClick={() => setIsDialogOpen(true)}
|
|
|
|
|
|
|
|
/>
|
|
|
|
|
|
|
|
{isDialogOpen && (
|
|
|
|
{isDialogOpen && (
|
|
|
|
<Dialog
|
|
|
|
<Dialog
|
|
|
|
isShown={isDialogOpen}
|
|
|
|
isShown={isDialogOpen}
|
|
|
@ -199,6 +205,12 @@ export default function CommentCard({
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
{!disableReply && isReplying && (
|
|
|
|
{!disableReply && isReplying && (
|
|
|
|
<div className="mt-2 mr-2">
|
|
|
|
<div className="mt-2 mr-2">
|
|
|
|
|
|
|
|
<form
|
|
|
|
|
|
|
|
onSubmit={(event) => {
|
|
|
|
|
|
|
|
event.preventDefault();
|
|
|
|
|
|
|
|
event.stopPropagation();
|
|
|
|
|
|
|
|
handleReply();
|
|
|
|
|
|
|
|
}}>
|
|
|
|
<TextArea
|
|
|
|
<TextArea
|
|
|
|
isLabelHidden={true}
|
|
|
|
isLabelHidden={true}
|
|
|
|
label="Comment"
|
|
|
|
label="Comment"
|
|
|
@ -225,11 +237,10 @@ export default function CommentCard({
|
|
|
|
/>
|
|
|
|
/>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
</form>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
)}
|
|
|
|
)}
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<HorizontalDivider />
|
|
|
|
|
|
|
|
</>
|
|
|
|
|
|
|
|
);
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|