"use client"; import { Report } from "revolt-api"; import { Textarea } from "../../ui/textarea"; import { Button } from "../../ui/button"; import { DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuLabel, DropdownMenuSeparator, DropdownMenuTrigger, } from "../../ui/dropdown-menu"; import { useState } from "react"; import { useToast } from "../../ui/use-toast"; import { rejectReport, reopenReport, resolveReport, sendAlert, updateReportNotes, } from "@/lib/actions"; import { AlertDialog, AlertDialogAction, AlertDialogCancel, AlertDialogContent, AlertDialogDescription, AlertDialogFooter, AlertDialogHeader, AlertDialogTitle, AlertDialogTrigger, } from "../../ui/alert-dialog"; import { ReportCard } from "../../cards/ReportCard"; const template: Record string> = { resolved: (ref) => `Your report (${ref}) has been actioned and appropriate action has been taken.`, invalid: (ref) => `Your report (${ref}) has been marked as invalid.`, false: (ref) => `Your report (${ref}) has been marked as false or spam. False reports may lead to additional action against your account.`, duplicate: (ref) => `Your report (${ref}) has been marked as a duplicate.`, "not enough evidence": (ref) => `Your report (${ref}) has not been actioned at this time due to a lack of supporting evidence, if you have additional information to support your report, please either report individual relevant messages or send an email to contact@revolt.chat.`, clarify: (ref) => `Your report (${ref}) needs clarification, please provide additional information.`, acknowledged: (ref) => `Your report (${ref}) has been acknowledged, we will be monitoring the situation.`, default: (ref) => `Report (${ref})\n\nNo template found for rejection reason, please specify.`, }; export function ReportActions({ report, reference, }: { report: Report; reference: string; }) { const { toast } = useToast(); const [reportDraft, setDraft] = useState(report); function rejectHandler(reason: string) { return async () => { try { const $set = await rejectReport(report._id, reason); setDraft((report) => ({ ...report, ...$set })); toast({ title: "Rejected report", }); } catch (err) { toast({ title: "Failed to reject report", description: String(err), variant: "destructive", }); } }; } return ( <>