import { useState } from 'react'; import { useQueryClient } from '@tanstack/react-query'; import { Dialog, DialogContent, DialogTitle, DialogDescription, } from '@/components/ui/dialog'; import { Button } from '@/components/ui/button'; import { Textarea } from '@/components/ui/textarea'; import { Label } from '@/components/ui/label'; import { useNostrPublish } from '@/hooks/useNostrPublish'; import { toast } from '@/hooks/useToast'; import { MODERATION_BAN_LABEL, MODERATION_LABEL_NAMESPACE, REPORT_KIND, } from '@/lib/communityUtils'; // ── Props ───────────────────────────────────────────────────────────────────── // // Only content-level bans remain. Agora's organization trust model has no // "member" tier any more, so banning a user wholesale is no longer // modeled — hide each unwanted post individually instead. interface BanConfirmDialogProps { /** The event ID to ban. */ eventId: string; /** The event author's pubkey. */ targetPubkey: string; /** The community `A` tag coordinate. */ communityATag: string; /** Display name for the dialog description. */ displayName?: string; open: boolean; onOpenChange: (open: boolean) => void; } export function BanConfirmDialog({ eventId, targetPubkey, communityATag, open, onOpenChange, }: BanConfirmDialogProps) { const queryClient = useQueryClient(); const { mutateAsync: publishEvent, isPending } = useNostrPublish(); const [reason, setReason] = useState(''); const handleSubmit = async () => { try { const tags: string[][] = [ ['e', eventId, 'other'], ['p', targetPubkey, 'other'], ['A', communityATag], ['L', MODERATION_LABEL_NAMESPACE], ['l', MODERATION_BAN_LABEL, MODERATION_LABEL_NAMESPACE], ]; await publishEvent({ kind: REPORT_KIND, content: reason.trim(), tags, }); // Invalidate community queries so the moderation overlay updates // immediately (removes banned content without a page refresh). await queryClient.invalidateQueries({ queryKey: ['community-members', communityATag] }); toast({ title: 'Post removed from organization' }); setReason(''); onOpenChange(false); } catch { toast({ title: 'Failed to remove post from organization', variant: 'destructive' }); } }; return ( Remove from organization This will hide the post from canonical organization views.