'use client' import { useRouter } from 'next/navigation' import { toast } from 'sonner' import { Pin, Lock, Trash2 } from 'lucide-react' import { updateForumThread, deleteForumThread } from '@/lib/actions' interface Props { threadId: string pinned: boolean locked: boolean canModerate: boolean isAuthor: boolean } export function ThreadActions({ threadId, pinned, locked, canModerate, isAuthor }: Props) { const router = useRouter() async function togglePinned() { const result = await updateForumThread(threadId, { pinned: !pinned }) if (result.error) { toast.error(result.error); return } router.refresh() } async function toggleLocked() { const result = await updateForumThread(threadId, { locked: !locked }) if (result.error) { toast.error(result.error); return } router.refresh() } async function handleDelete() { if (!confirm('Delete this thread? All comments are deleted too.')) return const result = await deleteForumThread(threadId) if (result.error) { toast.error(result.error); return } toast.success('Thread deleted') router.push('/forum') } return (