--- import { z } from 'astro/zod' import { Icon } from 'astro-icon/components' import BadgeSmall from '../../components/BadgeSmall.astro' import CommentModeration from '../../components/CommentModeration.astro' import MyPicture from '../../components/MyPicture.astro' import TimeFormatted from '../../components/TimeFormatted.astro' import UserBadge from '../../components/UserBadge.astro' import { commentStatusFilters, commentStatusFiltersZodEnum, getCommentStatusFilterInfo, getCommentStatusFilterValue, } from '../../constants/commentStatusFilters' import BaseLayout from '../../layouts/BaseLayout.astro' import { cn } from '../../lib/cn' import { zodParseQueryParamsStoringErrors } from '../../lib/parseUrlFilters' import { prisma } from '../../lib/prisma' import { urlWithParams } from '../../lib/urls' const user = Astro.locals.user if (!user || (!user.admin && !user.moderator)) { return Astro.rewrite('/404') } const { data: params } = zodParseQueryParamsStoringErrors( { status: commentStatusFiltersZodEnum.default('all'), page: z.number().int().positive().default(1), }, Astro ) const PAGE_SIZE = 20 const statusFilter = getCommentStatusFilterInfo(params.status) const [comments = [], totalComments = 0] = await Astro.locals.banners.try( 'Error fetching comments', async () => prisma.comment.findManyAndCount({ where: statusFilter.whereClause, include: { author: { select: { name: true, displayName: true, picture: true, }, }, service: { select: { name: true, slug: true, imageUrl: true, }, }, parent: { include: { author: true, }, }, votes: true, }, orderBy: [{ createdAt: 'desc' }, { id: 'asc' }], skip: (params.page - 1) * PAGE_SIZE, take: PAGE_SIZE, }), [] ) const totalPages = Math.ceil(totalComments / PAGE_SIZE) ---

> comments.moderate

{ commentStatusFilters.map((filter) => ( {filter.label} )) }
{ comments .map((comment) => ({ ...comment, statusFilterInfo: getCommentStatusFilterInfo(getCommentStatusFilterValue(comment)), })) .map((comment) => (
{/* Author Info */} {/* Service Link */} {!!comment.service.imageUrl && ( )} {comment.service.name} {/* Date */} {/* Status Badges */} {/* Link to Comment */} Open
{/* Parent Comment Context */} {comment.parent && (
Replying to
{comment.parent.content}
)} {/* Comment Content */}
{comment.content}
{/* Notes */} {comment.communityNote && (
Community Note

{comment.communityNote}

)} {comment.internalNote && (
Internal Note

{comment.internalNote}

)} {comment.privateContext && (
Private Context

{comment.privateContext}

)} {comment.orderId && (
Order ID

{comment.orderId}

{comment.orderIdStatus && ( {comment.orderIdStatus} )}
)} {(comment.kycRequested || comment.fundsBlocked) && (
Issue Flags
{comment.kycRequested && ( KYC Requested )} {comment.fundsBlocked && ( Funds Blocked )}
)}
)) }
{ totalPages > 1 && (
{params.page > 1 && ( Previous )} Page {params.page} of {totalPages} {params.page < totalPages && ( Next )}
) }