import { trpc } from '@documenso/trpc/react'; import { Alert, AlertDescription } from '@documenso/ui/primitives/alert'; import { Button } from '@documenso/ui/primitives/button'; import { Dialog, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogTitle, } from '@documenso/ui/primitives/dialog'; import { Label } from '@documenso/ui/primitives/label'; import { Textarea } from '@documenso/ui/primitives/textarea'; import { useToast } from '@documenso/ui/primitives/use-toast'; import { plural } from '@lingui/core/macro'; import { Plural, Trans, useLingui } from '@lingui/react/macro'; import type * as DialogPrimitive from '@radix-ui/react-dialog'; import { useEffect, useState } from 'react'; export type EnvelopesBulkCancelDialogProps = { envelopeIds: string[]; open: boolean; onOpenChange: (open: boolean) => void; onSuccess?: () => void; } & Omit; export const EnvelopesBulkCancelDialog = ({ envelopeIds, open, onOpenChange, onSuccess, ...props }: EnvelopesBulkCancelDialogProps) => { const { t } = useLingui(); const { toast } = useToast(); const trpcUtils = trpc.useUtils(); const [reason, setReason] = useState(''); useEffect(() => { if (open) { setReason(''); } }, [open]); const { mutateAsync: bulkCancelEnvelopes, isPending } = trpc.envelope.bulk.cancel.useMutation({ onSuccess: async (result) => { await trpcUtils.document.findDocumentsInternal.invalidate(); if (result.failedIds.length > 0) { toast({ title: t`Documents partially cancelled`, description: t`${plural(result.cancelledCount, { one: '# document cancelled.', other: '# documents cancelled.', })} ${plural(result.failedIds.length, { one: '# document could not be cancelled.', other: '# documents could not be cancelled.', })}`, variant: 'destructive', }); } else { toast({ title: t`Documents cancelled`, description: plural(result.cancelledCount, { one: '# document has been cancelled.', other: '# documents have been cancelled.', }), variant: 'default', }); } onSuccess?.(); onOpenChange(false); }, onError: () => { toast({ title: t`Error`, description: t`An error occurred while cancelling the documents.`, variant: 'destructive', }); }, }); return ( Cancel Documents

Only pending documents you have permission to manage will be cancelled.

Once confirmed, the following will occur:

  • The document signing process will be stopped
  • Recipients will be notified that the document was cancelled
  • The documents will remain in your dashboard marked as Cancelled