mirror of
https://github.com/documenso/documenso.git
synced 2025-11-10 04:22:32 +10:00
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.
77 lines
2.1 KiB
TypeScript
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>
|
|
);
|
|
},
|
|
);
|