'use client'; import { api } from '@/app/_trpc/client'; import { pushModal, showConfirm } from '@/modals'; import type { IClientWithProject } from '@/types'; import { clipboard } from '@/utils/clipboard'; import { MoreHorizontal } from 'lucide-react'; import { useRouter } from 'next/navigation'; import { Button } from '../ui/button'; import { DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuLabel, DropdownMenuSeparator, DropdownMenuTrigger, } from '../ui/dropdown-menu'; import { toast } from '../ui/use-toast'; export function ClientActions(client: IClientWithProject) { const { id } = client; const router = useRouter(); const deletion = api.client.remove.useMutation({ onSuccess() { toast({ title: 'Success', description: 'Client revoked, incoming requests will be rejected.', }); router.refresh(); }, }); return ( Actions clipboard(id)}> Copy client ID { pushModal('EditClient', client); }} > Edit { showConfirm({ title: 'Revoke client', text: 'Are you sure you want to revoke this client? This action cannot be undone.', onConfirm() { deletion.mutate({ id, }); }, }); }} > Revoke ); }