'use client'; import { useEffect, useRef, useState } from 'react'; import { REPORT_REASONS, REPORT_REASON_LABELS, type ProfileDTO, type ReportReason } from '@musicshare/shared'; import { client } from '@/lib/api'; /** "⋯" on someone else's profile: block/unblock and report. */ export function ProfileMenu({ profile, onChanged }: { profile: ProfileDTO; onChanged: () => void }) { const [open, setOpen] = useState(false); const [reporting, setReporting] = useState(false); const [confirmBlock, setConfirmBlock] = useState(false); const ref = useRef(null); const name = profile.user.displayName ?? profile.user.username; useEffect(() => { if (!open) return; const close = (e: MouseEvent) => !ref.current?.contains(e.target as Node) && setOpen(false); document.addEventListener('mousedown', close); return () => document.removeEventListener('mousedown', close); }, [open]); const toggleBlock = async () => { setOpen(false); setConfirmBlock(false); await (profile.isBlocked ? client.unblock(profile.user.username) : client.block(profile.user.username)); onChanged(); }; return (
{open && (
)} {confirmBlock && ( setConfirmBlock(false)} title={`Block ${name}?`}>

They won't be able to find you, see your profile or what you're playing, and you'll stop following each other. They aren't told.

)} {reporting && setReporting(false)} />}
); } /** Report someone's account, or one of their comments (`commentId`). */ export function ReportForm({ username, name, commentId, onClose }: { username: string; name: string; commentId?: string; onClose: () => void }) { const [reason, setReason] = useState(null); const [note, setNote] = useState(''); const [sent, setSent] = useState(false); const [error, setError] = useState(null); const submit = async (e: React.FormEvent) => { e.preventDefault(); if (!reason) return; try { const input = { reason, note: note.trim() || null }; await (commentId ? client.reportComment(commentId, input) : client.report(username, input)); setSent(true); } catch (err) { setError((err as Error).message); } }; if (sent) { return (

We'll take a look. If they're bothering you, you can also block them from this menu.

); } return (
What's wrong? {REPORT_REASONS.map((r) => ( ))}