This commit is contained in:
Timur Ercan
2023-02-24 16:43:42 +01:00
parent df669d26e4
commit b1519e147a
2 changed files with 30 additions and 21 deletions

View File

@@ -34,6 +34,12 @@ export default function PDFSigner(props: any) {
function onDialogClose(dialogResult: any) { function onDialogClose(dialogResult: any) {
// todo handle signature removed from field // todo handle signature removed from field
// todo remove free field if dialogresult is empty (or the id )
if (!dialogResult && dialogField.type === "FREE_SIGNATURE") {
onDeleteHandler(dialogField.id);
return;
}
const signature = { const signature = {
fieldId: dialogField.id, fieldId: dialogField.id,
type: dialogResult.type, type: dialogResult.type,
@@ -194,7 +200,6 @@ export default function PDFSigner(props: any) {
} }
try { try {
const deleted = toast.promise(
fetch("/api/documents/" + 0 + "/fields/" + field.id, { fetch("/api/documents/" + 0 + "/fields/" + field.id, {
method: "DELETE", method: "DELETE",
headers: { headers: {
@@ -217,9 +222,7 @@ export default function PDFSigner(props: any) {
style: { style: {
minWidth: "200px", minWidth: "200px",
}, },
} };
);
return deleted;
} catch (error) {} } catch (error) {}
} }
@@ -239,9 +242,9 @@ export default function PDFSigner(props: any) {
return res.json(); return res.json();
}), }),
{ {
loading: "Saving...", loading: "Adding...",
success: "Saved.", success: "Added.",
error: "Could not save :/", error: "Could not add :/",
}, },
{ {
id: "saving field", id: "saving field",

View File

@@ -102,7 +102,10 @@ export default function SignatureDialog(props: any) {
<div className="float-right"> <div className="float-right">
<Button <Button
color="secondary" color="secondary"
onClick={() => props.setOpen(false)} onClick={() => {
props.onClose();
props.setOpen(false);
}}
> >
Cancel Cancel
</Button> </Button>
@@ -153,7 +156,10 @@ export default function SignatureDialog(props: any) {
<div className="mt-10 float-right"> <div className="mt-10 float-right">
<Button <Button
color="secondary" color="secondary"
onClick={() => props.setOpen(false)} onClick={() => {
props.onClose();
props.setOpen(false);
}}
> >
Cancel Cancel
</Button> </Button>