--- import { Icon } from 'astro-icon/components' import { Markdown } from 'astro-remote' import { actions } from 'astro:actions' import { sortBy } from 'lodash-es' import AdminOnly from '../../components/AdminOnly.astro' import BadgeSmall from '../../components/BadgeSmall.astro' import InputSubmitButton from '../../components/InputSubmitButton.astro' import InputTextArea from '../../components/InputTextArea.astro' import MyPicture from '../../components/MyPicture.astro' import TimeFormatted from '../../components/TimeFormatted.astro' import Tooltip from '../../components/Tooltip.astro' import UserBadge from '../../components/UserBadge.astro' import { getKarmaTransactionActionInfo } from '../../constants/karmaTransactionActions' import { karmaUnlocks } from '../../constants/karmaUnlocks' import { SUPPORT_EMAIL } from '../../constants/project' import { getServiceSuggestionStatusInfo } from '../../constants/serviceSuggestionStatus' import { getServiceSuggestionTypeInfo } from '../../constants/serviceSuggestionType' import { getServiceUserRoleInfo } from '../../constants/serviceUserRoles' import { verificationStatusesByValue } from '../../constants/verificationStatus' import BaseLayout from '../../layouts/BaseLayout.astro' import { cn } from '../../lib/cn' import { makeUserWithKarmaUnlocks } from '../../lib/karmaUnlocks' import { prisma } from '../../lib/prisma' import { KYCNOTME_SCHEMA_MINI } from '../../lib/schema' import { formatDateShort } from '../../lib/timeAgo' import type { ProfilePage, WithContext } from 'schema-dts' const username = Astro.params.username if (!username) return Astro.rewrite('/404') const user = await Astro.locals.banners.try('user', async () => { return makeUserWithKarmaUnlocks( await prisma.user.findUnique({ where: { name: Astro.params.username }, select: { id: true, name: true, displayName: true, link: true, picture: true, spammer: true, verified: true, admin: true, moderator: true, verifiedLink: true, totalKarma: true, createdAt: true, lastLoginAt: true, _count: { select: { comments: true, commentVotes: true, karmaTransactions: true, }, }, karmaTransactions: { select: { id: true, points: true, action: true, description: true, createdAt: true, grantedBy: { select: { name: true, displayName: true, picture: true, }, }, comment: { select: { id: true, content: true, }, }, }, orderBy: { createdAt: 'desc' }, take: 5, }, suggestions: { select: { id: true, type: true, status: true, createdAt: true, service: { select: { id: true, name: true, slug: true, }, }, }, where: { service: { listedAt: { lte: new Date(), }, serviceVisibility: { in: ['PUBLIC', 'ARCHIVED'], }, }, }, orderBy: { createdAt: 'desc' }, take: 5, }, comments: { select: { id: true, content: true, createdAt: true, upvotes: true, status: true, service: { select: { id: true, name: true, slug: true, }, }, }, orderBy: { createdAt: 'desc' }, take: 5, }, commentVotes: { select: { id: true, downvote: true, createdAt: true, comment: { select: { id: true, content: true, service: { select: { id: true, name: true, slug: true, }, }, }, }, }, orderBy: { createdAt: 'desc' }, take: 5, }, serviceAffiliations: { select: { role: true, service: { select: { id: true, name: true, slug: true, imageUrl: true, verificationStatus: true, }, }, }, orderBy: [{ role: 'asc' }, { service: { name: 'asc' } }], }, internalNotes: { select: { id: true, content: true, createdAt: true, addedByUser: { select: { name: true, displayName: true, picture: true, }, }, }, orderBy: { createdAt: 'desc' }, }, }, }) ) }) if (!user) return Astro.rewrite('/404') const isCurrentUser = !!Astro.locals.user && user.id === Astro.locals.user.id --- , ]} breadcrumbs={[ { name: 'Users', url: '/u', }, { name: user.displayName ?? user.name, url: `/u/${user.name}`, }, ]} >
{ user.picture ? ( ) : (
) }

{user.displayName ?? user.name} {isCurrentUser && (You)}

{user.displayName &&

{user.name}

}
{ user.admin && ( admin ) } { user.verified && ( verified ) } { user.moderator && ( moderator ) }

Profile Information

  • Username

    {user.name}

  • Display Name

    {user.displayName ?? Not set}

  • { !!user.link && (
  • ) }
  • Karma

    {user.totalKarma.toLocaleString()}

Account Status

  • Account Type

    { user.admin && ( Admin ) } { user.verified && ( Verified User ) } { user.moderator && ( Moderator ) } { !user.admin && !user.verified && !user.moderator && ( Standard User ) }
  • Spam Status

    { user.spammer ? ( Spammer ) : ( Not Flagged ) }
  • Joined

    { formatDateShort(user.createdAt, { prefix: false, hourPrecision: true, caseType: 'sentence', }) }

  • Last login

    { formatDateShort(user.lastLoginAt, { prefix: false, hourPrecision: true, caseType: 'sentence', }) }

  • { user.verifiedLink && (
  • Verified as related to

    {user.verifiedLink}
  • ) }

Internal Notes (Admin only)

{ user.internalNotes.length === 0 ? (

No internal notes yet.

) : (
{user.internalNotes.map((note) => (
{!!note.addedByUser?.picture && ( )} {note.addedByUser ? (note.addedByUser.displayName ?? note.addedByUser.name) : 'System'}
))}
) }

Service Affiliations

{ user.serviceAffiliations.length > 0 ? ( ) : (

No service affiliations yet.

) }

Karma Unlocks

Earn karma to unlock features and privileges. Learn about karma

Recent Comments

{user._count.comments.toLocaleString()} comments
{ user.comments.length === 0 ? (

No comments yet.

) : (
{user.comments.map((comment) => ( ))}
Service Comment Status Upvotes Date
{comment.service.name}

{comment.content}

{comment.status} {comment.upvotes}
) }
{ user.karmaUnlocks.voteComments || user._count.commentVotes ? (

Recent Votes

{user._count.commentVotes.toLocaleString()} votes
{user.commentVotes.length === 0 ? (

No votes yet.

) : (
{user.commentVotes.map((vote) => ( ))}
Service Comment Vote Date
{vote.comment.service.name}

{vote.comment.content}

{vote.downvote ? ( ) : ( )}
)}
) : (

Recent Votes

Locked
) }

Recent Suggestions

{ user.suggestions.length === 0 ? (

No suggestions yet.

) : (
{user.suggestions.map((suggestion) => { const typeInfo = getServiceSuggestionTypeInfo(suggestion.type) const statusInfo = getServiceSuggestionStatusInfo(suggestion.status) return ( ) })}
Service Type Status Date
{suggestion.service.name} {typeInfo.label} {statusInfo.label}
) }

Recent Karma Transactions

{user.totalKarma.toLocaleString()} karma
{ user.karmaTransactions.length === 0 ? (

No karma transactions yet.

) : (
{user.karmaTransactions.map((transaction) => { const actionInfo = getKarmaTransactionActionInfo(transaction.action) return ( ) })}
Action Description Points Date
{actionInfo.label} {transaction.action === 'MANUAL_ADJUSTMENT' && transaction.grantedBy && ( <> from )} {transaction.description} = 0 ? 'text-green-400' : 'text-red-400' )} > {transaction.points >= 0 && '+'} {transaction.points}
) }