Open-source document signature platform. Not affiliated with DocuSign.
TypeScript
fix(envelopes): show no copy sent for voided or declined envelopes (#238)
Kevin Rose549f3b17116c
diff --git a/src/components/envelopes/envelope-detail-shell.tsx b/src/components/envelopes/envelope-detail-shell.tsxindex 5b9a87e..855cd75 100644--- a/src/components/envelopes/envelope-detail-shell.tsx+++ b/src/components/envelopes/envelope-detail-shell.tsx@@ -29,6 +29,7 @@ import type {EnvelopeDetailData,EnvelopeDetailTimelineItem,} from "@/lib/envelopes";+import { describeCopyRecipientDelivery } from "@/lib/envelope-detail-copy";import { formatReminderInterval } from "@/lib/services/reminders";import {DEFAULT_ENVELOPE_DEADLINE_DAYS,@@ -991,9 +992,7 @@ export function EnvelopeDetailShell({Receives a copy</h3><p className="mt-1 text-sm leading-6 text-(--secondary)">- {activeRecord.status === "completed"- ? "Sent the finished document and its certificate."- : "Gets the finished document once everyone has signed."}+ {describeCopyRecipientDelivery(activeRecord.status)}</p><ul className="mt-3 space-y-2">{record.copyRecipients.map((recipient) => (diff --git a/src/lib/envelope-detail-copy.test.ts b/src/lib/envelope-detail-copy.test.tsnew file mode 100644index 0000000..f69ca30--- /dev/null+++ b/src/lib/envelope-detail-copy.test.ts@@ -0,0 +1,27 @@+import assert from "node:assert/strict";+import { test } from "node:test";++import { describeCopyRecipientDelivery } from "./envelope-detail-copy.ts";++test("copy recipient status copy distinguishes terminal outcomes from pending delivery (issue #238)", () => {+ assert.equal(+ describeCopyRecipientDelivery("draft"),+ "Gets the finished document once everyone has signed.",+ );+ assert.equal(+ describeCopyRecipientDelivery("sent"),+ "Gets the finished document once everyone has signed.",+ );+ assert.equal(+ describeCopyRecipientDelivery("completed"),+ "Sent the finished document and its certificate.",+ );+ assert.equal(+ describeCopyRecipientDelivery("voided"),+ "No copy was sent because this envelope was voided.",+ );+ assert.equal(+ describeCopyRecipientDelivery("declined"),+ "No copy was sent because this envelope was declined.",+ );+});diff --git a/src/lib/envelope-detail-copy.ts b/src/lib/envelope-detail-copy.tsnew file mode 100644index 0000000..e4dc865--- /dev/null+++ b/src/lib/envelope-detail-copy.ts@@ -0,0 +1,20 @@+import type { EnvelopeStatus } from "./types/domain.ts";++/**+ * Explains what happened (or will happen) to copy recipients on the sender's+ * envelope detail page. Copies are only sent once every signer completes the+ * envelope.+ */+export function describeCopyRecipientDelivery(status: EnvelopeStatus): string {+ switch (status) {+ case "completed":+ return "Sent the finished document and its certificate.";+ case "voided":+ return "No copy was sent because this envelope was voided.";+ case "declined":+ return "No copy was sent because this envelope was declined.";+ case "draft":+ case "sent":+ return "Gets the finished document once everyone has signed.";+ }+}