diff --git a/apps/marketing/src/app/(marketing)/single-player-mode/[token]/success/page.tsx b/apps/marketing/src/app/(marketing)/single-player-mode/[token]/success/page.tsx index 138591a7e..6e02a470f 100644 --- a/apps/marketing/src/app/(marketing)/single-player-mode/[token]/success/page.tsx +++ b/apps/marketing/src/app/(marketing)/single-player-mode/[token]/success/page.tsx @@ -1,8 +1,9 @@ import { notFound } from 'next/navigation'; import { getDocumentAndRecipientByToken } from '@documenso/lib/server-only/document/get-document-by-token'; +import { DocumentStatus } from '@documenso/prisma/client'; -import SinglePlayerModeSuccess from '~/components/(marketing)/single-player-mode/single-player-mode-success'; +import { SinglePlayerModeSuccess } from '~/components/(marketing)/single-player-mode/single-player-mode-success'; export type SinglePlayerModeSuccessPageProps = { params: { @@ -21,7 +22,7 @@ export default async function SinglePlayerModeSuccessPage({ token, }).catch(() => null); - if (!document || document.status !== 'COMPLETED') { + if (!document || document.status !== DocumentStatus.COMPLETED) { return notFound(); } diff --git a/apps/marketing/src/app/(marketing)/single-player-mode/page.tsx b/apps/marketing/src/app/(marketing)/single-player-mode/page.tsx index 3dc8b5c85..3c76ebac0 100644 --- a/apps/marketing/src/app/(marketing)/single-player-mode/page.tsx +++ b/apps/marketing/src/app/(marketing)/single-player-mode/page.tsx @@ -6,6 +6,7 @@ import Link from 'next/link'; import { useRouter } from 'next/navigation'; import { useAnalytics } from '@documenso/lib/client-only/hooks/use-analytics'; +import { base64 } from '@documenso/lib/universal/base64'; import { putFile } from '@documenso/lib/universal/upload/put-file'; import { Field, Prisma, Recipient } from '@documenso/prisma/client'; import { Card, CardContent } from '@documenso/ui/primitives/card'; @@ -155,7 +156,7 @@ export default function SinglePlayerModePage() { const onFileDrop = async (file: File) => { try { const arrayBuffer = await file.arrayBuffer(); - const base64String = Buffer.from(arrayBuffer).toString('base64'); + const base64String = base64.encode(new Uint8Array(arrayBuffer)); setUploadedFile({ file, diff --git a/apps/marketing/src/components/(marketing)/single-player-mode/create-single-player-document.action.ts b/apps/marketing/src/components/(marketing)/single-player-mode/create-single-player-document.action.ts index d691abb95..f2bc074ea 100644 --- a/apps/marketing/src/components/(marketing)/single-player-mode/create-single-player-document.action.ts +++ b/apps/marketing/src/components/(marketing)/single-player-mode/create-single-player-document.action.ts @@ -3,7 +3,6 @@ import { createElement } from 'react'; import { DateTime } from 'luxon'; -import { nanoid } from 'nanoid'; import { PDFDocument } from 'pdf-lib'; import { match } from 'ts-pattern'; import { z } from 'zod'; @@ -13,6 +12,7 @@ import { render } from '@documenso/email/render'; import { DocumentSelfSignedEmailTemplate } from '@documenso/email/templates/document-self-signed'; import { FROM_ADDRESS, FROM_NAME, SERVICE_USER_EMAIL } from '@documenso/lib/constants/email'; import { insertFieldInPDF } from '@documenso/lib/server-only/pdf/insert-field-in-pdf'; +import { alphaid } from '@documenso/lib/universal/id'; import { getFile } from '@documenso/lib/universal/upload/get-file'; import { prisma } from '@documenso/prisma'; import { @@ -101,7 +101,7 @@ export const createSinglePlayerDocument = async ( const documentToken = await prisma.$transaction( async (tx) => { - const documentToken = nanoid(); + const documentToken = alphaid(); // Fetch service user who will be the owner of the document. const serviceUser = await tx.user.findFirstOrThrow({ @@ -179,7 +179,7 @@ export const createSinglePlayerDocument = async ( // Todo: Handle `downloadLink` const template = createElement(DocumentSelfSignedEmailTemplate, { - downloadLink: 'https://documenso.com', + downloadLink: `${process.env.NEXT_PUBLIC_MARKETING_URL}/single-player-mode/${documentToken}`, documentName: documentName, assetBaseUrl: process.env.NEXT_PUBLIC_WEBAPP_URL || 'http://localhost:3000', }); diff --git a/apps/marketing/src/components/(marketing)/single-player-mode/single-player-mode-success.tsx b/apps/marketing/src/components/(marketing)/single-player-mode/single-player-mode-success.tsx index 74718650c..65ad5bbfa 100644 --- a/apps/marketing/src/components/(marketing)/single-player-mode/single-player-mode-success.tsx +++ b/apps/marketing/src/components/(marketing)/single-player-mode/single-player-mode-success.tsx @@ -26,10 +26,7 @@ interface SinglePlayerModeSuccessProps { document: DocumentWithRecipient; } -export default function SinglePlayerModeSuccess({ - className, - document, -}: SinglePlayerModeSuccessProps) { +export const SinglePlayerModeSuccess = ({ className, document }: SinglePlayerModeSuccessProps) => { const { getFlag } = useFeatureFlags(); const isConfettiEnabled = getFlag('marketing_spm_confetti'); @@ -40,7 +37,7 @@ export default function SinglePlayerModeSuccess({ const { toast } = useToast(); - const handleShowDocumentDialog = async () => { + const onShowDocumentClick = async () => { if (isFetchingDocumentFile) { return; } @@ -103,7 +100,7 @@ export default function SinglePlayerModeSuccess({ />