Files
documenso/apps/remix/app/components/dialogs/sign-field-signature-dialog.tsx
David Nguyen 7f09ba72f4 feat: add envelopes (#2025)
This PR is handles the changes required to support envelopes. The new
envelope editor/signing page will be hidden during release.

The core changes here is to migrate the documents and templates model to
a centralized envelopes model.

Even though Documents and Templates are removed, from the user
perspective they will still exist as we remap envelopes to documents and
templates.
2025-10-14 21:56:36 +11:00

77 lines
2.1 KiB
TypeScript

import { useState } from 'react';
import { Trans } from '@lingui/react/macro';
import { createCallable } from 'react-call';
import { Button } from '@documenso/ui/primitives/button';
import {
Dialog,
DialogContent,
DialogFooter,
DialogHeader,
DialogTitle,
} from '@documenso/ui/primitives/dialog';
import { SignaturePad } from '@documenso/ui/primitives/signature-pad';
import { DocumentSigningDisclosure } from '../general/document-signing/document-signing-disclosure';
export type SignFieldSignatureDialogProps = {
initialSignature?: string;
typedSignatureEnabled?: boolean;
uploadSignatureEnabled?: boolean;
drawSignatureEnabled?: boolean;
};
export const SignFieldSignatureDialog = createCallable<
SignFieldSignatureDialogProps,
string | null
>(
({
call,
typedSignatureEnabled,
uploadSignatureEnabled,
drawSignatureEnabled,
initialSignature,
}) => {
const [localSignature, setLocalSignature] = useState(initialSignature);
return (
<Dialog open={true} onOpenChange={(value) => (!value ? call.end(null) : null)}>
<DialogContent position="center">
<div>
<DialogHeader>
<DialogTitle>
<Trans>Sign Signature Field</Trans>
</DialogTitle>
</DialogHeader>
<SignaturePad
value={localSignature ?? ''}
onChange={({ value }) => setLocalSignature(value)}
typedSignatureEnabled={typedSignatureEnabled}
uploadSignatureEnabled={uploadSignatureEnabled}
drawSignatureEnabled={drawSignatureEnabled}
/>
</div>
<DocumentSigningDisclosure />
<DialogFooter>
<Button type="button" variant="secondary" onClick={() => call.end(null)}>
<Trans>Cancel</Trans>
</Button>
<Button
type="button"
disabled={!localSignature}
onClick={() => call.end(localSignature || null)}
>
<Trans>Sign</Trans>
</Button>
</DialogFooter>
</DialogContent>
</Dialog>
);
},
);