"use client"; import Link from "next/link"; import { Button, buttonVariants } from "../ui/button"; import { DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuTrigger, } from "../ui/dropdown-menu"; import { AlertDialog, AlertDialogAction, AlertDialogCancel, AlertDialogContent, AlertDialogDescription, AlertDialogFooter, AlertDialogHeader, AlertDialogTitle, AlertDialogTrigger, } from "../ui/alert-dialog"; import { Input } from "../ui/input"; import { banUser, sendAlert, suspendUser } from "@/lib/actions"; import { useRef } from "react"; import { useToast } from "../ui/use-toast"; export function UserActions({ id, counts, }: { id: string; counts: { pending: number; all: number }; }) { const alertMessage = useRef(""); const { toast } = useToast(); return (
Account Are you sure you want to suspend this user? Cancel suspendUser(id) .then(() => toast({ title: "Suspended user" })) .catch((err) => toast({ title: "Failed to suspend user!", description: err, variant: "destructive", }) ) } > Suspend Are you sure you want to ban this user? Cancel banUser(id) .then(() => toast({ title: "Banned user" })) .catch((err) => toast({ title: "Failed to ban user!", description: err, variant: "destructive", }) ) } > Ban { throw "Cancel immediate propagation."; }} > Send Alert Send Alert This will send a message from the Platform Moderation account. (alertMessage.current = e.currentTarget.value) } /> Cancel { if (!alertMessage.current) return; alertMessage.current = ""; sendAlert(id, alertMessage.current) .then(() => toast({ title: "Sent Alert" })) .catch((err) => toast({ title: "Failed to send alert!", description: err, variant: "destructive", }) ); }} > Send {/* Clear ({counts.pending}) Friend Requests Clear All ({counts.all}) Relations */}
); }