import Link from 'next/link'; import { notFound } from 'next/navigation'; import { CheckCircle2, Clock8 } from 'lucide-react'; import { getServerSession } from 'next-auth'; import { match } from 'ts-pattern'; import signingCelebration from '@documenso/assets/images/signing-celebration.png'; import { getDocumentAndSenderByToken } from '@documenso/lib/server-only/document/get-document-by-token'; import { getFieldsForToken } from '@documenso/lib/server-only/field/get-fields-for-token'; import { getRecipientByToken } from '@documenso/lib/server-only/recipient/get-recipient-by-token'; import { getRecipientSignatures } from '@documenso/lib/server-only/recipient/get-recipient-signatures'; import { DocumentStatus, FieldType } from '@documenso/prisma/client'; import { DocumentDownloadButton } from '@documenso/ui/components/document/document-download-button'; import { DocumentShareButton } from '@documenso/ui/components/document/document-share-button'; import { SigningCard3D } from '@documenso/ui/components/signing-card'; import { truncateTitle } from '~/helpers/truncate-title'; export type CompletedSigningPageProps = { params: { token?: string; }; }; export default async function CompletedSigningPage({ params: { token }, }: CompletedSigningPageProps) { if (!token) { return notFound(); } const document = await getDocumentAndSenderByToken({ token, }).catch(() => null); if (!document || !document.documentData) { return notFound(); } const truncatedTitle = truncateTitle(document.title); const { documentData } = document; const [fields, recipient] = await Promise.all([ getFieldsForToken({ token }), getRecipientByToken({ token }).catch(() => null), ]); if (!recipient) { return notFound(); } const signatures = await getRecipientSignatures({ recipientId: recipient.id }); const recipientName = recipient.name || fields.find((field) => field.type === FieldType.NAME)?.customText || recipient.email; const sessionData = await getServerSession(); const isLoggedIn = !!sessionData?.user; return (
Everyone has signed! You will receive an Email copy of the signed document.
)) .with({ deletedAt: null }, () => (You will receive an Email copy of the signed document once everyone has signed.
)) .otherwise(() => (This document has been cancelled by the owner and is no longer available for others to sign.
))}Want to send slick signing links like this one?{' '} Check out Documenso.
)}