Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ type SignatureModalProps = SignatureCanvasProps & {
isInitials?: boolean;
translation: SignatureTranslations;
onEnd: (file: File) => void;
onSignAll?: (file: File) => void;
};

function SignatureModal(props: SignatureModalProps) {
Expand All @@ -32,6 +33,7 @@ function SignatureModal(props: SignatureModalProps) {
onEnd = () => {},
signMethods = '',
isInitials = false,
onSignAll,
translation: t
} = props;

Expand Down Expand Up @@ -146,6 +148,15 @@ function SignatureModal(props: SignatureModalProps) {
}
};

const handleSignAll = () => {
if (signatureFile && onSignAll) {
onSignAll(signatureFile);
sessionStorage.setItem(storageKey, fullName);
setShow(false);
resetState();
}
};

if (!show) {
return null;
}
Expand Down Expand Up @@ -446,6 +457,29 @@ function SignatureModal(props: SignatureModalProps) {
{t.clear}
</button>
)}
{onSignAll && (
<button
onClick={() => {
if (!isLoading) handleSignAll();
}}
disabled={isLoading || !signatureFile}
css={{
marginRight: '10px',
backgroundColor: '#535353',
color: '#fff',
'&:hover': {
backgroundColor: '#3a3a3a'
},
'&:disabled': {
'&:hover': {
cursor: 'not-allowed'
}
}
}}
>
{isInitials ? t.initials_confirm_all : t.confirm_all}
</button>
)}
<button
onClick={() => {
if (!isLoading) handleSubmit();
Expand Down
2 changes: 2 additions & 0 deletions src/elements/fields/SignatureField/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ function SignatureField({
disabled = false,
onEnd = () => {},
onClear = () => {},
onSignAll,
ReactPortal = null, // This is allowing the ability to pass a portal for the modal
children
}: any) {
Expand Down Expand Up @@ -53,6 +54,7 @@ function SignatureField({
onEnd={onEnd}
signMethods={servar.metadata?.sign_methods ?? ''}
isInitials={isInitials}
onSignAll={onSignAll}
translation={t}
/>
</Portal>
Expand Down
4 changes: 3 additions & 1 deletion src/elements/fields/SignatureField/translation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ export const defaultTranslations = {
draw_subtitle: 'Draw your signature here using your mouse or trackpad',
draw_instructions: 'Draw your signature in the box below',
confirm: 'Sign',
confirm_all: 'Sign All',
cancel: 'Cancel',
back: 'Back',
clear: 'Clear',
Expand All @@ -23,7 +24,8 @@ export const defaultTranslations = {
initials_draw_subtitle:
'Draw your initials here using your mouse or trackpad',
initials_draw_instructions: 'Draw your initials in the box below',
initials_confirm: 'Initial'
initials_confirm: 'Initial',
initials_confirm_all: 'Initial All'
} as const;

export type SignatureTranslations = typeof defaultTranslations;
Loading