From 5398026b806935473489ca7d80aab8f3b8926e76 Mon Sep 17 00:00:00 2001 From: Lucas Smith Date: Thu, 14 Nov 2024 21:37:42 +1100 Subject: [PATCH 1/3] feat: signature rejection (#1472) ## Description Adds support for rejecting a given document informing the document owner. Flows for resolving a rejection don't currently exist so it's up to the document owner to reach out to the recipient and work out a way to move forward via a new document or offline agreement. ## Related Issue ## Changes Made - Added new rejection properties to the recipient schema - Added API endpoints to support rejection - Added email templates for notifying the document owner and recipient - Added a dialog on the signing page to start the rejection flow. ## Testing Performed - Manually tested the flow end to end - Automated tests are planned --- .github/workflows/publish.yml | 2 +- .../app/(marketing)/singleplayer/client.tsx | 1 + .../document-page-view-recent-activity.tsx | 7 +- .../[id]/document-page-view-recipients.tsx | 31 +++- .../app/(dashboard)/documents/data-table.tsx | 2 +- .../src/app/(signing)/sign/[token]/page.tsx | 4 + .../sign/[token]/reject-document-dialog.tsx | 170 ++++++++++++++++++ .../(signing)/sign/[token]/rejected/page.tsx | 110 ++++++++++++ .../sign/[token]/signing-page-view.tsx | 47 ++--- .../(dashboard)/avatar/stack-avatar.tsx | 16 +- .../avatar/stack-avatars-with-tooltip.tsx | 43 ++++- .../document/document-history-sheet.tsx | 1 + .../template-document-invite.tsx | 17 ++ .../template-document-rejected.tsx | 48 +++++ .../template-document-rejection-confirmed.tsx | 48 +++++ .../email/templates/document-rejected.tsx | 70 ++++++++ .../document-rejection-confirmed.tsx | 70 ++++++++ packages/lib/client-only/recipient-type.ts | 5 + packages/lib/jobs/client.ts | 2 + .../emails/send-rejection-emails.ts | 169 +++++++++++++++++ .../server-only/admin/get-recipients-stats.ts | 1 + .../document/find-document-audit-logs.ts | 1 + .../document/reject-document-with-token.ts | 92 ++++++++++ .../document/send-completed-email.ts | 5 +- packages/lib/translations/de/common.po | 109 ++++++++--- packages/lib/translations/de/marketing.po | 1 - packages/lib/translations/de/web.js | 1 - packages/lib/translations/de/web.po | 87 ++++++--- packages/lib/translations/en/common.po | 123 ++++++++++--- packages/lib/translations/en/web.js | 1 - packages/lib/translations/en/web.po | 80 +++++++-- packages/lib/translations/es/common.po | 109 ++++++++--- packages/lib/translations/es/marketing.po | 1 - packages/lib/translations/es/web.po | 87 ++++++--- packages/lib/translations/fr/common.po | 109 ++++++++--- packages/lib/translations/fr/marketing.po | 1 - packages/lib/translations/fr/web.js | 1 - packages/lib/translations/fr/web.po | 85 ++++++--- packages/lib/types/document-audit-logs.ts | 12 ++ packages/lib/utils/document-audit-logs.ts | 10 ++ .../migration.sql | 5 + packages/prisma/schema.prisma | 2 + .../trpc/server/recipient-router/router.ts | 24 +++ .../trpc/server/recipient-router/schema.ts | 11 ++ 44 files changed, 1595 insertions(+), 226 deletions(-) create mode 100644 apps/web/src/app/(signing)/sign/[token]/reject-document-dialog.tsx create mode 100644 apps/web/src/app/(signing)/sign/[token]/rejected/page.tsx create mode 100644 packages/email/template-components/template-document-rejected.tsx create mode 100644 packages/email/template-components/template-document-rejection-confirmed.tsx create mode 100644 packages/email/templates/document-rejected.tsx create mode 100644 packages/email/templates/document-rejection-confirmed.tsx create mode 100644 packages/lib/jobs/definitions/emails/send-rejection-emails.ts create mode 100644 packages/lib/server-only/document/reject-document-with-token.ts delete mode 100644 packages/lib/translations/de/web.js delete mode 100644 packages/lib/translations/en/web.js delete mode 100644 packages/lib/translations/fr/web.js create mode 100644 packages/prisma/migrations/20241112223435_add_rejection_status_and_reason_to_recipient_schema/migration.sql diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 3d65574c6..5515b37a6 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -2,7 +2,7 @@ name: Publish Docker on: push: - branches: ["release"] + branches: ['release'] jobs: build_and_publish_platform_containers: diff --git a/apps/marketing/src/app/(marketing)/singleplayer/client.tsx b/apps/marketing/src/app/(marketing)/singleplayer/client.tsx index 35e1ccb7f..3062049b4 100644 --- a/apps/marketing/src/app/(marketing)/singleplayer/client.tsx +++ b/apps/marketing/src/app/(marketing)/singleplayer/client.tsx @@ -163,6 +163,7 @@ export const SinglePlayerClient = () => { expired: null, signedAt: null, readStatus: 'OPENED', + rejectionReason: null, documentDeletedAt: null, signingStatus: 'NOT_SIGNED', sendStatus: 'NOT_SENT', diff --git a/apps/web/src/app/(dashboard)/documents/[id]/document-page-view-recent-activity.tsx b/apps/web/src/app/(dashboard)/documents/[id]/document-page-view-recent-activity.tsx index b44175d51..f35a4255b 100644 --- a/apps/web/src/app/(dashboard)/documents/[id]/document-page-view-recent-activity.tsx +++ b/apps/web/src/app/(dashboard)/documents/[id]/document-page-view-recent-activity.tsx @@ -4,7 +4,7 @@ import { useMemo } from 'react'; import { Trans, msg } from '@lingui/macro'; import { useLingui } from '@lingui/react'; -import { CheckCheckIcon, CheckIcon, Loader, MailOpen } from 'lucide-react'; +import { AlertTriangle, CheckCheckIcon, CheckIcon, Loader, MailOpen } from 'lucide-react'; import { DateTime } from 'luxon'; import { match } from 'ts-pattern'; @@ -133,6 +133,11 @@ export const DocumentPageViewRecentActivity = ({