"use client"; import { AccountStrike, Message } from "revolt-api"; import { ListCompactor } from "../common/ListCompactor"; import { CompactMessage } from "../cards/CompactMessage"; import { useRef, useState } from "react"; import { Button } from "../ui/button"; import { AlertDialog, AlertDialogAction, AlertDialogCancel, AlertDialogContent, AlertDialogFooter, AlertDialogHeader, AlertDialogTitle, AlertDialogTrigger, } from "../ui/alert-dialog"; import { Input } from "../ui/input"; import { createStrike } from "@/lib/actions"; import { useToast } from "../ui/use-toast"; import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow, } from "../ui/table"; import dayjs from "dayjs"; import { decodeTime } from "ulid"; /** * * @param param0 You have received an account strike, for one or more reasons: - REASON_HERE Further violations will result in suspension or a permanent ban depending on severity, please abide by the [Acceptable Usage Policy](https://revolt.chat/aup). * @returns */ export function RelevantModerationNotices({ userId, strikes, notices, }: { userId: string; strikes: AccountStrike[]; notices: Message[]; }) { const { toast } = useToast(); const [strikesDraft, setStrikesDraft] = useState(strikes); const givenReason = useRef(""); const additionalContext = useRef(""); return (

Strikes

Reason Created {strikesDraft.map((strike) => ( {strike.reason} {dayjs(decodeTime(strike._id)).fromNow()} ))}
Create Strike

You have received an account strike, for one or more reasons: (givenReason.current = e.currentTarget.value)} /> Further violations will result in suspension or a permanent ban depending on severity, please abide by the{" "} Acceptable Usage Policy . (additionalContext.current = e.currentTarget.value) } />

Cancel givenReason.current && createStrike( userId, givenReason.current, additionalContext.current ) .then((strike) => { setStrikesDraft((strikes) => [strike, ...strikes]); toast({ title: "Created strike" }); }) .catch((err) => toast({ title: "Failed to create strike!", description: String(err), variant: "destructive", }) ) .finally(() => { givenReason.current = ""; additionalContext.current = ""; }) } > Create

Alerts

} />
); }