({
content,
searchParams,
}: {
content: {
id: number;
courseId: number;
commentCount: number;
possiblePath: string;
};
searchParams: QueryParams;
})
| 37 | dayjs.extend(relativeTime); |
| 38 | |
| 39 | const Comments = async ({ |
| 40 | content, |
| 41 | searchParams, |
| 42 | }: { |
| 43 | content: { |
| 44 | id: number; |
| 45 | courseId: number; |
| 46 | commentCount: number; |
| 47 | possiblePath: string; |
| 48 | }; |
| 49 | searchParams: QueryParams; |
| 50 | }) => { |
| 51 | const session = await getServerSession(authOptions); |
| 52 | if (!session?.user) { |
| 53 | return null; |
| 54 | } |
| 55 | const paginationInfo = paginationData(searchParams); |
| 56 | const q = constructCommentPrismaQuery( |
| 57 | searchParams, |
| 58 | paginationInfo, |
| 59 | content.id, |
| 60 | session.user.id, |
| 61 | ); |
| 62 | const data = await getComments(q, searchParams.parentId); |
| 63 | |
| 64 | if (!content.id) return null; |
| 65 | const modifiedSearchParams = { ...searchParams }; |
| 66 | delete modifiedSearchParams.parentId; |
| 67 | return ( |
| 68 | <div className="flex w-full flex-col gap-8"> |
| 69 | <div className="flex flex-col gap-4"> |
| 70 | {data.parentComment && ( |
| 71 | <Link |
| 72 | href={getUpdatedUrl( |
| 73 | `/courses/${content.courseId}/${content.possiblePath}`, |
| 74 | modifiedSearchParams, |
| 75 | {}, |
| 76 | )} |
| 77 | scroll={false} |
| 78 | > |
| 79 | <Button className="flex gap-2"> |
| 80 | <ArrowLeft className="size-4" /> Go back |
| 81 | </Button> |
| 82 | </Link> |
| 83 | )} |
| 84 | <div className="flex flex-col justify-between gap-4 md:flex-row md:items-center"> |
| 85 | <h2 |
| 86 | className={`text-xl font-bold tracking-tighter text-primary md:text-2xl`} |
| 87 | > |
| 88 | {!data.parentComment |
| 89 | ? `${content.commentCount} ${content.commentCount === 1 ? 'Comment' : 'Comments'}` |
| 90 | : `${data.parentComment.repliesCount} ${data.parentComment.repliesCount === 1 ? 'Reply' : 'Replies'}`} |
| 91 | </h2> |
| 92 | <div className="flex gap-2"> |
| 93 | <DropdownMenu modal={false}> |
| 94 | <DropdownMenuTrigger asChild> |
| 95 | <Button> |
| 96 | {searchParams.tabtype || TabType.mu} |
nothing calls this directly
no test coverage detected