diff --git a/apps/web/src/app/(signing)/sign/[token]/recipient-context.tsx b/apps/web/src/app/(signing)/sign/[token]/recipient-context.tsx index 30311274f..ea9228d27 100644 --- a/apps/web/src/app/(signing)/sign/[token]/recipient-context.tsx +++ b/apps/web/src/app/(signing)/sign/[token]/recipient-context.tsx @@ -37,11 +37,6 @@ export const RecipientProvider = ({ recipient, targetSigner = null, }: RecipientProviderProps) => { - // console.log({ - // recipient, - // targetSigner, - // isAssistantMode: !!targetSigner, - // }); return ( void | Promise; - onSignatureComplete: (nextSigner?: { email: string; name: string }) => void | Promise; - role: RecipientRole; - disabled?: boolean; - canModifyNextSigner?: boolean; -}; - -const formSchema = z.object({ - nextSigner: z - .object({ - email: z.string().email({ message: 'Please enter a valid email address' }).optional(), - name: z.string().min(1, { message: 'Name is required' }).optional(), - }) - .refine( - (data) => { - if (data.name) { - return !!data.email; - } - return true; - }, - { - message: 'Email is required when name is provided', - path: ['email'], - }, - ), -}); - -type TFormSchema = z.infer; - -export default function StepSignDialog({ - isSubmitting, - documentTitle, - fields, - fieldsValidated, - onSignatureComplete, - role, - disabled = false, - canModifyNextSigner = false, -}: StepSignDialogProps) { - const [step, setStep] = useState(1); - const [showDialog, setShowDialog] = useState(false); - - const isComplete = useMemo(() => !fieldsContainUnsignedRequiredField(fields), [fields]); - - const handleOpenChange = (open: boolean) => { - if (isSubmitting || !isComplete) { - return; - } - - setShowDialog(open); - }; - - const totalSteps = 2; - - const handleContinue = () => { - if (step < totalSteps) { - setStep(step + 1); - } - }; - - const form = useForm({ - resolver: zodResolver(formSchema), - defaultValues: { - nextSigner: { - email: '', - name: '', - }, - }, - }); - - const onFormSubmit = async (data: TFormSchema) => { - try { - await fieldsValidated(); - - if (!canModifyNextSigner || !data.nextSigner.email) { - await onSignatureComplete(); - return; - } - - await onSignatureComplete({ - email: data.nextSigner.email.trim().toLowerCase(), - name: data.nextSigner.name?.trim() ?? '', - }); - - setShowDialog(false); - form.reset(); - } catch (err) { - console.error(err); - } - }; - - return ( - <> - {!canModifyNextSigner ? ( - - - - - - - -
- {role === RecipientRole.VIEWER && Complete Viewing} - {role === RecipientRole.SIGNER && Complete Signing} - {role === RecipientRole.APPROVER && Complete Approval} -
-
- -
- {role === RecipientRole.VIEWER && ( - - - - You are about to complete viewing " - - {documentTitle} - - ". - -
Are you sure? -
-
- )} - {role === RecipientRole.SIGNER && ( - - - - You are about to complete signing " - - {documentTitle} - - ". - -
Are you sure? -
-
- )} - {role === RecipientRole.APPROVER && ( - - - - You are about to complete approving{' '} - - "{documentTitle}" - - . - -
Are you sure? -
-
- )} -
- - - - -
- - - -
-
-
-
- ) : ( - { - if (open) setStep(1); - }} - > - - - - - - {step === 1 && ( -
- Modify Next Signer -
- )} - - {step === 2 && ( -
- {role === RecipientRole.VIEWER && Complete Viewing} - {role === RecipientRole.SIGNER && Complete Signing} - {role === RecipientRole.APPROVER && Complete Approval} -
- )} -
- - {step === 1 && ( -
- - ( - - - Next Signer Email - - - - - - - )} - /> - - ( - - - Next Signer Name - - - - - - - )} - /> - - - )} - - {step === 2 && ( - <> -
- {role === RecipientRole.VIEWER && ( - - - - You are about to complete viewing " - - {documentTitle} - - ". - -
Are you sure? -
-
- )} - {role === RecipientRole.SIGNER && ( - - - - You are about to complete signing " - - {documentTitle} - - ". - -
Are you sure? -
-
- )} - {role === RecipientRole.APPROVER && ( - - - - You are about to complete approving{' '} - - "{documentTitle}" - - . - -
Are you sure? -
-
- )} -
- - - - )} - -
-
- {[...Array(totalSteps)].map((_, index) => ( -
- - - - - - {step === 1 && ( - - )} - - {step === 2 && ( - - )} - -
-
-
- )} - - ); -} diff --git a/apps/web/src/app/embed/completed.tsx b/apps/web/src/app/embed/completed.tsx index 13ab5701d..b50f007c4 100644 --- a/apps/web/src/app/embed/completed.tsx +++ b/apps/web/src/app/embed/completed.tsx @@ -10,7 +10,6 @@ export type EmbedDocumentCompletedPageProps = { }; export const EmbedDocumentCompleted = ({ name, signature }: EmbedDocumentCompletedPageProps) => { - console.log({ signature }); return (

diff --git a/packages/lib/server-only/document/complete-document-with-token.ts b/packages/lib/server-only/document/complete-document-with-token.ts index 9710652d1..9f77d0f45 100644 --- a/packages/lib/server-only/document/complete-document-with-token.ts +++ b/packages/lib/server-only/document/complete-document-with-token.ts @@ -103,8 +103,6 @@ export const completeDocumentWithToken = async ({ requestMetadata, nextSigner, }: CompleteDocumentWithTokenOptions) => { - console.log('completeDocumentWithToken == document-router', token, documentId, nextSigner); - const document = await getDocument({ token, documentId }); if (document.status !== DocumentStatus.PENDING) { @@ -166,8 +164,6 @@ export const completeDocumentWithToken = async ({ document.documentMeta?.modifyNextSigner && document.documentMeta?.signingOrder === DocumentSigningOrder.SEQUENTIAL ) { - console.log('delegateNextSigner == document-router', document.id, recipient.id, nextSigner); - await delegateNextSigner({ documentId: document.id, currentRecipientId: recipient.id, diff --git a/packages/trpc/server/recipient-router/router.ts b/packages/trpc/server/recipient-router/router.ts index 4637aba59..a7e8af232 100644 --- a/packages/trpc/server/recipient-router/router.ts +++ b/packages/trpc/server/recipient-router/router.ts @@ -439,14 +439,6 @@ export const recipientRouter = router({ .mutation(async ({ input, ctx }) => { const { token, documentId, authOptions, nextSigner } = input; - console.log( - 'completeDocumentWithToken == recipient-router', - token, - documentId, - authOptions, - nextSigner, - ); - return await completeDocumentWithToken({ token, documentId,