"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, updateBotDiscoverability, } from "@/lib/actions"; import { useRef, useState } from "react"; import { useToast } from "../ui/use-toast"; import { Bot, User } from "revolt-api"; export function UserActions({ user, bot }: { user: User; bot?: Bot }) { const alertMessage = useRef(""); const { toast } = useToast(); const [botDraft, setBotDraft] = useState(bot); return (
{bot ? ( botDraft!.discoverable ? ( ) : ( ) ) : ( Account )} Are you sure you want to suspend this user? Cancel suspendUser(user._id) .then(() => toast({ title: "Suspended user" })) .catch((err) => toast({ title: "Failed to suspend user!", description: String(err), variant: "destructive", }) ) } > Suspend Are you sure you want to ban this user? Cancel banUser(user._id) .then(() => toast({ title: "Banned user" })) .catch((err) => toast({ title: "Failed to ban user!", description: String(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(user._id, alertMessage.current) .then(() => toast({ title: "Sent Alert" })) .catch((err) => toast({ title: "Failed to send alert!", description: String(err), variant: "destructive", }) ); }} > Send {/* Clear ({counts.pending}) Friend Requests Clear All ({counts.all}) Relations */}
); }