+ {match({ isLoading, document })
+ .with({ isLoading: true }, () => (
+
+
+
+
+ Loading document...
+
+
+
+ ))
+ .with({ isLoading: false, document: undefined }, () => (
+
+
+ Failed to load document
+
+
+ ))
+ .with({ document: P.nonNullable }, ({ document }) => (
+ <>
+
+
+
{document.title}
+
+
+
+
+
+ {allowDocumentRejection && (
+
+
+
+ )}
+
+
+
+
{
+ setHasDocumentLoaded(true);
+ onDocumentReady?.();
+ }}
+ />
+
+
+ {/* Widget */}
+ {document.status !== DocumentStatus.COMPLETED && (
+
+
+ {/* Header */}
+
+
+
+ Sign document
+
+
+
+
+
+
+
+
+ Sign the document to complete the process.
+
+
+
+
+
+ {/* Form */}
+
+
+ {
+ <>
+
+
+
+ !isNameLocked && setFullName(e.target.value)}
+ />
+
+
+
+
+
+
+
+
+ {hasSignatureField && (
+
+
+
+ setSignature(v ?? '')}
+ typedSignatureEnabled={
+ document.documentMeta?.typedSignatureEnabled
+ }
+ uploadSignatureEnabled={
+ document.documentMeta?.uploadSignatureEnabled
+ }
+ drawSignatureEnabled={
+ document.documentMeta?.drawSignatureEnabled
+ }
+ />
+
+ )}
+ >
+ }
+
+
+
+
+
+
+ {pendingFields.length > 0 ? (
+
+ ) : (
+
+ )}
+
+
+
+ )}
+
+
+ {hasDocumentLoaded && (
+
+ {showPendingFieldTooltip && pendingFields.length > 0 && (
+
+ Click to insert field
+
+ )}
+
+ )}
+
+ {/* Fields */}
+ {hasDocumentLoaded && (
+
+ )}
+
+ {/* Completed fields */}
+ {document.status !== DocumentStatus.COMPLETED && (
+
+ )}
+ >
+ ))
+ .otherwise(() => null)}
+