mirror of
https://github.com/OpenSignLabs/OpenSign.git
synced 2026-09-05 01:07:39 +02:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
affbfc5061 | ||
|
|
886ede2007 | ||
|
|
a3936c66aa | ||
|
|
d98453ffc2 | ||
|
|
7424912455 | ||
|
|
e095495081 | ||
|
|
eb4ce5544f | ||
|
|
8eef17834d | ||
|
|
40ed5e2353 | ||
|
|
2aa4c8c361 | ||
|
|
e5b120fa36 | ||
|
|
1e026f8ebd | ||
|
|
e5c7da0847 | ||
|
|
2e67002768 | ||
|
|
9c03649d48 | ||
|
|
df436b3b20 | ||
|
|
34acf4170e | ||
|
|
f9a13c880a | ||
|
|
df7cd45be6 | ||
|
|
b22d70c833 | ||
|
|
1ef8e8aa6a | ||
|
|
2aa58b7eb3 | ||
|
|
9fb61509c4 | ||
|
|
b99dc875ed | ||
|
|
7da31f00c3 | ||
|
|
894ccd1244 | ||
|
|
8d90e6e808 | ||
|
|
79771f725e | ||
|
|
786f56941a | ||
|
|
8fae910d46 | ||
|
|
8b5920bba3 | ||
|
|
03f1451e64 | ||
|
|
1d2a975b5f | ||
|
|
3db32979dc | ||
|
|
110431dae2 | ||
|
|
ade228f756 | ||
|
|
9b18a66f22 | ||
|
|
c88de90a24 | ||
|
|
737d66d97d | ||
|
|
b77b57d3fd | ||
|
|
240c7766c1 | ||
|
|
508b2e43d3 | ||
|
|
d6129e21e9 | ||
|
|
a11a2444f1 | ||
|
|
db1fb1c0e1 | ||
|
|
7f326b19aa | ||
|
|
2a1d7d2502 | ||
|
|
01edfce6e7 | ||
|
|
9176b8f99c | ||
|
|
0ff2e57424 | ||
|
|
567966866c | ||
|
|
e03f07a8ef | ||
|
|
9915a700bb | ||
|
|
f0a406a397 | ||
|
|
851ea24be4 | ||
|
|
50c4eff790 | ||
|
|
e69e6998c9 | ||
|
|
c87873cfb6 | ||
|
|
b09becf3eb | ||
|
|
0673242f41 | ||
|
|
1776931df5 | ||
|
|
a2c0921345 | ||
|
|
ad0a974c14 | ||
|
|
2d4a7d336c | ||
|
|
8d2df87de3 | ||
|
|
873e7e2068 | ||
|
|
3fcb1d0138 | ||
|
|
ce41f9a0ce | ||
|
|
34d8ed19bf | ||
|
|
ea9f34f0b3 | ||
|
|
4e9cbd23f2 | ||
|
|
bbd65c01e9 | ||
|
|
5dc30b7702 | ||
|
|
eb3b31bd59 | ||
|
|
57597dfef0 | ||
|
|
8cb7a610c7 | ||
|
|
2c464978b4 | ||
|
|
8d0bf6abe8 | ||
|
|
82c724a768 | ||
|
|
6146fe5f86 | ||
|
|
24ce6eae3b | ||
|
|
8db934a2c2 | ||
|
|
dc90d412ca | ||
|
|
b8415c8995 | ||
|
|
0d86f39ba3 | ||
|
|
0bab033673 | ||
|
|
72a0ce3f51 | ||
|
|
c3a14b82b3 | ||
|
|
b3252e276b | ||
|
|
10c63a66f6 | ||
|
|
f44205b90d | ||
|
|
cd087d410f | ||
|
|
c5812ba938 | ||
|
|
2e4c7f7690 | ||
|
|
a7389efb00 | ||
|
|
532062687c | ||
|
|
d3a603d115 | ||
|
|
26fece78c5 | ||
|
|
b8fb626591 | ||
|
|
732786067f | ||
|
|
45c0cd48c7 | ||
|
|
50d7982dd5 | ||
|
|
ff085b1284 | ||
|
|
c3564b1f8f | ||
|
|
32eba21e7a | ||
|
|
9952afcc38 | ||
|
|
b3feccab0d | ||
|
|
86ebd4903b | ||
|
|
0533bb9c30 | ||
|
|
185e90494c | ||
|
|
3f77b497ce | ||
|
|
87a8333cdf | ||
|
|
3d12261aa7 | ||
|
|
19c6cbbcd3 | ||
|
|
39c191db7c | ||
|
|
58c36266e0 | ||
|
|
0ebdfffdeb | ||
|
|
ed840f3048 | ||
|
|
1e13b509df | ||
|
|
d76a9a4628 | ||
|
|
f70e20498e | ||
|
|
1715b39629 | ||
|
|
3c63db8c9c | ||
|
|
7af78c95dd | ||
|
|
1c4a377641 | ||
|
|
bf56937585 | ||
|
|
e97442b0c8 | ||
|
|
d029ce5380 | ||
|
|
20049921ad | ||
|
|
05a0db75db | ||
|
|
a7b8100a18 | ||
|
|
112369b283 | ||
|
|
f9b915b728 | ||
|
|
8acdbc928e | ||
|
|
9665e14e6d | ||
|
|
b45e05cc9e | ||
|
|
116f4d94ea | ||
|
|
f18b5b49c5 | ||
|
|
09a4db7c03 | ||
|
|
2616a5776b | ||
|
|
36cfc4a867 | ||
|
|
631f118afb | ||
|
|
b43e3a61e6 | ||
|
|
04100adece | ||
|
|
a103f93925 | ||
|
|
8467340fb5 | ||
|
|
3a8e41de27 | ||
|
|
97c2f183ca | ||
|
|
f1ab35e71e | ||
|
|
240d892b94 | ||
|
|
364d96e7f6 | ||
|
|
03dfd58ac5 |
Generated
+642
-697
File diff suppressed because it is too large
Load Diff
+18
-18
@@ -4,14 +4,14 @@
|
|||||||
"private": true,
|
"private": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@formkit/auto-animate": "^0.8.2",
|
"@formkit/auto-animate": "^0.8.2",
|
||||||
"@lottiefiles/dotlottie-react": "^0.9.0",
|
"@lottiefiles/dotlottie-react": "^0.9.3",
|
||||||
"@pdf-lib/fontkit": "^1.1.1",
|
"@pdf-lib/fontkit": "^1.1.1",
|
||||||
"@radix-ui/themes": "^3.1.4",
|
"@radix-ui/themes": "^3.1.4",
|
||||||
"@react-pdf/renderer": "^4.0.0",
|
"@react-pdf/renderer": "^4.0.0",
|
||||||
"@reduxjs/toolkit": "^2.2.7",
|
"@reduxjs/toolkit": "^2.3.0",
|
||||||
"axios": "^1.7.7",
|
"axios": "^1.7.7",
|
||||||
"file-saver": "^2.0.5",
|
"file-saver": "^2.0.5",
|
||||||
"i18next": "^23.15.2",
|
"i18next": "^23.16.5",
|
||||||
"i18next-browser-languagedetector": "^8.0.0",
|
"i18next-browser-languagedetector": "^8.0.0",
|
||||||
"i18next-http-backend": "^2.6.2",
|
"i18next-http-backend": "^2.6.2",
|
||||||
"jszip": "^3.10.1",
|
"jszip": "^3.10.1",
|
||||||
@@ -25,8 +25,8 @@
|
|||||||
"react": "^18.2.0",
|
"react": "^18.2.0",
|
||||||
"react-bootstrap": "^2.10.5",
|
"react-bootstrap": "^2.10.5",
|
||||||
"react-confetti": "^6.1.0",
|
"react-confetti": "^6.1.0",
|
||||||
"react-cookie": "^7.2.0",
|
"react-cookie": "^7.2.2",
|
||||||
"react-datepicker": "^7.4.0",
|
"react-datepicker": "^7.5.0",
|
||||||
"react-dnd": "^16.0.1",
|
"react-dnd": "^16.0.1",
|
||||||
"react-dnd-html5-backend": "^16.0.1",
|
"react-dnd-html5-backend": "^16.0.1",
|
||||||
"react-dnd-multi-backend": "^8.0.3",
|
"react-dnd-multi-backend": "^8.0.3",
|
||||||
@@ -34,25 +34,25 @@
|
|||||||
"react-dom": "^18.2.0",
|
"react-dom": "^18.2.0",
|
||||||
"react-gtm-module": "^2.0.11",
|
"react-gtm-module": "^2.0.11",
|
||||||
"react-helmet": "^6.1.0",
|
"react-helmet": "^6.1.0",
|
||||||
"react-i18next": "^15.0.2",
|
"react-i18next": "^15.0.3",
|
||||||
"react-konva": "^18.2.10",
|
"react-konva": "^18.2.10",
|
||||||
"react-pdf": "^9.1.1",
|
"react-pdf": "^9.1.1",
|
||||||
"react-quill-new": "^3.3.3",
|
"react-quill-new": "^3.3.3",
|
||||||
"react-redux": "^9.1.2",
|
"react-redux": "^9.1.2",
|
||||||
"react-rnd": "^10.4.13",
|
"react-rnd": "^10.4.13",
|
||||||
"react-router-dom": "^6.26.2",
|
"react-router-dom": "^6.27.0",
|
||||||
"react-scripts": "5.0.1",
|
"react-scripts": "5.0.1",
|
||||||
"react-scrollbars-custom": "^4.1.1",
|
"react-scrollbars-custom": "^4.1.1",
|
||||||
"react-select": "^5.8.1",
|
"react-select": "^5.8.3",
|
||||||
"react-signature-canvas": "^1.0.6",
|
"react-signature-canvas": "^1.0.6",
|
||||||
"react-syntax-highlighter": "^15.5.0",
|
"react-syntax-highlighter": "^15.6.1",
|
||||||
"react-tooltip": "^5.28.0",
|
"react-tooltip": "^5.28.0",
|
||||||
"react-web-share": "^2.0.2",
|
"react-web-share": "^2.0.2",
|
||||||
"reactour": "^1.19.4",
|
"reactour": "^1.19.4",
|
||||||
"redux": "^5.0.1",
|
"redux": "^5.0.1",
|
||||||
"redux-thunk": "^3.1.0",
|
"redux-thunk": "^3.1.0",
|
||||||
"regex-parser": "^2.3.0",
|
"regex-parser": "^2.3.0",
|
||||||
"serve": "^14.2.3",
|
"serve": "^14.2.4",
|
||||||
"styled-components": "^5.3.0",
|
"styled-components": "^5.3.0",
|
||||||
"web-vitals": "^4.2.3",
|
"web-vitals": "^4.2.3",
|
||||||
"ws": "^8.18.0"
|
"ws": "^8.18.0"
|
||||||
@@ -95,28 +95,28 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@babel/core": "^7.25.7",
|
"@babel/core": "^7.26.0",
|
||||||
"@babel/preset-env": "^7.25.7",
|
"@babel/preset-env": "^7.26.0",
|
||||||
"@babel/preset-react": "^7.25.7",
|
"@babel/preset-react": "^7.25.9",
|
||||||
"@babel/runtime-corejs2": "^7.25.7",
|
"@babel/runtime-corejs2": "^7.26.0",
|
||||||
"autoprefixer": "^10.4.20",
|
"autoprefixer": "^10.4.20",
|
||||||
"babel-loader": "^9.2.1",
|
"babel-loader": "^9.2.1",
|
||||||
"clean-webpack-plugin": "^4.0.0",
|
"clean-webpack-plugin": "^4.0.0",
|
||||||
"commitizen": "^4.3.1",
|
"commitizen": "^4.3.1",
|
||||||
"concurrently": "^9.0.1",
|
"concurrently": "^9.0.1",
|
||||||
"css-loader": "^7.1.2",
|
"css-loader": "^7.1.2",
|
||||||
"daisyui": "^4.12.12",
|
"daisyui": "^4.12.14",
|
||||||
"dotenv": "^16.4.5",
|
"dotenv": "^16.4.5",
|
||||||
"dotenv-webpack": "^8.1.0",
|
"dotenv-webpack": "^8.1.0",
|
||||||
"eslint": "^9.12.0",
|
"eslint": "^9.13.0",
|
||||||
"eslint-plugin-prettier": "^5.2.1",
|
"eslint-plugin-prettier": "^5.2.1",
|
||||||
"eslint-plugin-react": "^7.37.1",
|
"eslint-plugin-react": "^7.37.1",
|
||||||
"lint-staged": "^15.2.10",
|
"lint-staged": "^15.2.10",
|
||||||
"mini-css-extract-plugin": "^2.9.1",
|
"mini-css-extract-plugin": "^2.9.1",
|
||||||
"postcss": "^8.4.47",
|
"postcss": "^8.4.48",
|
||||||
"prettier": "^3.3.3",
|
"prettier": "^3.3.3",
|
||||||
"pretty-quick": "^4.0.0",
|
"pretty-quick": "^4.0.0",
|
||||||
"tailwindcss": "^3.4.13",
|
"tailwindcss": "^3.4.14",
|
||||||
"terser-webpack-plugin": "^5.3.10",
|
"terser-webpack-plugin": "^5.3.10",
|
||||||
"webpack-cli": "^5.1.4"
|
"webpack-cli": "^5.1.4"
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -94,6 +94,7 @@
|
|||||||
"My Signature": "My Signature",
|
"My Signature": "My Signature",
|
||||||
"API Token": "API Token",
|
"API Token": "API Token",
|
||||||
"Webhook": "Webhook",
|
"Webhook": "Webhook",
|
||||||
|
"Preferences": "Preferences",
|
||||||
"Teams": "Teams",
|
"Teams": "Teams",
|
||||||
"Team-update-successfully": "Team Updated successfully.",
|
"Team-update-successfully": "Team Updated successfully.",
|
||||||
"Users": "Users"
|
"Users": "Users"
|
||||||
@@ -291,7 +292,7 @@
|
|||||||
"subject": "Subject",
|
"subject": "Subject",
|
||||||
"body": "Body",
|
"body": "Body",
|
||||||
"add-contact": "Add Contact",
|
"add-contact": "Add Contact",
|
||||||
"add-signer-alert": "Contact already exist!",
|
"add-signer-alert": "Contact already exist! Please select it from ‘Signers’ dropdown",
|
||||||
"record-delete-alert": "Record deleted successfully!",
|
"record-delete-alert": "Record deleted successfully!",
|
||||||
"record-revoke-alert": "Record revoked successfully!",
|
"record-revoke-alert": "Record revoked successfully!",
|
||||||
"mail-sent-alert": "Mail sent successfully.",
|
"mail-sent-alert": "Mail sent successfully.",
|
||||||
@@ -445,7 +446,8 @@
|
|||||||
"cutomize-email": "Cutomize Email",
|
"cutomize-email": "Cutomize Email",
|
||||||
"upgrade-to-customize-email": "Upgrade to customize Email",
|
"upgrade-to-customize-email": "Upgrade to customize Email",
|
||||||
"sign-url": "Sign url",
|
"sign-url": "Sign url",
|
||||||
"Mails Sent": "Mails Sent",
|
"mails-sent": "Mails sent",
|
||||||
|
"mail-not-delivered": "Mail not delivered",
|
||||||
"document-alert": "Document Alert",
|
"document-alert": "Document Alert",
|
||||||
"owner-subscription-expired": "Owner's subscription has expired.",
|
"owner-subscription-expired": "Owner's subscription has expired.",
|
||||||
"subscription-expired": "Subscription Expired",
|
"subscription-expired": "Subscription Expired",
|
||||||
@@ -679,9 +681,21 @@
|
|||||||
"p3":"Tip: If your signers are familiar with OpenSign and frequently use it, you may want to disable the guided tour for a more seamless experience. Choose the option that best fits your document signing needs."
|
"p3":"Tip: If your signers are familiar with OpenSign and frequently use it, you may want to disable the guided tour for a more seamless experience. Choose the option that best fits your document signing needs."
|
||||||
},
|
},
|
||||||
"form-title-1":"Document Flow Setting",
|
"form-title-1":"Document Flow Setting",
|
||||||
"form-title-2":"Security Setting",
|
"form-title-2":"Security Settings",
|
||||||
"public-tour-message":"The template needs to be public before you can generate a shareable link.",
|
"public-tour-message":"The template needs to be public before you can generate a shareable link.",
|
||||||
"add-user-template": "You need to add a role before you can add fields for it.",
|
"add-user-template": "You need to add a role before you can add fields for it.",
|
||||||
"pdf-uncompatible": "This pdf is not compatible with opensign, please contact <support@opensignlabs.com>"
|
"pdf-uncompatible": "This pdf is not compatible with opensign, please contact <support@opensignlabs.com>",
|
||||||
|
"text-field-tour":"Fields of type 'Text' must be filled in advance before the document is sent. If you need the signers to provide input, use the 'Text Input' field instead.",
|
||||||
|
"attach-signer-tour":"You need to attach a Signer to every role. You can do that by clicking this icon. Once you select a Signer it will be attached to all the fields associated with that role which appear in the same colour.",
|
||||||
|
"allowed-signature-types": "Allowed signature types",
|
||||||
|
"at-least-one-signature-type": "At least one signature type should be enabled.",
|
||||||
|
"expect-default-one-more-signature-type": "Please enable one additional signature type apart from the default.",
|
||||||
|
"add-signer-note": "Note - This contact will be added to your contact list",
|
||||||
|
"allowed-signature-types-help": {
|
||||||
|
"p1": "This signature preference controls which signing options are available to your signers. Only the signature types you select will appear in the signature widget when a document is signed. For example, if you choose only the 'Draw' option in preferences, your signer will see only the 'Draw' option in the signature widget, while the other three options will not be available.",
|
||||||
|
"l1": "Create a handwritten signature directly on the screen using your finger or a stylus.",
|
||||||
|
"l2": "Enter your name and choose from various font styles to create a signature.",
|
||||||
|
"l3": "Upload an existing digital version of your signature.",
|
||||||
|
"l4": "Use a pre-set signature style saved under 'My Signature' in your settings."
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -94,6 +94,7 @@
|
|||||||
"My Signature": "Mi firma",
|
"My Signature": "Mi firma",
|
||||||
"API Token": "Token API",
|
"API Token": "Token API",
|
||||||
"Webhook": "Webhook",
|
"Webhook": "Webhook",
|
||||||
|
"Preferences": "Preferencias",
|
||||||
"Teams": "Equipos",
|
"Teams": "Equipos",
|
||||||
"Team-update-successfully": "Equipo actualizado correctamente.",
|
"Team-update-successfully": "Equipo actualizado correctamente.",
|
||||||
"Users": "Usuarios"
|
"Users": "Usuarios"
|
||||||
@@ -291,7 +292,7 @@
|
|||||||
"subject": "Asunto",
|
"subject": "Asunto",
|
||||||
"body": "Cuerpo",
|
"body": "Cuerpo",
|
||||||
"add-contact": "Agregar contacto",
|
"add-contact": "Agregar contacto",
|
||||||
"add-signer-alert": "¡El contacto ya existe!",
|
"add-signer-alert": "¡El contacto ya existe! Selecciónelo en el menú desplegable 'Firmantes'",
|
||||||
"record-delete-alert": "¡Entrada eliminada exitosamente!",
|
"record-delete-alert": "¡Entrada eliminada exitosamente!",
|
||||||
"record-revoke-alert": "¡Entrada revocada exitosamente!",
|
"record-revoke-alert": "¡Entrada revocada exitosamente!",
|
||||||
"mail-sent-alert": "Correo enviado exitosamente.",
|
"mail-sent-alert": "Correo enviado exitosamente.",
|
||||||
@@ -445,7 +446,8 @@
|
|||||||
"cutomize-email": "Personalizar correo",
|
"cutomize-email": "Personalizar correo",
|
||||||
"upgrade-to-customize-email": "Mejora para personalizar el correo",
|
"upgrade-to-customize-email": "Mejora para personalizar el correo",
|
||||||
"sign-url": "URL de firma",
|
"sign-url": "URL de firma",
|
||||||
"Mails Sent": "Correos enviados",
|
"mails-sent": "Correos enviados",
|
||||||
|
"mail-not-delivered": "correo no entregado",
|
||||||
"document-alert": "Alerta de documento",
|
"document-alert": "Alerta de documento",
|
||||||
"owner-subscription-expired": "La suscripción del propietario ha expirado.",
|
"owner-subscription-expired": "La suscripción del propietario ha expirado.",
|
||||||
"subscription-expired": "Suscripción expirada",
|
"subscription-expired": "Suscripción expirada",
|
||||||
@@ -682,6 +684,18 @@
|
|||||||
"p3": "Consejo: si sus firmantes están familiarizados con OpenSign y lo utilizan con frecuencia, es posible que desee desactivar la visita guiada para disfrutar de una experiencia más fluida. Elija la opción que mejor se adapte a sus necesidades de firma de documentos"
|
"p3": "Consejo: si sus firmantes están familiarizados con OpenSign y lo utilizan con frecuencia, es posible que desee desactivar la visita guiada para disfrutar de una experiencia más fluida. Elija la opción que mejor se adapte a sus necesidades de firma de documentos"
|
||||||
},
|
},
|
||||||
"form-title-1": "Configuración del flujo de documentos",
|
"form-title-1": "Configuración del flujo de documentos",
|
||||||
"form-title-2": "Configuración de seguridad"
|
"form-title-2": "Configuración de seguridad",
|
||||||
|
"text-field-tour":"Los campos de tipo 'Texto' deben completarse con anticipación antes de enviar el documento. Si necesita que los firmantes proporcionen información, utilice el campo 'Entrada de texto'",
|
||||||
|
"attach-signer-tour" :"Debe adjuntar un firmante a cada función. Puede hacerlo haciendo clic en este icono. Una vez que seleccione un Firmante, se adjuntará a todos los campos asociados con ese rol que aparecen en el mismo color.",
|
||||||
|
"allowed-signature-types": "Tipos de firma permitidos",
|
||||||
|
"at-least-one-signature-type": "Se debe habilitar al menos un tipo de firma.",
|
||||||
|
"expect-default-one-signature-type": "Habilite un tipo de firma adicional aparte del predeterminado.",
|
||||||
|
"add-signer-note": "Nota - Este contacto se agregará a su lista de contactos",
|
||||||
|
"allowed-signature-types-help": {
|
||||||
|
"p1": "Esta preferencia de firma controla qué opciones de firma están disponibles para sus firmantes. Solo los tipos de firma que seleccione aparecerán en el widget de firma cuando se firme un documento. Por ejemplo, si elige sólo la opción 'Draw' en las preferencias, su firmante verá sólo la opción 'Draw' en el widget de firma, mientras que las otras tres opciones no estarán disponibles.",
|
||||||
|
"l1": "Cree una firma manuscrita directamente en la pantalla usando su dedo o un lápiz.",
|
||||||
|
"l2": "Ingrese su nombre y elija entre varios estilos de fuente para crear una firma.",
|
||||||
|
"l3": "Cargue una versión digital existente de su firma.",
|
||||||
|
"l4": "Utilice un estilo de firma preestablecido guardado en 'Mi firma' en su configuración."
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -94,6 +94,7 @@
|
|||||||
"My Signature": "Ma signature",
|
"My Signature": "Ma signature",
|
||||||
"API Token": "Jeton API",
|
"API Token": "Jeton API",
|
||||||
"Webhook": "Webhook",
|
"Webhook": "Webhook",
|
||||||
|
"Preferences": "Préférences",
|
||||||
"Teams": "Équipe",
|
"Teams": "Équipe",
|
||||||
"Team-update-successfully": "Équipe mise à jour avec succès.",
|
"Team-update-successfully": "Équipe mise à jour avec succès.",
|
||||||
"Users": "Utilisateurs"
|
"Users": "Utilisateurs"
|
||||||
@@ -290,7 +291,7 @@
|
|||||||
"subject": "Sujet",
|
"subject": "Sujet",
|
||||||
"body": "Corps",
|
"body": "Corps",
|
||||||
"add-contact": "Ajouter le contact",
|
"add-contact": "Ajouter le contact",
|
||||||
"add-signer-alert": "Le contact existe déjà !",
|
"add-signer-alert": "Le contact existe déjà ! Veuillez le sélectionner dans la liste déroulante 'Signataires'",
|
||||||
"record-delete-alert": "Enregistrement supprimé avec succès !",
|
"record-delete-alert": "Enregistrement supprimé avec succès !",
|
||||||
"record-revoke-alert": " Enregistrement révoqué avec succès ! ",
|
"record-revoke-alert": " Enregistrement révoqué avec succès ! ",
|
||||||
"mail-sent-alert": "Courriel envoyé avec succès.",
|
"mail-sent-alert": "Courriel envoyé avec succès.",
|
||||||
@@ -444,7 +445,8 @@
|
|||||||
"cutomize-email": "Personnaliser l'e-mail",
|
"cutomize-email": "Personnaliser l'e-mail",
|
||||||
"upgrade-to-customize-email": "Mise à niveau pour personnaliser l'e-mail",
|
"upgrade-to-customize-email": "Mise à niveau pour personnaliser l'e-mail",
|
||||||
"sign-url": "Signer l'URL",
|
"sign-url": "Signer l'URL",
|
||||||
"Mails Sent": "Mails envoyés avec succès !",
|
"mails-sent": "Mails envoyés avec succès !",
|
||||||
|
"mail-not-delivered": "Courrier non distribué",
|
||||||
"document-alert": "Alerte document",
|
"document-alert": "Alerte document",
|
||||||
"owner-subscription-expired": "L'abonnement du propriétaire a expiré.",
|
"owner-subscription-expired": "L'abonnement du propriétaire a expiré.",
|
||||||
"subscription-expired": "Abonnement expiré",
|
"subscription-expired": "Abonnement expiré",
|
||||||
@@ -681,7 +683,18 @@
|
|||||||
"form-title-2": "Paramètre de sécurité",
|
"form-title-2": "Paramètre de sécurité",
|
||||||
"public-tour-message": "Le modèle doit être public avant que vous puissiez générer un lien partageable.",
|
"public-tour-message": "Le modèle doit être public avant que vous puissiez générer un lien partageable.",
|
||||||
"add-user-template":"Vous devez ajouter un rôle avant de pouvoir lui ajouter des champs. ",
|
"add-user-template":"Vous devez ajouter un rôle avant de pouvoir lui ajouter des champs. ",
|
||||||
"pdf-uncompatible":"Ce pdf n'est pas compatible avec opensign, veuillez contacter <support@opensignlabs.com>"
|
"pdf-uncompatible":"Ce pdf n'est pas compatible avec opensign, veuillez contacter <support@opensignlabs.com>",
|
||||||
|
"text-field-tour" :"Les champs de type 'Texte' doivent être remplis à l'avance avant l'envoi du document. Si vous avez besoin que les signataires fournissent des informations, utilisez plutôt le champ 'Saisie de texte'.",
|
||||||
|
"attach-signer-tour" :"Vous devez associer un signataire à chaque rôle. Vous pouvez le faire en cliquant sur cette icône. Une fois que vous avez sélectionné un signataire, il sera attaché à tous les champs associés à ce rôle qui apparaissent dans la même couleur.",
|
||||||
|
"allowed-signature-types": "Types de signature autorisés",
|
||||||
|
"at-least-one-signature-type": "Au moins un type de signature doit être activé.",
|
||||||
|
"expect-default-one-signature-type": "Veuillez activer un type de signature supplémentaire en plus de celui par défaut.",
|
||||||
|
"add-signer-note": "Remarque - Ce contact sera ajouté à votre liste de contacts",
|
||||||
|
"allowed-signature-types-help": {
|
||||||
|
"p1": "Cette préférence de signature contrôle les options de signature disponibles pour vos signataires. Seuls les types de signature que vous sélectionnez apparaîtront dans le widget de signature lorsqu'un document est signé. Par exemple, si vous choisissez uniquement l'option 'Draw' dans les préférences, votre signataire ne verra que l'option 'Draw' dans le widget de signature, tandis que les trois autres options ne seront pas disponibles.",
|
||||||
|
"l1": "Créez une signature manuscrite directement sur l'écran à l'aide de votre doigt ou d'un stylet.",
|
||||||
|
"l2": "Entrez votre nom et choisissez parmi différents styles de police pour créer une signature.",
|
||||||
|
"l3": "Téléchargez une version numérique existante de votre signature.",
|
||||||
|
"l4": "Utilisez un style de signature prédéfini enregistré sous 'Ma signature' dans vos paramètres."
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -35,6 +35,8 @@ const GenerateToken = lazy(() => import("./pages/GenerateToken"));
|
|||||||
const Webhook = lazy(() => import("./pages/Webhook"));
|
const Webhook = lazy(() => import("./pages/Webhook"));
|
||||||
const AddAdmin = lazy(() => import("./pages/AddAdmin"));
|
const AddAdmin = lazy(() => import("./pages/AddAdmin"));
|
||||||
const UpdateExistUserAdmin = lazy(() => import("./pages/UpdateExistUserAdmin"));
|
const UpdateExistUserAdmin = lazy(() => import("./pages/UpdateExistUserAdmin"));
|
||||||
|
const DraftTemplate = lazy(() => import("./pages/DraftTemplate"));
|
||||||
|
const Preferences = lazy(() => import("./pages/Preferences"));
|
||||||
|
|
||||||
pdfjs.GlobalWorkerOptions.workerSrc = `//unpkg.com/pdfjs-dist@${pdfjs.version}/legacy/build/pdf.worker.min.mjs`;
|
pdfjs.GlobalWorkerOptions.workerSrc = `//unpkg.com/pdfjs-dist@${pdfjs.version}/legacy/build/pdf.worker.min.mjs`;
|
||||||
const AppLoader = () => {
|
const AppLoader = () => {
|
||||||
@@ -198,8 +200,16 @@ function App() {
|
|||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
<Route path="/users" element={<UserList />} />
|
<Route path="/users" element={<UserList />} />
|
||||||
|
<Route
|
||||||
|
path="/preferences"
|
||||||
|
element={<LazyPage Page={Preferences} />}
|
||||||
|
/>
|
||||||
</Route>
|
</Route>
|
||||||
<Route path="/sso" element={<SSOVerify />} />
|
<Route path="/sso" element={<SSOVerify />} />
|
||||||
|
<Route
|
||||||
|
path="/drafttemplate/:jwttoken"
|
||||||
|
element={<DraftTemplate />}
|
||||||
|
/>
|
||||||
<Route path="*" element={<PageNotFound />} />
|
<Route path="*" element={<PageNotFound />} />
|
||||||
</Routes>
|
</Routes>
|
||||||
</BrowserRouter>
|
</BrowserRouter>
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ import React, { useState, useEffect } from "react";
|
|||||||
import Parse from "parse";
|
import Parse from "parse";
|
||||||
import Loader from "../primitives/Loader";
|
import Loader from "../primitives/Loader";
|
||||||
import { useTranslation } from "react-i18next";
|
import { useTranslation } from "react-i18next";
|
||||||
|
import { emailRegex } from "../constant/const";
|
||||||
|
|
||||||
const AddSigner = (props) => {
|
const AddSigner = (props) => {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
@@ -47,139 +48,143 @@ const AddSigner = (props) => {
|
|||||||
const handleSubmit = async (e) => {
|
const handleSubmit = async (e) => {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
setIsLoader(true);
|
if (!emailRegex.test(email)) {
|
||||||
if (localStorage.getItem("TenantId")) {
|
alert("Please enter a valid email address.");
|
||||||
try {
|
} else {
|
||||||
const user = Parse.User.current();
|
setIsLoader(true);
|
||||||
const query = new Parse.Query("contracts_Contactbook");
|
if (localStorage.getItem("TenantId")) {
|
||||||
query.equalTo("CreatedBy", user);
|
try {
|
||||||
query.notEqualTo("IsDeleted", true);
|
const user = Parse.User.current();
|
||||||
query.equalTo("Email", email);
|
const query = new Parse.Query("contracts_Contactbook");
|
||||||
const res = await query.first();
|
query.equalTo("CreatedBy", user);
|
||||||
// console.log(res);
|
query.notEqualTo("IsDeleted", true);
|
||||||
if (!res) {
|
query.equalTo("Email", email);
|
||||||
const contactQuery = new Parse.Object("contracts_Contactbook");
|
const res = await query.first();
|
||||||
contactQuery.set("Name", name);
|
// console.log(res);
|
||||||
if (phone) {
|
if (!res) {
|
||||||
contactQuery.set("Phone", phone);
|
const contactQuery = new Parse.Object("contracts_Contactbook");
|
||||||
}
|
contactQuery.set("Name", name);
|
||||||
contactQuery.set("Email", email);
|
|
||||||
contactQuery.set("UserRole", "contracts_Guest");
|
|
||||||
|
|
||||||
contactQuery.set("TenantId", {
|
|
||||||
__type: "Pointer",
|
|
||||||
className: "partners_Tenant",
|
|
||||||
objectId: localStorage.getItem("TenantId")
|
|
||||||
});
|
|
||||||
|
|
||||||
try {
|
|
||||||
const _users = Parse.Object.extend("User");
|
|
||||||
const _user = new _users();
|
|
||||||
_user.set("name", name);
|
|
||||||
_user.set("username", email);
|
|
||||||
_user.set("email", email);
|
|
||||||
_user.set("password", email);
|
|
||||||
if (phone) {
|
if (phone) {
|
||||||
_user.set("phone", phone);
|
contactQuery.set("Phone", phone);
|
||||||
}
|
}
|
||||||
const user = await _user.save();
|
contactQuery.set("Email", email);
|
||||||
if (user) {
|
contactQuery.set("UserRole", "contracts_Guest");
|
||||||
const currentUser = Parse.User.current();
|
|
||||||
contactQuery.set(
|
|
||||||
"CreatedBy",
|
|
||||||
Parse.User.createWithoutData(currentUser.id)
|
|
||||||
);
|
|
||||||
|
|
||||||
contactQuery.set("UserId", user);
|
contactQuery.set("TenantId", {
|
||||||
const acl = new Parse.ACL();
|
__type: "Pointer",
|
||||||
acl.setPublicReadAccess(true);
|
className: "partners_Tenant",
|
||||||
acl.setPublicWriteAccess(true);
|
objectId: localStorage.getItem("TenantId")
|
||||||
acl.setReadAccess(currentUser.id, true);
|
});
|
||||||
acl.setWriteAccess(currentUser.id, true);
|
|
||||||
|
|
||||||
contactQuery.setACL(acl);
|
try {
|
||||||
|
const _users = Parse.Object.extend("User");
|
||||||
|
const _user = new _users();
|
||||||
|
_user.set("name", name);
|
||||||
|
_user.set("username", email);
|
||||||
|
_user.set("email", email);
|
||||||
|
_user.set("password", email);
|
||||||
|
if (phone) {
|
||||||
|
_user.set("phone", phone);
|
||||||
|
}
|
||||||
|
const user = await _user.save();
|
||||||
|
if (user) {
|
||||||
|
const currentUser = Parse.User.current();
|
||||||
|
contactQuery.set(
|
||||||
|
"CreatedBy",
|
||||||
|
Parse.User.createWithoutData(currentUser.id)
|
||||||
|
);
|
||||||
|
|
||||||
const res = await contactQuery.save();
|
contactQuery.set("UserId", user);
|
||||||
|
const acl = new Parse.ACL();
|
||||||
|
acl.setPublicReadAccess(true);
|
||||||
|
acl.setPublicWriteAccess(true);
|
||||||
|
acl.setReadAccess(currentUser.id, true);
|
||||||
|
acl.setWriteAccess(currentUser.id, true);
|
||||||
|
|
||||||
const parseData = JSON.parse(JSON.stringify(res));
|
contactQuery.setACL(acl);
|
||||||
if (props.details) {
|
|
||||||
props.details({
|
const res = await contactQuery.save();
|
||||||
value: parseData[props.valueKey],
|
|
||||||
label: parseData[props.displayKey]
|
const parseData = JSON.parse(JSON.stringify(res));
|
||||||
|
if (props.details) {
|
||||||
|
props.details({
|
||||||
|
value: parseData[props.valueKey],
|
||||||
|
label: parseData[props.displayKey]
|
||||||
|
});
|
||||||
|
}
|
||||||
|
if (props.closePopup) {
|
||||||
|
props.closePopup();
|
||||||
|
}
|
||||||
|
if (props.handleUserData) {
|
||||||
|
props.handleUserData(parseData);
|
||||||
|
}
|
||||||
|
|
||||||
|
setIsLoader(false);
|
||||||
|
// Reset the form fields
|
||||||
|
setAddYourself(false);
|
||||||
|
setName("");
|
||||||
|
setPhone("");
|
||||||
|
setEmail("");
|
||||||
|
}
|
||||||
|
} catch (err) {
|
||||||
|
console.log("err ", err);
|
||||||
|
if (err.code === 202) {
|
||||||
|
const params = { email: email };
|
||||||
|
const userRes = await Parse.Cloud.run("getUserId", params);
|
||||||
|
const currentUser = Parse.User.current();
|
||||||
|
contactQuery.set(
|
||||||
|
"CreatedBy",
|
||||||
|
Parse.User.createWithoutData(currentUser.id)
|
||||||
|
);
|
||||||
|
|
||||||
|
contactQuery.set("UserId", {
|
||||||
|
__type: "Pointer",
|
||||||
|
className: "_User",
|
||||||
|
objectId: userRes.id
|
||||||
});
|
});
|
||||||
}
|
const acl = new Parse.ACL();
|
||||||
if (props.closePopup) {
|
acl.setPublicReadAccess(true);
|
||||||
props.closePopup();
|
acl.setPublicWriteAccess(true);
|
||||||
}
|
acl.setReadAccess(currentUser.id, true);
|
||||||
if (props.handleUserData) {
|
acl.setWriteAccess(currentUser.id, true);
|
||||||
props.handleUserData(parseData);
|
|
||||||
}
|
|
||||||
|
|
||||||
setIsLoader(false);
|
contactQuery.setACL(acl);
|
||||||
// Reset the form fields
|
const res = await contactQuery.save();
|
||||||
setAddYourself(false);
|
|
||||||
setName("");
|
const parseData = JSON.parse(JSON.stringify(res));
|
||||||
setPhone("");
|
if (props.details) {
|
||||||
setEmail("");
|
props.details({
|
||||||
}
|
value: parseData[props.valueKey],
|
||||||
} catch (err) {
|
label: parseData[props.displayKey]
|
||||||
console.log("err ", err);
|
});
|
||||||
if (err.code === 202) {
|
}
|
||||||
const params = { email: email };
|
if (props.closePopup) {
|
||||||
const userRes = await Parse.Cloud.run("getUserId", params);
|
props.closePopup();
|
||||||
const currentUser = Parse.User.current();
|
}
|
||||||
contactQuery.set(
|
if (props.handleUserData) {
|
||||||
"CreatedBy",
|
props.handleUserData(parseData);
|
||||||
Parse.User.createWithoutData(currentUser.id)
|
}
|
||||||
);
|
setIsLoader(false);
|
||||||
|
// Reset the form fields
|
||||||
contactQuery.set("UserId", {
|
setAddYourself(false);
|
||||||
__type: "Pointer",
|
setName("");
|
||||||
className: "_User",
|
setPhone("");
|
||||||
objectId: userRes.id
|
setEmail("");
|
||||||
});
|
}
|
||||||
const acl = new Parse.ACL();
|
|
||||||
acl.setPublicReadAccess(true);
|
|
||||||
acl.setPublicWriteAccess(true);
|
|
||||||
acl.setReadAccess(currentUser.id, true);
|
|
||||||
acl.setWriteAccess(currentUser.id, true);
|
|
||||||
|
|
||||||
contactQuery.setACL(acl);
|
|
||||||
const res = await contactQuery.save();
|
|
||||||
|
|
||||||
const parseData = JSON.parse(JSON.stringify(res));
|
|
||||||
if (props.details) {
|
|
||||||
props.details({
|
|
||||||
value: parseData[props.valueKey],
|
|
||||||
label: parseData[props.displayKey]
|
|
||||||
});
|
|
||||||
}
|
|
||||||
if (props.closePopup) {
|
|
||||||
props.closePopup();
|
|
||||||
}
|
|
||||||
if (props.handleUserData) {
|
|
||||||
props.handleUserData(parseData);
|
|
||||||
}
|
|
||||||
setIsLoader(false);
|
|
||||||
// Reset the form fields
|
|
||||||
setAddYourself(false);
|
|
||||||
setName("");
|
|
||||||
setPhone("");
|
|
||||||
setEmail("");
|
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
alert(t("add-signer-alert"));
|
||||||
|
setIsLoader(false);
|
||||||
}
|
}
|
||||||
} else {
|
} catch (err) {
|
||||||
alert(t("add-signer-alert"));
|
console.log("err in fetch contact", err);
|
||||||
setIsLoader(false);
|
setIsLoader(false);
|
||||||
|
alert(t("something-went-wrong-mssg"));
|
||||||
}
|
}
|
||||||
} catch (err) {
|
} else {
|
||||||
console.log("err in fetch contact", err);
|
|
||||||
setIsLoader(false);
|
setIsLoader(false);
|
||||||
alert(t("something-went-wrong-mssg"));
|
alert(t("something-went-wrong-mssg"));
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
setIsLoader(false);
|
|
||||||
alert(t("something-went-wrong-mssg"));
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -206,6 +211,7 @@ const AddSigner = (props) => {
|
|||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
<div className="w-full mx-auto p-2 text-base-content">
|
<div className="w-full mx-auto p-2 text-base-content">
|
||||||
|
<p className="mb-3">{t("add-signer-note")}</p>
|
||||||
{isUserExist && (
|
{isUserExist && (
|
||||||
<div className="mb-3 flex items-center">
|
<div className="mb-3 flex items-center">
|
||||||
<input
|
<input
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ import Parse from "parse";
|
|||||||
import Title from "./Title";
|
import Title from "./Title";
|
||||||
import Loader from "../primitives/Loader";
|
import Loader from "../primitives/Loader";
|
||||||
import { copytoData, fetchSubscriptionInfo } from "../constant/Utils";
|
import { copytoData, fetchSubscriptionInfo } from "../constant/Utils";
|
||||||
import { isEnableSubscription } from "../constant/const";
|
import { emailRegex, isEnableSubscription } from "../constant/const";
|
||||||
import { useTranslation } from "react-i18next";
|
import { useTranslation } from "react-i18next";
|
||||||
function generatePassword(length) {
|
function generatePassword(length) {
|
||||||
const characters =
|
const characters =
|
||||||
@@ -115,149 +115,172 @@ const AddUser = (props) => {
|
|||||||
const handleSubmit = async (e) => {
|
const handleSubmit = async (e) => {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
const localUser = JSON.parse(localStorage.getItem("Extand_Class"))?.[0];
|
if (!emailRegex.test(formdata.email)) {
|
||||||
setIsFormLoader(true);
|
alert("Please enter a valid email address.");
|
||||||
const res = await checkUserExist();
|
|
||||||
if (res) {
|
|
||||||
props.setIsAlert({ type: "danger", msg: t("user-already-exist") });
|
|
||||||
setIsFormLoader(false);
|
|
||||||
setTimeout(() => props.setIsAlert({ type: "success", msg: "" }), 1000);
|
|
||||||
} else {
|
} else {
|
||||||
try {
|
const localUser = JSON.parse(localStorage.getItem("Extand_Class"))?.[0];
|
||||||
const extUser = new Parse.Object("contracts_Users");
|
setIsFormLoader(true);
|
||||||
extUser.set("Name", formdata.name);
|
const res = await checkUserExist();
|
||||||
if (formdata.phone) {
|
if (res) {
|
||||||
extUser.set("Phone", formdata.phone);
|
props.setIsAlert({ type: "danger", msg: t("user-already-exist") });
|
||||||
}
|
setIsFormLoader(false);
|
||||||
extUser.set("Email", formdata.email);
|
setTimeout(() => props.setIsAlert({ type: "success", msg: "" }), 1000);
|
||||||
extUser.set("UserRole", `contracts_${formdata.role}`);
|
} else {
|
||||||
if (formdata?.team) {
|
|
||||||
extUser.set("TeamIds", [
|
|
||||||
{
|
|
||||||
__type: "Pointer",
|
|
||||||
className: "contracts_Teams",
|
|
||||||
objectId: formdata.team
|
|
||||||
}
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
if (localUser && localUser.OrganizationId) {
|
|
||||||
extUser.set("OrganizationId", {
|
|
||||||
__type: "Pointer",
|
|
||||||
className: "contracts_Organizations",
|
|
||||||
objectId: localUser.OrganizationId.objectId
|
|
||||||
});
|
|
||||||
}
|
|
||||||
if (localUser && localUser.Company) {
|
|
||||||
extUser.set("Company", localUser.Company);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (localStorage.getItem("TenantId")) {
|
|
||||||
extUser.set("TenantId", {
|
|
||||||
__type: "Pointer",
|
|
||||||
className: "partners_Tenant",
|
|
||||||
objectId: localStorage.getItem("TenantId")
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const _users = Parse.Object.extend("User");
|
const extUser = new Parse.Object("contracts_Users");
|
||||||
const _user = new _users();
|
extUser.set("Name", formdata.name);
|
||||||
_user.set("name", formdata.name);
|
|
||||||
_user.set("username", formdata.email);
|
|
||||||
_user.set("email", formdata.email);
|
|
||||||
_user.set("password", formdata.password);
|
|
||||||
if (formdata.phone) {
|
if (formdata.phone) {
|
||||||
_user.set("phone", formdata.phone);
|
extUser.set("Phone", formdata.phone);
|
||||||
|
}
|
||||||
|
extUser.set("Email", formdata.email);
|
||||||
|
extUser.set("UserRole", `contracts_${formdata.role}`);
|
||||||
|
if (formdata?.team) {
|
||||||
|
extUser.set("TeamIds", [
|
||||||
|
{
|
||||||
|
__type: "Pointer",
|
||||||
|
className: "contracts_Teams",
|
||||||
|
objectId: formdata.team
|
||||||
|
}
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
if (localUser && localUser.OrganizationId) {
|
||||||
|
extUser.set("OrganizationId", {
|
||||||
|
__type: "Pointer",
|
||||||
|
className: "contracts_Organizations",
|
||||||
|
objectId: localUser.OrganizationId.objectId
|
||||||
|
});
|
||||||
|
}
|
||||||
|
if (localUser && localUser.Company) {
|
||||||
|
extUser.set("Company", localUser.Company);
|
||||||
}
|
}
|
||||||
|
|
||||||
const user = await _user.save();
|
if (localStorage.getItem("TenantId")) {
|
||||||
if (user) {
|
extUser.set("TenantId", {
|
||||||
const currentUser = Parse.User.current();
|
__type: "Pointer",
|
||||||
extUser.set(
|
className: "partners_Tenant",
|
||||||
"CreatedBy",
|
objectId: localStorage.getItem("TenantId")
|
||||||
Parse.User.createWithoutData(currentUser.id)
|
});
|
||||||
);
|
}
|
||||||
|
|
||||||
extUser.set("UserId", user);
|
try {
|
||||||
const acl = new Parse.ACL();
|
const _users = Parse.Object.extend("User");
|
||||||
acl.setPublicReadAccess(true);
|
const _user = new _users();
|
||||||
acl.setPublicWriteAccess(true);
|
_user.set("name", formdata.name);
|
||||||
acl.setReadAccess(currentUser.id, true);
|
_user.set("username", formdata.email);
|
||||||
acl.setWriteAccess(currentUser.id, true);
|
_user.set("email", formdata.email);
|
||||||
|
_user.set("password", formdata.password);
|
||||||
extUser.setACL(acl);
|
if (formdata.phone) {
|
||||||
|
_user.set("phone", formdata.phone);
|
||||||
const res = await extUser.save();
|
|
||||||
|
|
||||||
const parseData = JSON.parse(JSON.stringify(res));
|
|
||||||
|
|
||||||
if (props.closePopup) {
|
|
||||||
props.closePopup();
|
|
||||||
}
|
}
|
||||||
if (props.handleUserData) {
|
|
||||||
if (formdata?.team) {
|
const user = await _user.save();
|
||||||
const team = teamList.find((x) => x.objectId === formdata.team);
|
if (user) {
|
||||||
parseData.TeamIds = parseData.TeamIds.map((y) =>
|
const currentUser = Parse.User.current();
|
||||||
y.objectId === team.objectId ? team : y
|
extUser.set(
|
||||||
);
|
"CreatedBy",
|
||||||
|
Parse.User.createWithoutData(currentUser.id)
|
||||||
|
);
|
||||||
|
|
||||||
|
extUser.set("UserId", user);
|
||||||
|
const acl = new Parse.ACL();
|
||||||
|
acl.setPublicReadAccess(true);
|
||||||
|
acl.setPublicWriteAccess(true);
|
||||||
|
acl.setReadAccess(currentUser.id, true);
|
||||||
|
acl.setWriteAccess(currentUser.id, true);
|
||||||
|
|
||||||
|
extUser.setACL(acl);
|
||||||
|
|
||||||
|
const res = await extUser.save();
|
||||||
|
|
||||||
|
const parseData = JSON.parse(JSON.stringify(res));
|
||||||
|
|
||||||
|
if (props.closePopup) {
|
||||||
|
props.closePopup();
|
||||||
|
}
|
||||||
|
if (props.handleUserData) {
|
||||||
|
if (formdata?.team) {
|
||||||
|
const team = teamList.find(
|
||||||
|
(x) => x.objectId === formdata.team
|
||||||
|
);
|
||||||
|
parseData.TeamIds = parseData.TeamIds.map((y) =>
|
||||||
|
y.objectId === team.objectId ? team : y
|
||||||
|
);
|
||||||
|
}
|
||||||
|
props.handleUserData(parseData);
|
||||||
}
|
}
|
||||||
props.handleUserData(parseData);
|
|
||||||
}
|
|
||||||
|
|
||||||
setIsFormLoader(false);
|
setIsFormLoader(false);
|
||||||
setFormdata({ name: "", email: "", phone: "", team: "", role: "" });
|
setFormdata({
|
||||||
|
name: "",
|
||||||
|
email: "",
|
||||||
|
phone: "",
|
||||||
|
team: "",
|
||||||
|
role: ""
|
||||||
|
});
|
||||||
|
}
|
||||||
|
} catch (err) {
|
||||||
|
console.log("err ", err);
|
||||||
|
if (err.code === 202) {
|
||||||
|
const params = { email: formdata.email };
|
||||||
|
const userRes = await Parse.Cloud.run("getUserId", params);
|
||||||
|
const currentUser = Parse.User.current();
|
||||||
|
extUser.set(
|
||||||
|
"CreatedBy",
|
||||||
|
Parse.User.createWithoutData(currentUser.id)
|
||||||
|
);
|
||||||
|
|
||||||
|
extUser.set("UserId", {
|
||||||
|
__type: "Pointer",
|
||||||
|
className: "_User",
|
||||||
|
objectId: userRes.id
|
||||||
|
});
|
||||||
|
const acl = new Parse.ACL();
|
||||||
|
acl.setPublicReadAccess(true);
|
||||||
|
acl.setPublicWriteAccess(true);
|
||||||
|
acl.setReadAccess(currentUser.id, true);
|
||||||
|
acl.setWriteAccess(currentUser.id, true);
|
||||||
|
|
||||||
|
extUser.setACL(acl);
|
||||||
|
const res = await extUser.save();
|
||||||
|
|
||||||
|
const parseData = JSON.parse(JSON.stringify(res));
|
||||||
|
if (props.closePopup) {
|
||||||
|
props.closePopup();
|
||||||
|
}
|
||||||
|
if (props.handleUserData) {
|
||||||
|
if (formdata?.team) {
|
||||||
|
const team = teamList.find(
|
||||||
|
(x) => x.objectId === formdata.team
|
||||||
|
);
|
||||||
|
parseData.TeamIds = parseData.TeamIds.map((y) =>
|
||||||
|
y.objectId === team.objectId ? team : y
|
||||||
|
);
|
||||||
|
}
|
||||||
|
props.handleUserData(parseData);
|
||||||
|
}
|
||||||
|
setIsFormLoader(false);
|
||||||
|
setFormdata({
|
||||||
|
name: "",
|
||||||
|
email: "",
|
||||||
|
phone: "",
|
||||||
|
team: "",
|
||||||
|
role: ""
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.log("err ", err);
|
console.log("err", err);
|
||||||
if (err.code === 202) {
|
setIsFormLoader(false);
|
||||||
const params = { email: formdata.email };
|
props.setIsAlert({
|
||||||
const userRes = await Parse.Cloud.run("getUserId", params);
|
type: "danger",
|
||||||
const currentUser = Parse.User.current();
|
msg: t("something-went-wrong-mssg")
|
||||||
extUser.set(
|
});
|
||||||
"CreatedBy",
|
} finally {
|
||||||
Parse.User.createWithoutData(currentUser.id)
|
setTimeout(
|
||||||
);
|
() => props.setIsAlert({ type: "success", msg: "" }),
|
||||||
|
1500
|
||||||
extUser.set("UserId", {
|
);
|
||||||
__type: "Pointer",
|
|
||||||
className: "_User",
|
|
||||||
objectId: userRes.id
|
|
||||||
});
|
|
||||||
const acl = new Parse.ACL();
|
|
||||||
acl.setPublicReadAccess(true);
|
|
||||||
acl.setPublicWriteAccess(true);
|
|
||||||
acl.setReadAccess(currentUser.id, true);
|
|
||||||
acl.setWriteAccess(currentUser.id, true);
|
|
||||||
|
|
||||||
extUser.setACL(acl);
|
|
||||||
const res = await extUser.save();
|
|
||||||
|
|
||||||
const parseData = JSON.parse(JSON.stringify(res));
|
|
||||||
if (props.closePopup) {
|
|
||||||
props.closePopup();
|
|
||||||
}
|
|
||||||
if (props.handleUserData) {
|
|
||||||
if (formdata?.team) {
|
|
||||||
const team = teamList.find((x) => x.objectId === formdata.team);
|
|
||||||
parseData.TeamIds = parseData.TeamIds.map((y) =>
|
|
||||||
y.objectId === team.objectId ? team : y
|
|
||||||
);
|
|
||||||
}
|
|
||||||
props.handleUserData(parseData);
|
|
||||||
}
|
|
||||||
setIsFormLoader(false);
|
|
||||||
setFormdata({ name: "", email: "", phone: "", team: "", role: "" });
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
} catch (err) {
|
|
||||||
console.log("err", err);
|
|
||||||
setIsFormLoader(false);
|
|
||||||
props.setIsAlert({
|
|
||||||
type: "danger",
|
|
||||||
msg: t("something-went-wrong-mssg")
|
|
||||||
});
|
|
||||||
} finally {
|
|
||||||
setTimeout(() => props.setIsAlert({ type: "success", msg: "" }), 1500);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ import Loader from "../primitives/Loader";
|
|||||||
import { useTranslation } from "react-i18next";
|
import { useTranslation } from "react-i18next";
|
||||||
import Parse from "parse";
|
import Parse from "parse";
|
||||||
import ModalUi from "../primitives/ModalUi";
|
import ModalUi from "../primitives/ModalUi";
|
||||||
import { isEnableSubscription } from "../constant/const";
|
import { emailRegex, isEnableSubscription } from "../constant/const";
|
||||||
import { fetchSubscription } from "../constant/Utils";
|
import { fetchSubscription } from "../constant/Utils";
|
||||||
import { useNavigate } from "react-router-dom";
|
import { useNavigate } from "react-router-dom";
|
||||||
const BulkSendUi = (props) => {
|
const BulkSendUi = (props) => {
|
||||||
@@ -69,7 +69,21 @@ const BulkSendUi = (props) => {
|
|||||||
if (subscription?.plan === "freeplan") {
|
if (subscription?.plan === "freeplan") {
|
||||||
setIsFreePlan(true);
|
setIsFreePlan(true);
|
||||||
}
|
}
|
||||||
const resCredits = await Parse.Cloud.run("allowedcredits");
|
const token = props.jwttoken
|
||||||
|
? { jwttoken: props.jwttoken }
|
||||||
|
: { "X-Parse-Session-Token": localStorage.getItem("accesstoken") };
|
||||||
|
const axiosres = await axios.post(
|
||||||
|
`${localStorage.getItem("baseUrl")}functions/allowedcredits`,
|
||||||
|
{},
|
||||||
|
{
|
||||||
|
headers: {
|
||||||
|
"Content-Type": "application/json",
|
||||||
|
"X-Parse-Application-Id": localStorage.getItem("parseAppId"),
|
||||||
|
...token
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
const resCredits = axiosres.data && axiosres.data.result;
|
||||||
if (resCredits) {
|
if (resCredits) {
|
||||||
const allowedcredits = resCredits?.allowedcredits || 0;
|
const allowedcredits = resCredits?.allowedcredits || 0;
|
||||||
const addoncredits = resCredits?.addoncredits || 0;
|
const addoncredits = resCredits?.addoncredits || 0;
|
||||||
@@ -81,7 +95,7 @@ const BulkSendUi = (props) => {
|
|||||||
}
|
}
|
||||||
setAmount((obj) => ({ ...obj, totalcredits: totalcredits }));
|
setAmount((obj) => ({ ...obj, totalcredits: totalcredits }));
|
||||||
}
|
}
|
||||||
const getPlaceholder = props.item?.Placeholders;
|
const getPlaceholder = props?.Placeholders;
|
||||||
const checkIsSignatureExistt = getPlaceholder?.every((placeholderObj) =>
|
const checkIsSignatureExistt = getPlaceholder?.every((placeholderObj) =>
|
||||||
placeholderObj?.placeHolder?.some((holder) =>
|
placeholderObj?.placeHolder?.some((holder) =>
|
||||||
holder?.pos?.some((posItem) => posItem?.type === "signature")
|
holder?.pos?.some((posItem) => posItem?.type === "signature")
|
||||||
@@ -97,7 +111,7 @@ const BulkSendUi = (props) => {
|
|||||||
} else {
|
} else {
|
||||||
setIsBulkAvailable(true);
|
setIsBulkAvailable(true);
|
||||||
setAdmin((obj) => ({ ...obj, isAdmin: true }));
|
setAdmin((obj) => ({ ...obj, isAdmin: true }));
|
||||||
const getPlaceholder = props.item?.Placeholders;
|
const getPlaceholder = props?.Placeholders;
|
||||||
const checkIsSignatureExistt = getPlaceholder?.every((placeholderObj) =>
|
const checkIsSignatureExistt = getPlaceholder?.every((placeholderObj) =>
|
||||||
placeholderObj?.placeHolder?.some((holder) =>
|
placeholderObj?.placeHolder?.some((holder) =>
|
||||||
holder?.pos?.some((posItem) => posItem?.type === "signature")
|
holder?.pos?.some((posItem) => posItem?.type === "signature")
|
||||||
@@ -188,75 +202,99 @@ const BulkSendUi = (props) => {
|
|||||||
const updatedForms = forms.filter((_, i) => i !== index);
|
const updatedForms = forms.filter((_, i) => i !== index);
|
||||||
setForms(updatedForms);
|
setForms(updatedForms);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
function validateEmails(data) {
|
||||||
|
for (const item of data) {
|
||||||
|
for (const field of item.fields) {
|
||||||
|
if (!emailRegex.test(field.email)) {
|
||||||
|
alert(`Invalid email found: ${field.email}`);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
const handleSubmit = async (e) => {
|
const handleSubmit = async (e) => {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
setIsSubmit(true);
|
setIsSubmit(true);
|
||||||
|
if (validateEmails(forms)) {
|
||||||
// Create a copy of Placeholders array from props.item
|
// Create a copy of Placeholders array from props.item
|
||||||
let Placeholders = [...props.item.Placeholders];
|
let Placeholders = [...props.Placeholders];
|
||||||
// Initialize an empty array to store updated documents
|
// Initialize an empty array to store updated documents
|
||||||
let Documents = [];
|
let Documents = [];
|
||||||
// Loop through each form
|
// Loop through each form
|
||||||
forms.forEach((form) => {
|
forms.forEach((form) => {
|
||||||
//checking if user enter email which already exist as a signer then add user in a signers array
|
//checking if user enter email which already exist as a signer then add user in a signers array
|
||||||
let existSigner = [];
|
let existSigner = [];
|
||||||
form.fields.map((data) => {
|
form.fields.map((data) => {
|
||||||
if (data.signer) {
|
if (data.signer) {
|
||||||
existSigner.push(data.signer);
|
existSigner.push(data.signer);
|
||||||
}
|
|
||||||
});
|
|
||||||
// Map through the copied Placeholders array to update email values
|
|
||||||
const updatedPlaceholders = Placeholders.map((placeholder) => {
|
|
||||||
// Find the field in the current form that matches the placeholder Id
|
|
||||||
const field = form.fields.find(
|
|
||||||
(element) => parseInt(element.fieldId) === placeholder.Id
|
|
||||||
);
|
|
||||||
// If a matching field is found, update the email value in the placeholder
|
|
||||||
const signer = field?.signer?.objectId ? field.signer : "";
|
|
||||||
if (field) {
|
|
||||||
if (signer) {
|
|
||||||
return {
|
|
||||||
...placeholder,
|
|
||||||
signerObjId: field?.signer?.objectId || "",
|
|
||||||
signerPtr: signer
|
|
||||||
};
|
|
||||||
} else {
|
|
||||||
return {
|
|
||||||
...placeholder,
|
|
||||||
email: field.email,
|
|
||||||
signerObjId: field?.signer?.objectId || "",
|
|
||||||
signerPtr: signer
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
// If no matching field is found, keep the placeholder as is
|
|
||||||
return placeholder;
|
|
||||||
});
|
|
||||||
|
|
||||||
// Push a new document object with updated Placeholders into the Documents array
|
|
||||||
if (existSigner?.length > 0) {
|
|
||||||
Documents.push({
|
|
||||||
...props.item,
|
|
||||||
Placeholders: updatedPlaceholders,
|
|
||||||
Signers: props.item.Signers
|
|
||||||
? [...props.item.Signers, ...existSigner]
|
|
||||||
: [...existSigner]
|
|
||||||
});
|
});
|
||||||
} else {
|
// Map through the copied Placeholders array to update email values
|
||||||
Documents.push({ ...props.item, Placeholders: updatedPlaceholders });
|
const updatedPlaceholders = Placeholders.map((placeholder) => {
|
||||||
}
|
// Find the field in the current form that matches the placeholder Id
|
||||||
});
|
const field = form.fields.find(
|
||||||
await batchQuery(Documents);
|
(element) => parseInt(element.fieldId) === placeholder.Id
|
||||||
|
);
|
||||||
|
// If a matching field is found, update the email value in the placeholder
|
||||||
|
const signer = field?.signer?.objectId ? field.signer : "";
|
||||||
|
if (field) {
|
||||||
|
if (signer) {
|
||||||
|
return {
|
||||||
|
...placeholder,
|
||||||
|
signerObjId: field?.signer?.objectId || "",
|
||||||
|
signerPtr: signer
|
||||||
|
};
|
||||||
|
} else {
|
||||||
|
return {
|
||||||
|
...placeholder,
|
||||||
|
email: field.email,
|
||||||
|
signerObjId: field?.signer?.objectId || "",
|
||||||
|
signerPtr: signer
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// If no matching field is found, keep the placeholder as is
|
||||||
|
return placeholder;
|
||||||
|
});
|
||||||
|
|
||||||
|
// Push a new document object with updated Placeholders into the Documents array
|
||||||
|
if (existSigner?.length > 0) {
|
||||||
|
Documents.push({
|
||||||
|
...props.item,
|
||||||
|
Placeholders: updatedPlaceholders,
|
||||||
|
Signers: props.item.Signers
|
||||||
|
? [...props.item.Signers, ...existSigner]
|
||||||
|
: [...existSigner]
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
Documents.push({
|
||||||
|
...props.item,
|
||||||
|
Placeholders: updatedPlaceholders,
|
||||||
|
SignatureType: props.signatureType
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
await batchQuery(Documents);
|
||||||
|
} else {
|
||||||
|
setIsSubmit(false);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const batchQuery = async (Documents) => {
|
const batchQuery = async (Documents) => {
|
||||||
const serverUrl = localStorage.getItem("baseUrl");
|
const token = props.jwttoken
|
||||||
const functionsUrl = `${serverUrl}functions/batchdocuments`;
|
? { jwttoken: props.jwttoken }
|
||||||
|
: { "X-Parse-Session-Token": localStorage.getItem("accesstoken") };
|
||||||
|
const functionsUrl = `${localStorage.getItem(
|
||||||
|
"baseUrl"
|
||||||
|
)}functions/batchdocuments`;
|
||||||
const headers = {
|
const headers = {
|
||||||
"Content-Type": "application/json",
|
"Content-Type": "application/json",
|
||||||
"X-Parse-Application-Id": localStorage.getItem("parseAppId"),
|
"X-Parse-Application-Id": localStorage.getItem("parseAppId"),
|
||||||
sessionToken: localStorage.getItem("accesstoken")
|
...token
|
||||||
};
|
};
|
||||||
const params = { Documents: JSON.stringify(Documents) };
|
const params = { Documents: JSON.stringify(Documents) };
|
||||||
try {
|
try {
|
||||||
@@ -362,6 +400,7 @@ const BulkSendUi = (props) => {
|
|||||||
fieldIndex
|
fieldIndex
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
jwttoken={props?.jwttoken}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
))}
|
))}
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ import { useTranslation } from "react-i18next";
|
|||||||
import ModalUi from "../primitives/ModalUi";
|
import ModalUi from "../primitives/ModalUi";
|
||||||
import QuotaCard from "../primitives/QuotaCard";
|
import QuotaCard from "../primitives/QuotaCard";
|
||||||
|
|
||||||
const Header = ({ showSidebar }) => {
|
const Header = ({ showSidebar, setIsMenu }) => {
|
||||||
const { t, i18n } = useTranslation();
|
const { t, i18n } = useTranslation();
|
||||||
const navigate = useNavigate();
|
const navigate = useNavigate();
|
||||||
const { width } = useWindowSize();
|
const { width } = useWindowSize();
|
||||||
@@ -40,7 +40,7 @@ const Header = ({ showSidebar }) => {
|
|||||||
const toggleDropdown = () => {
|
const toggleDropdown = () => {
|
||||||
setIsOpen(!isOpen);
|
setIsOpen(!isOpen);
|
||||||
if (width <= 768) {
|
if (width <= 768) {
|
||||||
showSidebar();
|
setIsMenu(false);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
|||||||
@@ -1,16 +1,16 @@
|
|||||||
import React from "react";
|
import React from "react";
|
||||||
import { useTranslation } from "react-i18next";
|
import { useTranslation } from "react-i18next";
|
||||||
function DefaultSignature({ defaultSignImg, xyPostion, setDefaultSignAlert }) {
|
function DefaultSignature(props) {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
|
|
||||||
const confirmToaddDefaultSign = () => {
|
const confirmToaddDefaultSign = () => {
|
||||||
if (xyPostion.length > 0) {
|
if (props?.xyPostion.length > 0) {
|
||||||
setDefaultSignAlert({
|
props?.setDefaultSignAlert({
|
||||||
isShow: true,
|
isShow: true,
|
||||||
alertMessage: t("default-sign-alert")
|
alertMessage: t("default-sign-alert")
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
setDefaultSignAlert({
|
props?.setDefaultSignAlert({
|
||||||
isShow: true,
|
isShow: true,
|
||||||
alertMessage: t("please-select-position!")
|
alertMessage: t("please-select-position!")
|
||||||
});
|
});
|
||||||
@@ -22,22 +22,30 @@ function DefaultSignature({ defaultSignImg, xyPostion, setDefaultSignAlert }) {
|
|||||||
<div className="mx-2 pr-2 pt-2 pb-1 text-[15px] text-base-content font-semibold border-b-[1px] border-base-300">
|
<div className="mx-2 pr-2 pt-2 pb-1 text-[15px] text-base-content font-semibold border-b-[1px] border-base-300">
|
||||||
{t("signature")}
|
{t("signature")}
|
||||||
</div>
|
</div>
|
||||||
<div className="flex flex-col items-center mt-[10px] font-semibold">
|
<div className="flex flex-col items-center mt-[10px] font-semibold relative">
|
||||||
<p className="text-base-content">{t("Your-Signature")}</p>
|
<p className="text-base-content">{t("Your-Signature")}</p>
|
||||||
<div className="op-card shadow-md h-[111px] w-[90%] p-2">
|
<div className="op-card shadow-md h-[111px] w-[90%] p-2">
|
||||||
<img
|
<img
|
||||||
alt="signature"
|
alt="signature"
|
||||||
className="w-full h-full object-contain"
|
className="w-full h-full object-contain"
|
||||||
src={defaultSignImg}
|
src={props?.defaultSignImg}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<button
|
<button
|
||||||
type="button"
|
type="button"
|
||||||
className="op-btn op-btn-primary op-btn-sm mt-[10px]"
|
className="op-btn op-btn-primary op-btn-sm mt-[10px]"
|
||||||
onClick={() => confirmToaddDefaultSign()}
|
onClick={() => confirmToaddDefaultSign()}
|
||||||
|
disabled={!props?.isDefault}
|
||||||
>
|
>
|
||||||
{t("auto-sign-all")}
|
{t("auto-sign-all")}
|
||||||
</button>
|
</button>
|
||||||
|
{!props.isDefault && (
|
||||||
|
<div className="absolute bg-black/70 text-white w-full h-full flex items-center justify-center text-[11px] cursor-default">
|
||||||
|
<span className="-rotate-45">
|
||||||
|
Document creator has disabled this option
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -339,9 +339,9 @@ function DropdownWidgetOption(props) {
|
|||||||
value={
|
value={
|
||||||
props.fontSize ||
|
props.fontSize ||
|
||||||
props.currWidgetsDetails?.options?.fontSize ||
|
props.currWidgetsDetails?.options?.fontSize ||
|
||||||
"12"
|
12
|
||||||
}
|
}
|
||||||
onChange={(e) => props.setFontSize(e.target.value)}
|
onChange={(e) => props.setFontSize(parseInt(e.target.value))}
|
||||||
>
|
>
|
||||||
{fontsizeArr.map((size, ind) => {
|
{fontsizeArr.map((size, ind) => {
|
||||||
return (
|
return (
|
||||||
|
|||||||
@@ -5,11 +5,8 @@ import { isEnableSubscription } from "../../constant/const";
|
|||||||
import { useTranslation } from "react-i18next";
|
import { useTranslation } from "react-i18next";
|
||||||
import { Tooltip } from "react-tooltip";
|
import { Tooltip } from "react-tooltip";
|
||||||
|
|
||||||
// import SelectFolder from "../../premitives/SelectFolder";
|
const EditTemplate = ({ template, onSuccess, jwttoken }) => {
|
||||||
|
|
||||||
const EditTemplate = ({ template, onSuccess }) => {
|
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
// const [folder, setFolder] = useState({ ObjectId: "", Name: "" });
|
|
||||||
const [formData, setFormData] = useState({
|
const [formData, setFormData] = useState({
|
||||||
Name: template?.Name || "",
|
Name: template?.Name || "",
|
||||||
Note: template?.Note || "",
|
Note: template?.Note || "",
|
||||||
@@ -29,17 +26,13 @@ const EditTemplate = ({ template, onSuccess }) => {
|
|||||||
}, []);
|
}, []);
|
||||||
const fetchSubscription = async () => {
|
const fetchSubscription = async () => {
|
||||||
if (isEnableSubscription) {
|
if (isEnableSubscription) {
|
||||||
const subscribe = await checkIsSubscribed();
|
const subscribe = await checkIsSubscribed(jwttoken);
|
||||||
setIsSubscribe(subscribe.isValid);
|
setIsSubscribe(subscribe.isValid);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
const handleStrInput = (e) => {
|
const handleStrInput = (e) => {
|
||||||
setFormData({ ...formData, [e.target.name]: e.target.value });
|
setFormData({ ...formData, [e.target.name]: e.target.value });
|
||||||
};
|
};
|
||||||
// const handleFolder = (data) => {
|
|
||||||
// console.log("handleFolder ", data)
|
|
||||||
// setFolder(data);
|
|
||||||
// };
|
|
||||||
|
|
||||||
// Define a function to handle form submission
|
// Define a function to handle form submission
|
||||||
const handleSubmit = async (e) => {
|
const handleSubmit = async (e) => {
|
||||||
@@ -85,7 +78,7 @@ const EditTemplate = ({ template, onSuccess }) => {
|
|||||||
</div>
|
</div>
|
||||||
<div className="mb-[0.35rem]">
|
<div className="mb-[0.35rem]">
|
||||||
<label htmlFor="name" className="text-[13px]">
|
<label htmlFor="name" className="text-[13px]">
|
||||||
{t("name")}
|
{t("Title")}
|
||||||
<span className="text-[13px] text-[red]"> *</span>
|
<span className="text-[13px] text-[red]"> *</span>
|
||||||
</label>
|
</label>
|
||||||
<input
|
<input
|
||||||
@@ -158,7 +151,6 @@ const EditTemplate = ({ template, onSuccess }) => {
|
|||||||
}
|
}
|
||||||
>
|
>
|
||||||
{t("auto-reminder")}
|
{t("auto-reminder")}
|
||||||
{" "}
|
|
||||||
{!isSubscribe && isEnableSubscription && <Upgrade />}
|
{!isSubscribe && isEnableSubscription && <Upgrade />}
|
||||||
</span>
|
</span>
|
||||||
<label
|
<label
|
||||||
|
|||||||
@@ -40,7 +40,8 @@ function Header({
|
|||||||
handleRotationFun,
|
handleRotationFun,
|
||||||
isDisableRotate,
|
isDisableRotate,
|
||||||
templateId,
|
templateId,
|
||||||
setIsDownloadModal
|
setIsDownloadModal,
|
||||||
|
disabledBackBtn
|
||||||
}) {
|
}) {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
const filterPrefill =
|
const filterPrefill =
|
||||||
@@ -48,6 +49,7 @@ function Header({
|
|||||||
const isMobile = window.innerWidth < 767;
|
const isMobile = window.innerWidth < 767;
|
||||||
const [isDownloading, setIsDownloading] = useState("");
|
const [isDownloading, setIsDownloading] = useState("");
|
||||||
const isGuestSigner = localStorage.getItem("isGuestSigner");
|
const isGuestSigner = localStorage.getItem("isGuestSigner");
|
||||||
|
const enabledBackBtn = disabledBackBtn === true ? false : true;
|
||||||
|
|
||||||
//function for show decline alert
|
//function for show decline alert
|
||||||
const handleDeclinePdfAlert = async () => {
|
const handleDeclinePdfAlert = async () => {
|
||||||
@@ -332,13 +334,15 @@ function Header({
|
|||||||
<i className="fa-light fa-gear fa-lg"></i>
|
<i className="fa-light fa-gear fa-lg"></i>
|
||||||
</button>
|
</button>
|
||||||
)}
|
)}
|
||||||
<button
|
{enabledBackBtn && (
|
||||||
onClick={() => window.history.go(-2)}
|
<button
|
||||||
type="button"
|
onClick={() => window.history.go(-2)}
|
||||||
className="op-btn op-btn-ghost op-btn-sm mr-[3px]"
|
type="button"
|
||||||
>
|
className="op-btn op-btn-ghost op-btn-sm mr-[3px]"
|
||||||
{t("back")}
|
>
|
||||||
</button>
|
{t("back")}
|
||||||
|
</button>
|
||||||
|
)}
|
||||||
<button
|
<button
|
||||||
disabled={isMailSend && true}
|
disabled={isMailSend && true}
|
||||||
data-tut="headerArea"
|
data-tut="headerArea"
|
||||||
|
|||||||
@@ -331,10 +331,9 @@ function Placeholder(props) {
|
|||||||
//condition for only placeholder and template flow
|
//condition for only placeholder and template flow
|
||||||
if (props.data && props?.pos?.type !== textWidget) {
|
if (props.data && props?.pos?.type !== textWidget) {
|
||||||
props.setUniqueId(props?.data?.Id);
|
props.setUniqueId(props?.data?.Id);
|
||||||
const checkIndex = props.xyPostion.findIndex(
|
const checkIndex = props.xyPostion
|
||||||
(data) => data.Id === props.data.Id
|
.filter((data) => data.Role !== "prefill")
|
||||||
);
|
.findIndex((data) => data.Id === props.data.Id);
|
||||||
|
|
||||||
props.setIsSelectId(checkIndex || 0);
|
props.setIsSelectId(checkIndex || 0);
|
||||||
}
|
}
|
||||||
//condition to handle in placeholder and template flow for text widget signerId for text widgets i have to set uniqueId in tempSignerId because
|
//condition to handle in placeholder and template flow for text widget signerId for text widgets i have to set uniqueId in tempSignerId because
|
||||||
@@ -342,10 +341,6 @@ function Placeholder(props) {
|
|||||||
else if (props.data && props.pos.type === textWidget) {
|
else if (props.data && props.pos.type === textWidget) {
|
||||||
props.setTempSignerId(props.uniqueId);
|
props.setTempSignerId(props.uniqueId);
|
||||||
props.setUniqueId(props?.data?.Id);
|
props.setUniqueId(props?.data?.Id);
|
||||||
const checkIndex = props.xyPostion.findIndex(
|
|
||||||
(data) => data.Id === props.data.Id
|
|
||||||
);
|
|
||||||
props.setIsSelectId(checkIndex || 0);
|
|
||||||
}
|
}
|
||||||
props.setSignKey(props.pos.key);
|
props.setSignKey(props.pos.key);
|
||||||
props.setWidgetType(props.pos.type);
|
props.setWidgetType(props.pos.type);
|
||||||
@@ -361,18 +356,13 @@ function Placeholder(props) {
|
|||||||
|
|
||||||
if (props.data && props?.pos?.type !== textWidget) {
|
if (props.data && props?.pos?.type !== textWidget) {
|
||||||
props.setUniqueId(props?.data?.Id);
|
props.setUniqueId(props?.data?.Id);
|
||||||
const checkIndex = props.xyPostion.findIndex(
|
const checkIndex = props.xyPostion
|
||||||
(data) => data.Id === props.data.Id
|
.filter((data) => data.Role !== "prefill")
|
||||||
);
|
.findIndex((data) => data.Id === props.data.Id);
|
||||||
|
|
||||||
props.setIsSelectId(checkIndex || 0);
|
props.setIsSelectId(checkIndex || 0);
|
||||||
} else if (props.data && props.pos.type === textWidget) {
|
} else if (props.data && props.pos.type === textWidget) {
|
||||||
props.setTempSignerId(props.uniqueId);
|
props.setTempSignerId(props.uniqueId);
|
||||||
props.setUniqueId(props?.data?.Id);
|
props.setUniqueId(props?.data?.Id);
|
||||||
const checkIndex = props.xyPostion.findIndex(
|
|
||||||
(data) => data.Id === props.data.Id
|
|
||||||
);
|
|
||||||
props.setIsSelectId(checkIndex || 0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//checking widget's type and open widget copy modal for required widgets
|
//checking widget's type and open widget copy modal for required widgets
|
||||||
@@ -422,7 +412,7 @@ function Placeholder(props) {
|
|||||||
data?.format,
|
data?.format,
|
||||||
null,
|
null,
|
||||||
null,
|
null,
|
||||||
props.fontSize || props.pos?.options?.fontSize || "12",
|
props.fontSize || props.pos?.options?.fontSize || 12,
|
||||||
props.fontColor || props.pos?.options?.fontColor || "black"
|
props.fontColor || props.pos?.options?.fontColor || "black"
|
||||||
);
|
);
|
||||||
setSelectDate({ date: date, format: data?.format });
|
setSelectDate({ date: date, format: data?.format });
|
||||||
@@ -455,17 +445,13 @@ function Placeholder(props) {
|
|||||||
handleOnClickSettingIcon();
|
handleOnClickSettingIcon();
|
||||||
}}
|
}}
|
||||||
className="fa-light fa-gear icon"
|
className="fa-light fa-gear icon"
|
||||||
style={{
|
style={{ color: "#188ae2", right: "29px", top: "-19px" }}
|
||||||
color: "#188ae2",
|
|
||||||
right: "29px",
|
|
||||||
top: "-19px"
|
|
||||||
}}
|
|
||||||
></i>
|
></i>
|
||||||
) : (
|
) : (
|
||||||
/* condition to add setting icon for placeholder & template flow for all widgets except signature and date */
|
/* condition to add setting icon for placeholder & template flow for all widgets except signature and date */
|
||||||
((!props?.pos?.type && props.pos.isStamp) ||
|
((!props?.pos?.type && props.pos.isStamp) ||
|
||||||
(props?.pos?.type &&
|
(props?.pos?.type &&
|
||||||
!["date", "signature"].includes(props.pos.type) &&
|
!["date"].includes(props.pos.type) &&
|
||||||
!props.isSignYourself)) && (
|
!props.isSignYourself)) && (
|
||||||
<i
|
<i
|
||||||
onClick={(e) => {
|
onClick={(e) => {
|
||||||
@@ -479,7 +465,7 @@ function Placeholder(props) {
|
|||||||
className="fa-light fa-gear icon"
|
className="fa-light fa-gear icon"
|
||||||
style={{
|
style={{
|
||||||
color: "#188ae2",
|
color: "#188ae2",
|
||||||
right: props?.pos?.type === textWidget ? "32px" : "47px",
|
right: props?.pos?.type === textWidget ? "32px" : "51px",
|
||||||
top: "-19px"
|
top: "-19px"
|
||||||
}}
|
}}
|
||||||
></i>
|
></i>
|
||||||
@@ -661,7 +647,7 @@ function Placeholder(props) {
|
|||||||
const fontSize = (size || 12) * containerScale * props.scale;
|
const fontSize = (size || 12) * containerScale * props.scale;
|
||||||
//isMinHeight to set text box minimum height
|
//isMinHeight to set text box minimum height
|
||||||
if (isMinHeight) {
|
if (isMinHeight) {
|
||||||
return fontSize * 1.5 + "px";
|
return fontSize * 1.2 + "px";
|
||||||
} else {
|
} else {
|
||||||
return fontSize + "px";
|
return fontSize + "px";
|
||||||
}
|
}
|
||||||
@@ -848,7 +834,7 @@ function Placeholder(props) {
|
|||||||
)}
|
)}
|
||||||
{isTabAndMobile ? (
|
{isTabAndMobile ? (
|
||||||
<div
|
<div
|
||||||
className="flex items-stretch"
|
className="flex items-stretch justify-center"
|
||||||
style={{
|
style={{
|
||||||
left: xPos(props.pos, props.isSignYourself),
|
left: xPos(props.pos, props.isSignYourself),
|
||||||
top: yPos(props.pos, props.isSignYourself),
|
top: yPos(props.pos, props.isSignYourself),
|
||||||
@@ -958,8 +944,8 @@ function Placeholder(props) {
|
|||||||
<span>{t("font-size")} :</span>
|
<span>{t("font-size")} :</span>
|
||||||
<select
|
<select
|
||||||
className="ml-[3px] md:ml:[7px] op-select op-select-bordered op-select-sm focus:outline-none hover:border-base-content text-xs"
|
className="ml-[3px] md:ml:[7px] op-select op-select-bordered op-select-sm focus:outline-none hover:border-base-content text-xs"
|
||||||
value={props.fontSize || clickonWidget.options?.fontSize || "12"}
|
value={props.fontSize || clickonWidget.options?.fontSize || 12}
|
||||||
onChange={(e) => props.setFontSize(e.target.value)}
|
onChange={(e) => props.setFontSize(parseInt(e.target.value))}
|
||||||
>
|
>
|
||||||
{fontsizeArr.map((size, ind) => {
|
{fontsizeArr.map((size, ind) => {
|
||||||
return (
|
return (
|
||||||
|
|||||||
@@ -361,6 +361,7 @@ function RenderPdf({
|
|||||||
fontColor={fontColor}
|
fontColor={fontColor}
|
||||||
setFontColor={setFontColor}
|
setFontColor={setFontColor}
|
||||||
isResize={isResize}
|
isResize={isResize}
|
||||||
|
unSignedWidgetId={unSignedWidgetId}
|
||||||
/>
|
/>
|
||||||
</React.Fragment>
|
</React.Fragment>
|
||||||
);
|
);
|
||||||
@@ -555,6 +556,7 @@ function RenderPdf({
|
|||||||
fontColor={fontColor}
|
fontColor={fontColor}
|
||||||
setFontColor={setFontColor}
|
setFontColor={setFontColor}
|
||||||
isResize={isResize}
|
isResize={isResize}
|
||||||
|
unSignedWidgetId={unSignedWidgetId}
|
||||||
/>
|
/>
|
||||||
</React.Fragment>
|
</React.Fragment>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -9,15 +9,13 @@ function SelectLanguage(props) {
|
|||||||
{ value: "es", text: "Española" },
|
{ value: "es", text: "Española" },
|
||||||
{ value: "fr", text: "Français" }
|
{ value: "fr", text: "Français" }
|
||||||
];
|
];
|
||||||
const [lang, setLang] = useState(i18next.language || "en");
|
const defaultLanguage = i18next.language || "en";
|
||||||
|
const [lang, setLang] = useState(defaultLanguage);
|
||||||
// This function put query that helps to change the language
|
// This function put query that helps to change the language
|
||||||
const handleChangeLang = (e) => {
|
const handleChangeLang = (e) => {
|
||||||
setLang(e.target.value);
|
setLang(e.target.value);
|
||||||
i18n.changeLanguage(e.target.value);
|
i18n.changeLanguage(e.target.value);
|
||||||
props?.updateExtUser &&
|
props?.updateExtUser && props.updateExtUser({ language: e.target.value });
|
||||||
props.updateExtUser({
|
|
||||||
language: e.target.value
|
|
||||||
});
|
|
||||||
};
|
};
|
||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
@@ -32,9 +30,7 @@ function SelectLanguage(props) {
|
|||||||
!props.isProfile ? " md:w-[15%] w-[50%]" : "w-[180px]"
|
!props.isProfile ? " md:w-[15%] w-[50%]" : "w-[180px]"
|
||||||
} op-select op-select-bordered bg-white op-select-sm `}
|
} op-select op-select-bordered bg-white op-select-sm `}
|
||||||
>
|
>
|
||||||
<option disabled selected>
|
<option disabled>select</option>
|
||||||
select
|
|
||||||
</option>
|
|
||||||
{languages.map((item) => {
|
{languages.map((item) => {
|
||||||
return (
|
return (
|
||||||
<option key={item.value} value={item.value}>
|
<option key={item.value} value={item.value}>
|
||||||
|
|||||||
@@ -1,39 +1,20 @@
|
|||||||
import React, { useRef, useState, useEffect } from "react";
|
import React, { useRef, useState, useEffect } from "react";
|
||||||
import { useTranslation } from "react-i18next";
|
import { useTranslation } from "react-i18next";
|
||||||
import SignatureCanvas from "react-signature-canvas";
|
import SignatureCanvas from "react-signature-canvas";
|
||||||
function SignPad({
|
|
||||||
isSignPad,
|
function SignPad(props) {
|
||||||
isStamp,
|
|
||||||
setIsImageSelect,
|
|
||||||
onSaveSign,
|
|
||||||
setIsSignPad,
|
|
||||||
setImage,
|
|
||||||
isImageSelect,
|
|
||||||
imageRef,
|
|
||||||
onImageChange,
|
|
||||||
onSaveImage,
|
|
||||||
image,
|
|
||||||
defaultSign,
|
|
||||||
setSignature,
|
|
||||||
myInitial,
|
|
||||||
isInitial,
|
|
||||||
setIsInitial,
|
|
||||||
setIsStamp,
|
|
||||||
widgetType,
|
|
||||||
currWidgetsDetails,
|
|
||||||
setCurrWidgetsDetails
|
|
||||||
}) {
|
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
const [penColor, setPenColor] = useState("blue");
|
const [penColor, setPenColor] = useState("blue");
|
||||||
const allColor = ["blue", "red", "black"];
|
const allColor = ["blue", "red", "black"];
|
||||||
const canvasRef = useRef(null);
|
const canvasRef = useRef(null);
|
||||||
const [isDefaultSign, setIsDefaultSign] = useState(false);
|
const [isDefaultSign, setIsDefaultSign] = useState(false);
|
||||||
const [isTab, setIsTab] = useState("draw");
|
const [isTab, setIsTab] = useState("");
|
||||||
const [isSignImg, setIsSignImg] = useState("");
|
const [isSignImg, setIsSignImg] = useState("");
|
||||||
const [signValue, setSignValue] = useState("");
|
const [signValue, setSignValue] = useState("");
|
||||||
const [textWidth, setTextWidth] = useState(0);
|
const [textWidth, setTextWidth] = useState(0);
|
||||||
const [textHeight, setTextHeight] = useState(0);
|
const [textHeight, setTextHeight] = useState(0);
|
||||||
const [signatureType, setSignatureType] = useState("draw");
|
const [signatureType, setSignatureType] = useState("");
|
||||||
|
const [isSignTypes, setIsSignTypes] = useState(true);
|
||||||
const fontOptions = [
|
const fontOptions = [
|
||||||
{ value: "Fasthand" },
|
{ value: "Fasthand" },
|
||||||
{ value: "Dancing Script" },
|
{ value: "Dancing Script" },
|
||||||
@@ -53,24 +34,58 @@ function SignPad({
|
|||||||
const jsonSender = JSON.parse(senderUser);
|
const jsonSender = JSON.parse(senderUser);
|
||||||
const currentUserName = jsonSender && jsonSender?.name;
|
const currentUserName = jsonSender && jsonSender?.name;
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
handleTab();
|
||||||
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||||
|
}, [props.signatureTypes]);
|
||||||
|
|
||||||
|
function handleTab() {
|
||||||
|
const signtypes = props?.signatureTypes || [];
|
||||||
|
const index = signtypes?.findIndex((x) => x.enabled === true);
|
||||||
|
if (index !== -1) {
|
||||||
|
setIsSignTypes(true);
|
||||||
|
const tab = props?.signatureTypes[index].name;
|
||||||
|
if (tab === "draw") {
|
||||||
|
setIsTab("draw");
|
||||||
|
setSignatureType("draw");
|
||||||
|
} else if (tab === "upload") {
|
||||||
|
props?.setIsImageSelect(true);
|
||||||
|
setIsTab("uploadImage");
|
||||||
|
} else if (tab === "typed") {
|
||||||
|
setIsTab("type");
|
||||||
|
} else if (tab === "default") {
|
||||||
|
setIsTab("mysignature");
|
||||||
|
} else {
|
||||||
|
setIsTab(true);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
setIsSignTypes(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
function isTabEnabled(tabName) {
|
||||||
|
const isEnabled = props?.signatureTypes.find(
|
||||||
|
(x) => x.name === tabName
|
||||||
|
)?.enabled;
|
||||||
|
return isEnabled;
|
||||||
|
}
|
||||||
|
|
||||||
//function for clear signature image
|
//function for clear signature image
|
||||||
const handleClear = () => {
|
const handleClear = () => {
|
||||||
setCurrWidgetsDetails({});
|
props?.setCurrWidgetsDetails({});
|
||||||
if (isTab === "draw") {
|
if (isTab === "draw") {
|
||||||
if (canvasRef.current) {
|
if (canvasRef.current) {
|
||||||
canvasRef.current.clear();
|
canvasRef.current.clear();
|
||||||
} else if (isStamp) {
|
} else if (props?.isStamp) {
|
||||||
setImage("");
|
props?.setImage("");
|
||||||
}
|
}
|
||||||
setIsSignImg("");
|
setIsSignImg("");
|
||||||
} else if (isTab === "uploadImage") {
|
} else if (isTab === "uploadImage") {
|
||||||
setImage("");
|
props?.setImage("");
|
||||||
}
|
}
|
||||||
// setIsInitial(false);
|
|
||||||
};
|
};
|
||||||
//function for set signature url
|
//function for set signature url
|
||||||
const handleSignatureChange = (data) => {
|
const handleSignatureChange = (data) => {
|
||||||
setSignature(data);
|
props?.setSignature(data);
|
||||||
setIsSignImg(data);
|
setIsSignImg(data);
|
||||||
};
|
};
|
||||||
//save button component
|
//save button component
|
||||||
@@ -88,58 +103,57 @@ function SignPad({
|
|||||||
)}
|
)}
|
||||||
<button
|
<button
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
setCurrWidgetsDetails({});
|
props?.setCurrWidgetsDetails({});
|
||||||
if (!image) {
|
if (!props?.image) {
|
||||||
if (isTab === "mysignature") {
|
if (isTab === "mysignature") {
|
||||||
setIsSignImg("");
|
setIsSignImg("");
|
||||||
if (isInitial) {
|
if (props?.isInitial) {
|
||||||
onSaveSign(signatureType, "initials");
|
props?.onSaveSign(signatureType, "initials");
|
||||||
} else {
|
} else {
|
||||||
onSaveSign(null, "default");
|
props?.onSaveSign(null, "default");
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (isTab === "type") {
|
if (isTab === "type") {
|
||||||
setIsSignImg("");
|
setIsSignImg("");
|
||||||
onSaveSign(
|
props?.onSaveSign(
|
||||||
null,
|
null,
|
||||||
false,
|
false,
|
||||||
!isInitial && textWidth > 150 ? 150 : textWidth,
|
!props?.isInitial && textWidth > 150 ? 150 : textWidth,
|
||||||
!isInitial && textHeight > 35 ? 35 : textHeight
|
!props?.isInitial && textHeight > 35 ? 35 : textHeight
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
setIsSignImg("");
|
setIsSignImg("");
|
||||||
canvasRef.current.clear();
|
canvasRef.current.clear();
|
||||||
onSaveSign(signatureType);
|
props?.onSaveSign(signatureType);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
setPenColor("blue");
|
setPenColor("blue");
|
||||||
} else {
|
} else {
|
||||||
setIsSignImg("");
|
setIsSignImg("");
|
||||||
onSaveImage(signatureType);
|
props?.onSaveImage(signatureType);
|
||||||
}
|
}
|
||||||
setIsSignPad(false);
|
props?.setIsSignPad(false);
|
||||||
setIsInitial(false);
|
props?.setIsInitial(false);
|
||||||
setIsImageSelect(false);
|
props?.setIsImageSelect(false);
|
||||||
setIsDefaultSign(false);
|
setIsDefaultSign(false);
|
||||||
setImage();
|
props?.setImage();
|
||||||
setIsTab("draw");
|
handleTab();
|
||||||
setSignValue("");
|
setSignValue("");
|
||||||
setIsStamp(false);
|
props?.setIsStamp(false);
|
||||||
}}
|
}}
|
||||||
type="button"
|
type="button"
|
||||||
className={`${
|
className={`${
|
||||||
isSignImg || image || isDefaultSign || textWidth
|
isSignImg || props?.image || isDefaultSign || textWidth
|
||||||
? ""
|
? ""
|
||||||
: "pointer-events-none"
|
: "pointer-events-none"
|
||||||
} op-btn op-btn-primary shadow-lg`}
|
} op-btn op-btn-primary shadow-lg`}
|
||||||
disabled={
|
disabled={
|
||||||
(isTab === "draw" && isSignImg) ||
|
(isTab === "draw" && isSignImg) ||
|
||||||
(isTab === "image" && image) ||
|
(isTab === "image" && props?.image) ||
|
||||||
(isTab === "mysignature" && isDefaultSign) ||
|
(isTab === "mysignature" && isDefaultSign) ||
|
||||||
(isTab === "type" && signValue)
|
(isTab === "type" && signValue)
|
||||||
? false
|
? false
|
||||||
: image
|
: props?.image
|
||||||
? false
|
? false
|
||||||
: true
|
: true
|
||||||
}
|
}
|
||||||
@@ -151,12 +165,12 @@ function SignPad({
|
|||||||
};
|
};
|
||||||
//useEffect for set already draw or save signature url/text url of signature text type and draw type for initial type and signature type widgets
|
//useEffect for set already draw or save signature url/text url of signature text type and draw type for initial type and signature type widgets
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (currWidgetsDetails && canvasRef.current) {
|
if (props?.currWidgetsDetails && canvasRef.current) {
|
||||||
const isWidgetType = currWidgetsDetails?.type;
|
const isWidgetType = props?.currWidgetsDetails?.type;
|
||||||
const signatureType = currWidgetsDetails?.signatureType;
|
const signatureType = props?.currWidgetsDetails?.signatureType;
|
||||||
const url = currWidgetsDetails?.SignUrl;
|
const url = props?.currWidgetsDetails?.SignUrl;
|
||||||
//checking widget type and draw type signature url
|
//checking widget type and draw type signature url
|
||||||
if (isInitial) {
|
if (props?.isInitial) {
|
||||||
if (isWidgetType === "initials" && signatureType === "draw" && url) {
|
if (isWidgetType === "initials" && signatureType === "draw" && url) {
|
||||||
canvasRef.current.fromDataURL(url);
|
canvasRef.current.fromDataURL(url);
|
||||||
}
|
}
|
||||||
@@ -171,12 +185,12 @@ function SignPad({
|
|||||||
|
|
||||||
const trimmedName = currentUserName && currentUserName?.trim();
|
const trimmedName = currentUserName && currentUserName?.trim();
|
||||||
const firstCharacter = trimmedName?.charAt(0);
|
const firstCharacter = trimmedName?.charAt(0);
|
||||||
const userName = isInitial ? firstCharacter : currentUserName;
|
const userName = props?.isInitial ? firstCharacter : currentUserName;
|
||||||
setSignValue(userName || "");
|
setSignValue(userName || "");
|
||||||
setFontSelect("Fasthand");
|
setFontSelect("Fasthand");
|
||||||
|
|
||||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||||
}, [isSignPad]);
|
}, [props.isSignPad]);
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const loadFont = async () => {
|
const loadFont = async () => {
|
||||||
try {
|
try {
|
||||||
@@ -204,7 +218,7 @@ function SignPad({
|
|||||||
? signValue?.trim()
|
? signValue?.trim()
|
||||||
: currentUserName?.trim();
|
: currentUserName?.trim();
|
||||||
const firstCharacter = trimmedName?.charAt(0);
|
const firstCharacter = trimmedName?.charAt(0);
|
||||||
const userName = isInitial ? firstCharacter : signValue;
|
const userName = props?.isInitial ? firstCharacter : signValue;
|
||||||
setSignValue(userName);
|
setSignValue(userName);
|
||||||
convertToImg(fontSelect, userName);
|
convertToImg(fontSelect, userName);
|
||||||
}
|
}
|
||||||
@@ -233,7 +247,7 @@ function SignPad({
|
|||||||
// Draw the text content on the canvas
|
// Draw the text content on the canvas
|
||||||
const ctx = canvasElement.getContext("2d");
|
const ctx = canvasElement.getContext("2d");
|
||||||
const pixelRatio = window.devicePixelRatio || 1;
|
const pixelRatio = window.devicePixelRatio || 1;
|
||||||
const addExtraWidth = isInitial ? 10 : 50;
|
const addExtraWidth = props?.isInitial ? 10 : 50;
|
||||||
const width = span.offsetWidth + addExtraWidth;
|
const width = span.offsetWidth + addExtraWidth;
|
||||||
const height = span.offsetHeight;
|
const height = span.offsetHeight;
|
||||||
setTextWidth(width);
|
setTextWidth(width);
|
||||||
@@ -255,7 +269,7 @@ function SignPad({
|
|||||||
document.body.removeChild(span);
|
document.body.removeChild(span);
|
||||||
// Convert the canvas to image data
|
// Convert the canvas to image data
|
||||||
const dataUrl = canvasElement.toDataURL("image/png");
|
const dataUrl = canvasElement.toDataURL("image/png");
|
||||||
setSignature(dataUrl);
|
props?.setSignature(dataUrl);
|
||||||
};
|
};
|
||||||
|
|
||||||
const PenColorComponent = (props) => {
|
const PenColorComponent = (props) => {
|
||||||
@@ -297,319 +311,365 @@ function SignPad({
|
|||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// `handleCancelBtn` function trigger when user click on cross button
|
||||||
|
const handleCancelBtn = () => {
|
||||||
|
setPenColor("blue");
|
||||||
|
props?.setIsSignPad(false);
|
||||||
|
props?.setIsInitial(false);
|
||||||
|
props?.setIsImageSelect(false);
|
||||||
|
setIsDefaultSign(false);
|
||||||
|
props?.setImage();
|
||||||
|
handleTab();
|
||||||
|
setSignValue("");
|
||||||
|
props?.setIsStamp(false);
|
||||||
|
};
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
{isSignPad && (
|
{props?.isSignPad && (
|
||||||
<div className="op-modal op-modal-open">
|
<div className="op-modal op-modal-open">
|
||||||
<div className="op-modal-box px-[13px] pt-2 pb-0">
|
<div className="op-modal-box px-[13px] pt-2 pb-0">
|
||||||
<div className="flex justify-between text-base-content items-center">
|
{isSignTypes ? (
|
||||||
<div className="text-[1.2rem]">
|
<>
|
||||||
<div className="flex flex-row justify-between mt-[3px]">
|
<div className="flex justify-between text-base-content items-center">
|
||||||
<div className="flex flex-row justify-between gap-[5px] md:gap-[8px] text-[11px] md:text-base">
|
<div className="text-[1.2rem]">
|
||||||
{isStamp ? (
|
<div className="flex flex-row justify-between mt-[3px]">
|
||||||
<span className="text-base-content font-bold text-lg">
|
<div className="flex flex-row justify-between gap-[5px] md:gap-[8px] text-[11px] md:text-base">
|
||||||
{widgetType === "image" ||
|
{props?.isStamp ? (
|
||||||
currWidgetsDetails?.type === "image"
|
<span className="text-base-content font-bold text-lg">
|
||||||
? t("upload-image")
|
{props?.widgetType === "image" ||
|
||||||
: t("upload-stamp-image")}
|
props?.currWidgetsDetails?.type === "image"
|
||||||
</span>
|
? t("upload-image")
|
||||||
) : (
|
: t("upload-stamp-image")}
|
||||||
<>
|
|
||||||
<div>
|
|
||||||
<span
|
|
||||||
onClick={() => {
|
|
||||||
setIsDefaultSign(false);
|
|
||||||
setIsImageSelect(false);
|
|
||||||
setIsTab("draw");
|
|
||||||
setImage();
|
|
||||||
if (isSignImg) {
|
|
||||||
setSignature(isSignImg);
|
|
||||||
}
|
|
||||||
}}
|
|
||||||
className={`${
|
|
||||||
isTab === "draw"
|
|
||||||
? "op-link-primary"
|
|
||||||
: "no-underline"
|
|
||||||
} op-link underline-offset-8 ml-[2px]`}
|
|
||||||
>
|
|
||||||
{t("draw")}
|
|
||||||
</span>
|
</span>
|
||||||
</div>
|
|
||||||
<div>
|
|
||||||
<span
|
|
||||||
onClick={() => {
|
|
||||||
setIsDefaultSign(false);
|
|
||||||
setIsImageSelect(true);
|
|
||||||
setIsTab("uploadImage");
|
|
||||||
setSignatureType("");
|
|
||||||
}}
|
|
||||||
className={`${
|
|
||||||
isTab === "uploadImage"
|
|
||||||
? "op-link-primary"
|
|
||||||
: "no-underline"
|
|
||||||
} op-link underline-offset-8 ml-[2px]`}
|
|
||||||
>
|
|
||||||
{t("upload-image")}
|
|
||||||
</span>
|
|
||||||
</div>
|
|
||||||
<div>
|
|
||||||
<span
|
|
||||||
onClick={() => {
|
|
||||||
setIsDefaultSign(false);
|
|
||||||
setIsImageSelect(false);
|
|
||||||
setIsTab("type");
|
|
||||||
setSignatureType("");
|
|
||||||
setImage();
|
|
||||||
}}
|
|
||||||
className={`${
|
|
||||||
isTab === "type"
|
|
||||||
? "op-link-primary"
|
|
||||||
: "no-underline"
|
|
||||||
} op-link underline-offset-8 ml-[2px]`}
|
|
||||||
>
|
|
||||||
{t("type")}
|
|
||||||
</span>
|
|
||||||
</div>
|
|
||||||
{!isInitial && defaultSign ? (
|
|
||||||
<div>
|
|
||||||
<span
|
|
||||||
onClick={() => {
|
|
||||||
setIsDefaultSign(true);
|
|
||||||
setIsImageSelect(true);
|
|
||||||
setIsTab("mysignature");
|
|
||||||
setSignatureType("");
|
|
||||||
setImage();
|
|
||||||
}}
|
|
||||||
className={`${
|
|
||||||
isTab === "mysignature"
|
|
||||||
? "op-link-primary"
|
|
||||||
: "no-underline"
|
|
||||||
} op-link underline-offset-8 ml-[2px]`}
|
|
||||||
>
|
|
||||||
{t("my-signature")}
|
|
||||||
</span>
|
|
||||||
</div>
|
|
||||||
) : (
|
) : (
|
||||||
isInitial &&
|
<>
|
||||||
myInitial && (
|
{isTabEnabled("draw") && (
|
||||||
<div>
|
<div>
|
||||||
<span
|
<span
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
setIsDefaultSign(true);
|
setIsDefaultSign(false);
|
||||||
setIsImageSelect(true);
|
props?.setIsImageSelect(false);
|
||||||
setIsTab("mysignature");
|
setIsTab("draw");
|
||||||
setSignatureType("");
|
props?.setImage();
|
||||||
setImage();
|
if (isSignImg) {
|
||||||
}}
|
props?.setSignature(isSignImg);
|
||||||
className={`${
|
}
|
||||||
isTab === "mysignature"
|
}}
|
||||||
? "op-link-primary"
|
className={`${
|
||||||
: "no-underline"
|
isTab === "draw"
|
||||||
} op-link underline-offset-8 ml-[2px]`}
|
? "op-link-primary"
|
||||||
>
|
: "no-underline"
|
||||||
{t("my-initials")}
|
} op-link underline-offset-8 ml-[2px]`}
|
||||||
</span>
|
>
|
||||||
</div>
|
{t("draw")}
|
||||||
)
|
</span>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
{isTabEnabled("upload") && (
|
||||||
|
<div>
|
||||||
|
<span
|
||||||
|
onClick={() => {
|
||||||
|
setIsDefaultSign(false);
|
||||||
|
props?.setIsImageSelect(true);
|
||||||
|
setIsTab("uploadImage");
|
||||||
|
setSignatureType("");
|
||||||
|
}}
|
||||||
|
className={`${
|
||||||
|
isTab === "uploadImage"
|
||||||
|
? "op-link-primary"
|
||||||
|
: "no-underline"
|
||||||
|
} op-link underline-offset-8 ml-[2px]`}
|
||||||
|
>
|
||||||
|
{t("upload-image")}
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
{isTabEnabled("typed") && (
|
||||||
|
<div>
|
||||||
|
<span
|
||||||
|
onClick={() => {
|
||||||
|
setIsDefaultSign(false);
|
||||||
|
props?.setIsImageSelect(false);
|
||||||
|
setIsTab("type");
|
||||||
|
setSignatureType("");
|
||||||
|
props?.setImage();
|
||||||
|
}}
|
||||||
|
className={`${
|
||||||
|
isTab === "type"
|
||||||
|
? "op-link-primary"
|
||||||
|
: "no-underline"
|
||||||
|
} op-link underline-offset-8 ml-[2px]`}
|
||||||
|
>
|
||||||
|
{t("type")}
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
{!props?.isInitial &&
|
||||||
|
props?.defaultSign &&
|
||||||
|
isTabEnabled("default") ? (
|
||||||
|
<div>
|
||||||
|
<span
|
||||||
|
onClick={() => {
|
||||||
|
setIsDefaultSign(true);
|
||||||
|
props?.setIsImageSelect(true);
|
||||||
|
setIsTab("mysignature");
|
||||||
|
setSignatureType("");
|
||||||
|
props?.setImage();
|
||||||
|
}}
|
||||||
|
className={`${
|
||||||
|
isTab === "mysignature"
|
||||||
|
? "op-link-primary"
|
||||||
|
: "no-underline"
|
||||||
|
} op-link underline-offset-8 ml-[2px]`}
|
||||||
|
>
|
||||||
|
{t("my-signature")}
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
) : (
|
||||||
|
props?.isInitial &&
|
||||||
|
props?.myInitial &&
|
||||||
|
isTabEnabled("default") && (
|
||||||
|
<div>
|
||||||
|
<span
|
||||||
|
onClick={() => {
|
||||||
|
setIsDefaultSign(true);
|
||||||
|
props?.setIsImageSelect(true);
|
||||||
|
setIsTab("mysignature");
|
||||||
|
setSignatureType("");
|
||||||
|
props?.setImage();
|
||||||
|
}}
|
||||||
|
className={`${
|
||||||
|
isTab === "mysignature"
|
||||||
|
? "op-link-primary"
|
||||||
|
: "no-underline"
|
||||||
|
} op-link underline-offset-8 ml-[2px]`}
|
||||||
|
>
|
||||||
|
{t("my-initials")}
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
)}
|
||||||
|
</>
|
||||||
)}
|
)}
|
||||||
</>
|
|
||||||
)}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div
|
|
||||||
className="text-[1.5rem] cursor-pointer"
|
|
||||||
onClick={() => {
|
|
||||||
setPenColor("blue");
|
|
||||||
setIsSignPad(false);
|
|
||||||
setIsInitial(false);
|
|
||||||
setIsImageSelect(false);
|
|
||||||
setIsDefaultSign(false);
|
|
||||||
setImage();
|
|
||||||
setIsTab("draw");
|
|
||||||
setSignatureType("draw");
|
|
||||||
setSignValue("");
|
|
||||||
setIsStamp(false);
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
×
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div className="p-[20px] h-full">
|
|
||||||
{isDefaultSign ? (
|
|
||||||
<>
|
|
||||||
<div className="flex justify-center">
|
|
||||||
<div
|
|
||||||
style={{
|
|
||||||
border: "1.3px solid #007bff",
|
|
||||||
borderRadius: "2px",
|
|
||||||
display: "flex",
|
|
||||||
flexDirection: "column",
|
|
||||||
justifyContent: "center",
|
|
||||||
alignItems: "center",
|
|
||||||
marginBottom: 6,
|
|
||||||
cursor: "pointer"
|
|
||||||
}}
|
|
||||||
className={
|
|
||||||
isInitial ? "intialSignatureCanvas" : "signatureCanvas"
|
|
||||||
}
|
|
||||||
>
|
|
||||||
<img
|
|
||||||
alt="stamp img"
|
|
||||||
className="w-full h-full object-contain bg-white"
|
|
||||||
draggable="false"
|
|
||||||
src={isInitial ? myInitial : defaultSign}
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div className="flex justify-end">
|
|
||||||
<SaveBtn />
|
|
||||||
</div>
|
|
||||||
</>
|
|
||||||
) : isImageSelect || isStamp ? (
|
|
||||||
!image ? (
|
|
||||||
<div className="flex justify-center">
|
|
||||||
<div
|
|
||||||
style={{
|
|
||||||
border: "1.3px solid #007bff",
|
|
||||||
borderRadius: "2px",
|
|
||||||
display: "flex",
|
|
||||||
flexDirection: "column",
|
|
||||||
justifyContent: "center",
|
|
||||||
alignItems: "center",
|
|
||||||
marginBottom: 6,
|
|
||||||
cursor: "pointer"
|
|
||||||
}}
|
|
||||||
className={
|
|
||||||
isInitial ? "intialSignatureCanvas" : "signatureCanvas"
|
|
||||||
}
|
|
||||||
onClick={() => imageRef.current.click()}
|
|
||||||
>
|
|
||||||
<input
|
|
||||||
type="file"
|
|
||||||
onChange={onImageChange}
|
|
||||||
className="filetype"
|
|
||||||
accept="image/png,image/jpeg"
|
|
||||||
ref={imageRef}
|
|
||||||
hidden
|
|
||||||
/>
|
|
||||||
<i className="fa-light fa-cloud-upload-alt uploadImgLogo"></i>
|
|
||||||
<div className="text-[10px]">{t("upload")}</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
) : (
|
|
||||||
<>
|
|
||||||
<div className="flex justify-center">
|
|
||||||
<div
|
|
||||||
style={{
|
|
||||||
border: "1.3px solid #007bff",
|
|
||||||
borderRadius: "2px",
|
|
||||||
marginBottom: 6,
|
|
||||||
overflow: "hidden"
|
|
||||||
}}
|
|
||||||
className={
|
|
||||||
isInitial
|
|
||||||
? "intialSignatureCanvas"
|
|
||||||
: "signatureCanvas"
|
|
||||||
}
|
|
||||||
>
|
|
||||||
<img
|
|
||||||
alt="print img"
|
|
||||||
ref={imageRef}
|
|
||||||
src={image.src}
|
|
||||||
draggable="false"
|
|
||||||
className=" object-contain h-full w-full"
|
|
||||||
/>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div className="flex justify-end">
|
|
||||||
<SaveBtn />
|
|
||||||
</div>
|
|
||||||
</>
|
|
||||||
)
|
|
||||||
) : isTab === "type" ? (
|
|
||||||
<div>
|
|
||||||
<div className="flex justify-between items-center">
|
|
||||||
<span className="mr-[5px] text-[12px]">
|
|
||||||
{isInitial ? t("initial-teb") : t("signature-tab")}:
|
|
||||||
</span>
|
|
||||||
<input
|
|
||||||
maxLength={isInitial ? 3 : 30}
|
|
||||||
style={{ fontFamily: fontSelect, color: penColor }}
|
|
||||||
type="text"
|
|
||||||
className="ml-1 op-input op-input-bordered op-input-sm focus:outline-none hover:border-base-content w-full text-[20px]"
|
|
||||||
placeholder="Your signature"
|
|
||||||
value={signValue}
|
|
||||||
onChange={(e) => {
|
|
||||||
setSignValue(e.target.value);
|
|
||||||
convertToImg(fontSelect, e.target.value);
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
</div>
|
</div>
|
||||||
<div className="border-[1px] border-[#d6d3d3] mt-[10px] ml-[5px]">
|
<div
|
||||||
{fontOptions.map((font, ind) => {
|
className="text-[1.5rem] cursor-pointer"
|
||||||
return (
|
onClick={handleCancelBtn}
|
||||||
<div
|
>
|
||||||
key={ind}
|
×
|
||||||
style={{
|
|
||||||
cursor: "pointer",
|
|
||||||
fontFamily: font.value,
|
|
||||||
backgroundColor:
|
|
||||||
fontSelect === font.value && "rgb(206 225 247)"
|
|
||||||
}}
|
|
||||||
onClick={() => {
|
|
||||||
setFontSelect(font.value);
|
|
||||||
convertToImg(font.value, signValue);
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<div
|
|
||||||
style={{
|
|
||||||
padding: "5px 10px 5px 10px",
|
|
||||||
fontSize: "20px",
|
|
||||||
color: penColor
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
{signValue ? signValue : "Your signature"}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
})}
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div className="flex flex-row justify-between mt-[10px]">
|
|
||||||
<PenColorComponent convertToImg={convertToImg} />
|
|
||||||
<SaveBtn />
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
) : (
|
<div className="p-[20px] h-full">
|
||||||
<>
|
{isDefaultSign ? (
|
||||||
<div className="flex justify-center">
|
<>
|
||||||
<SignatureCanvas
|
<div className="flex justify-center">
|
||||||
ref={canvasRef}
|
<div
|
||||||
penColor={penColor}
|
style={{
|
||||||
canvasProps={{
|
border: "1.3px solid #007bff",
|
||||||
className: isInitial
|
borderRadius: "2px",
|
||||||
? "intialSignatureCanvas"
|
display: "flex",
|
||||||
: "signatureCanvas",
|
flexDirection: "column",
|
||||||
style: {
|
justifyContent: "center",
|
||||||
border: "1.6px solid #007bff",
|
alignItems: "center",
|
||||||
borderRadius: "2px"
|
marginBottom: 6,
|
||||||
}
|
cursor: "pointer"
|
||||||
}}
|
}}
|
||||||
// backgroundColor="rgb(255, 255, 255)"
|
className={
|
||||||
onEnd={() =>
|
props?.isInitial
|
||||||
handleSignatureChange(canvasRef.current?.toDataURL())
|
? "intialSignatureCanvas"
|
||||||
}
|
: "signatureCanvas"
|
||||||
dotSize={1}
|
}
|
||||||
/>
|
>
|
||||||
|
<img
|
||||||
|
alt="stamp img"
|
||||||
|
className="w-full h-full object-contain bg-white"
|
||||||
|
draggable="false"
|
||||||
|
src={
|
||||||
|
props?.isInitial
|
||||||
|
? props?.myInitial
|
||||||
|
: props?.defaultSign
|
||||||
|
}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div className="flex justify-end">
|
||||||
|
<SaveBtn />
|
||||||
|
</div>
|
||||||
|
</>
|
||||||
|
) : props?.isImageSelect || props?.isStamp ? (
|
||||||
|
!props?.image ? (
|
||||||
|
<div className="flex justify-center">
|
||||||
|
<div
|
||||||
|
style={{
|
||||||
|
border: "1.3px solid #007bff",
|
||||||
|
borderRadius: "2px",
|
||||||
|
display: "flex",
|
||||||
|
flexDirection: "column",
|
||||||
|
justifyContent: "center",
|
||||||
|
alignItems: "center",
|
||||||
|
marginBottom: 6,
|
||||||
|
cursor: "pointer"
|
||||||
|
}}
|
||||||
|
className={
|
||||||
|
props?.isInitial
|
||||||
|
? "intialSignatureCanvas"
|
||||||
|
: "signatureCanvas"
|
||||||
|
}
|
||||||
|
onClick={() => props?.imageRef.current.click()}
|
||||||
|
>
|
||||||
|
<input
|
||||||
|
type="file"
|
||||||
|
onChange={props?.onImageChange}
|
||||||
|
className="filetype"
|
||||||
|
accept="image/png,image/jpeg"
|
||||||
|
ref={props?.imageRef}
|
||||||
|
hidden
|
||||||
|
/>
|
||||||
|
<i className="fa-light fa-cloud-upload-alt uploadImgLogo"></i>
|
||||||
|
<div className="text-[10px]">{t("upload")}</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
) : (
|
||||||
|
<>
|
||||||
|
<div className="flex justify-center">
|
||||||
|
<div
|
||||||
|
style={{
|
||||||
|
border: "1.3px solid #007bff",
|
||||||
|
borderRadius: "2px",
|
||||||
|
marginBottom: 6,
|
||||||
|
overflow: "hidden"
|
||||||
|
}}
|
||||||
|
className={
|
||||||
|
props?.isInitial
|
||||||
|
? "intialSignatureCanvas"
|
||||||
|
: "signatureCanvas"
|
||||||
|
}
|
||||||
|
>
|
||||||
|
<img
|
||||||
|
alt="print img"
|
||||||
|
ref={props?.imageRef}
|
||||||
|
src={props?.image.src}
|
||||||
|
draggable="false"
|
||||||
|
className=" object-contain h-full w-full"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div className="flex justify-end">
|
||||||
|
<SaveBtn />
|
||||||
|
</div>
|
||||||
|
</>
|
||||||
|
)
|
||||||
|
) : isTab === "type" ? (
|
||||||
|
<div>
|
||||||
|
<div className="flex justify-between items-center">
|
||||||
|
<span className="mr-[5px] text-[12px]">
|
||||||
|
{props?.isInitial
|
||||||
|
? t("initial-teb")
|
||||||
|
: t("signature-tab")}
|
||||||
|
:
|
||||||
|
</span>
|
||||||
|
<input
|
||||||
|
maxLength={props?.isInitial ? 3 : 30}
|
||||||
|
style={{ fontFamily: fontSelect, color: penColor }}
|
||||||
|
type="text"
|
||||||
|
className="ml-1 op-input op-input-bordered op-input-sm focus:outline-none hover:border-base-content w-full text-[20px]"
|
||||||
|
placeholder="Your signature"
|
||||||
|
value={signValue}
|
||||||
|
onChange={(e) => {
|
||||||
|
setSignValue(e.target.value);
|
||||||
|
convertToImg(fontSelect, e.target.value);
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
<div className="border-[1px] border-[#d6d3d3] mt-[10px] ml-[5px]">
|
||||||
|
{fontOptions.map((font, ind) => {
|
||||||
|
return (
|
||||||
|
<div
|
||||||
|
key={ind}
|
||||||
|
style={{
|
||||||
|
cursor: "pointer",
|
||||||
|
fontFamily: font.value,
|
||||||
|
backgroundColor:
|
||||||
|
fontSelect === font.value &&
|
||||||
|
"rgb(206 225 247)"
|
||||||
|
}}
|
||||||
|
onClick={() => {
|
||||||
|
setFontSelect(font.value);
|
||||||
|
convertToImg(font.value, signValue);
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<div
|
||||||
|
style={{
|
||||||
|
padding: "5px 10px 5px 10px",
|
||||||
|
fontSize: "20px",
|
||||||
|
color: penColor
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
{signValue ? signValue : "Your signature"}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
})}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className="flex flex-row justify-between mt-[10px]">
|
||||||
|
<PenColorComponent convertToImg={convertToImg} />
|
||||||
|
<SaveBtn />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
) : (
|
||||||
|
<>
|
||||||
|
<div className="flex justify-center">
|
||||||
|
<SignatureCanvas
|
||||||
|
ref={canvasRef}
|
||||||
|
penColor={penColor}
|
||||||
|
canvasProps={{
|
||||||
|
className: props?.isInitial
|
||||||
|
? "intialSignatureCanvas"
|
||||||
|
: "signatureCanvas",
|
||||||
|
style: {
|
||||||
|
border: "1.6px solid #007bff",
|
||||||
|
borderRadius: "2px"
|
||||||
|
}
|
||||||
|
}}
|
||||||
|
// backgroundColor="rgb(255, 255, 255)"
|
||||||
|
onEnd={() =>
|
||||||
|
handleSignatureChange(
|
||||||
|
canvasRef.current?.toDataURL()
|
||||||
|
)
|
||||||
|
}
|
||||||
|
dotSize={1}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
<div className="flex flex-row justify-between mt-[10px]">
|
||||||
|
<PenColorComponent />
|
||||||
|
<SaveBtn />
|
||||||
|
</div>
|
||||||
|
</>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
</>
|
||||||
|
) : (
|
||||||
|
<div className="">
|
||||||
|
<div className="relative flex flex-row items-center justify-between">
|
||||||
|
<div className="text-base-content font-bold text-lg">
|
||||||
|
Signature
|
||||||
</div>
|
</div>
|
||||||
<div className="flex flex-row justify-between mt-[10px]">
|
<div
|
||||||
<PenColorComponent />
|
className="text-[1.5rem] cursor-pointer"
|
||||||
<SaveBtn />
|
onClick={handleCancelBtn}
|
||||||
|
>
|
||||||
|
×
|
||||||
</div>
|
</div>
|
||||||
</>
|
</div>
|
||||||
)}
|
<div className="mx-3 mb-6 mt-3">
|
||||||
</div>
|
<p>{t("at-least-one-signature-type")}</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
|
|||||||
@@ -21,9 +21,11 @@ function TextFontSetting(props) {
|
|||||||
value={
|
value={
|
||||||
props.fontSize ||
|
props.fontSize ||
|
||||||
props.currWidgetsDetails?.options?.fontSize ||
|
props.currWidgetsDetails?.options?.fontSize ||
|
||||||
"12"
|
12
|
||||||
}
|
}
|
||||||
onChange={(e) => props.setFontSize(e.target.value)}
|
onChange={(e) => {
|
||||||
|
props.setFontSize(parseInt(e.target.value));
|
||||||
|
}}
|
||||||
>
|
>
|
||||||
{fontsizeArr.map((size, ind) => {
|
{fontsizeArr.map((size, ind) => {
|
||||||
return (
|
return (
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import RecipientList from "./RecipientList";
|
|||||||
import { useDrag } from "react-dnd";
|
import { useDrag } from "react-dnd";
|
||||||
import WidgetList from "./WidgetList";
|
import WidgetList from "./WidgetList";
|
||||||
import {
|
import {
|
||||||
|
color,
|
||||||
radioButtonWidget,
|
radioButtonWidget,
|
||||||
textInputWidget,
|
textInputWidget,
|
||||||
textWidget,
|
textWidget,
|
||||||
@@ -43,163 +44,69 @@ function WidgetComponent({
|
|||||||
const [isSignersModal, setIsSignersModal] = useState(false);
|
const [isSignersModal, setIsSignersModal] = useState(false);
|
||||||
const [, dropdown] = useDrag({
|
const [, dropdown] = useDrag({
|
||||||
type: "BOX",
|
type: "BOX",
|
||||||
item: {
|
item: { type: "BOX", id: 5, text: "dropdown" },
|
||||||
type: "BOX",
|
|
||||||
id: 5,
|
|
||||||
text: "dropdown"
|
|
||||||
},
|
|
||||||
|
|
||||||
collect: (monitor) => ({
|
collect: (monitor) => ({
|
||||||
isDragDropdown: !!monitor.isDragging()
|
isDragDropdown: !!monitor.isDragging()
|
||||||
})
|
})
|
||||||
});
|
});
|
||||||
const [, checkbox] = useDrag({
|
const [, checkbox] = useDrag({
|
||||||
type: "BOX",
|
type: "BOX",
|
||||||
item: {
|
item: { type: "BOX", id: 6, text: "checkbox" },
|
||||||
type: "BOX",
|
collect: (monitor) => ({ isDragCheck: !!monitor.isDragging() })
|
||||||
id: 6,
|
|
||||||
text: "checkbox"
|
|
||||||
},
|
|
||||||
|
|
||||||
collect: (monitor) => ({
|
|
||||||
isDragCheck: !!monitor.isDragging()
|
|
||||||
})
|
|
||||||
});
|
});
|
||||||
const [, textInput] = useDrag({
|
const [, textInput] = useDrag({
|
||||||
type: "BOX",
|
type: "BOX",
|
||||||
item: {
|
item: { type: "BOX", id: 7, text: textInputWidget },
|
||||||
type: "BOX",
|
collect: (monitor) => ({ isDragTextInput: !!monitor.isDragging() })
|
||||||
id: 7,
|
|
||||||
text: textInputWidget
|
|
||||||
},
|
|
||||||
collect: (monitor) => ({
|
|
||||||
isDragTextInput: !!monitor.isDragging()
|
|
||||||
})
|
|
||||||
});
|
});
|
||||||
const [, initials] = useDrag({
|
const [, initials] = useDrag({
|
||||||
type: "BOX",
|
type: "BOX",
|
||||||
item: {
|
item: { type: "BOX", id: 8, text: "initials" },
|
||||||
type: "BOX",
|
collect: (monitor) => ({ isDragInitial: !!monitor.isDragging() })
|
||||||
id: 8,
|
|
||||||
text: "initials"
|
|
||||||
},
|
|
||||||
|
|
||||||
collect: (monitor) => ({
|
|
||||||
isDragInitial: !!monitor.isDragging()
|
|
||||||
})
|
|
||||||
});
|
});
|
||||||
const [, name] = useDrag({
|
const [, name] = useDrag({
|
||||||
type: "BOX",
|
type: "BOX",
|
||||||
item: {
|
item: { type: "BOX", id: 9, text: "name" },
|
||||||
type: "BOX",
|
collect: (monitor) => ({ isDragName: !!monitor.isDragging() })
|
||||||
id: 9,
|
|
||||||
text: "name"
|
|
||||||
},
|
|
||||||
|
|
||||||
collect: (monitor) => ({
|
|
||||||
isDragName: !!monitor.isDragging()
|
|
||||||
})
|
|
||||||
});
|
});
|
||||||
const [, company] = useDrag({
|
const [, company] = useDrag({
|
||||||
type: "BOX",
|
type: "BOX",
|
||||||
item: {
|
item: { type: "BOX", id: 10, text: "company" },
|
||||||
type: "BOX",
|
collect: (monitor) => ({ isDragCompany: !!monitor.isDragging() })
|
||||||
id: 10,
|
|
||||||
text: "company"
|
|
||||||
},
|
|
||||||
|
|
||||||
collect: (monitor) => ({
|
|
||||||
isDragCompany: !!monitor.isDragging()
|
|
||||||
})
|
|
||||||
});
|
});
|
||||||
const [, jobTitle] = useDrag({
|
const [, jobTitle] = useDrag({
|
||||||
type: "BOX",
|
type: "BOX",
|
||||||
item: {
|
item: { type: "BOX", id: 11, text: "job title" },
|
||||||
type: "BOX",
|
collect: (monitor) => ({ isDragJobtitle: !!monitor.isDragging() })
|
||||||
id: 11,
|
|
||||||
text: "job title"
|
|
||||||
},
|
|
||||||
|
|
||||||
collect: (monitor) => ({
|
|
||||||
isDragJobtitle: !!monitor.isDragging()
|
|
||||||
})
|
|
||||||
});
|
});
|
||||||
const [, date] = useDrag({
|
const [, date] = useDrag({
|
||||||
type: "BOX",
|
type: "BOX",
|
||||||
item: {
|
item: { type: "BOX", id: 12, text: "date" },
|
||||||
type: "BOX",
|
collect: (monitor) => ({ isDragDate: !!monitor.isDragging() })
|
||||||
id: 12,
|
|
||||||
text: "date"
|
|
||||||
},
|
|
||||||
|
|
||||||
collect: (monitor) => ({
|
|
||||||
isDragDate: !!monitor.isDragging()
|
|
||||||
})
|
|
||||||
});
|
});
|
||||||
const [, image] = useDrag({
|
const [, image] = useDrag({
|
||||||
type: "BOX",
|
type: "BOX",
|
||||||
item: {
|
item: { type: "BOX", id: 13, text: "image" },
|
||||||
type: "BOX",
|
collect: (monitor) => ({ isDragImage: !!monitor.isDragging() })
|
||||||
id: 13,
|
|
||||||
text: "image"
|
|
||||||
},
|
|
||||||
|
|
||||||
collect: (monitor) => ({
|
|
||||||
isDragImage: !!monitor.isDragging()
|
|
||||||
})
|
|
||||||
});
|
});
|
||||||
const [, email] = useDrag({
|
const [, email] = useDrag({
|
||||||
type: "BOX",
|
type: "BOX",
|
||||||
item: {
|
item: { type: "BOX", id: 14, text: "email" },
|
||||||
type: "BOX",
|
collect: (monitor) => ({ isDragEmail: !!monitor.isDragging() })
|
||||||
id: 14,
|
|
||||||
text: "email"
|
|
||||||
},
|
|
||||||
collect: (monitor) => ({
|
|
||||||
isDragEmail: !!monitor.isDragging()
|
|
||||||
})
|
|
||||||
});
|
});
|
||||||
const [, radioButton] = useDrag({
|
const [, radioButton] = useDrag({
|
||||||
type: "BOX",
|
type: "BOX",
|
||||||
|
item: { type: "BOX", id: 15, text: radioButtonWidget },
|
||||||
item: {
|
collect: (monitor) => ({ isDragRadiotton: !!monitor.isDragging() })
|
||||||
type: "BOX",
|
|
||||||
id: 15,
|
|
||||||
text: radioButtonWidget
|
|
||||||
},
|
|
||||||
collect: (monitor) => ({
|
|
||||||
isDragRadiotton: !!monitor.isDragging()
|
|
||||||
})
|
|
||||||
});
|
});
|
||||||
const [, text] = useDrag({
|
const [, text] = useDrag({
|
||||||
type: "BOX",
|
type: "BOX",
|
||||||
|
item: { type: "BOX", id: 16, text: textWidget },
|
||||||
item: {
|
collect: (monitor) => ({ isDragText: !!monitor.isDragging() })
|
||||||
type: "BOX",
|
|
||||||
id: 16,
|
|
||||||
text: textWidget
|
|
||||||
},
|
|
||||||
collect: (monitor) => ({
|
|
||||||
isDragText: !!monitor.isDragging()
|
|
||||||
})
|
|
||||||
});
|
});
|
||||||
const isMobile = window.innerWidth < 767;
|
const isMobile = window.innerWidth < 767;
|
||||||
const scrollContainerRef = useRef(null);
|
const scrollContainerRef = useRef(null);
|
||||||
const [widget, setWidget] = useState([]);
|
const [widget, setWidget] = useState([]);
|
||||||
const color = [
|
|
||||||
"#93a3db",
|
|
||||||
"#e6c3db",
|
|
||||||
"#c0e3bc",
|
|
||||||
"#bce3db",
|
|
||||||
"#b8ccdb",
|
|
||||||
"#ceb8db",
|
|
||||||
"#ffccff",
|
|
||||||
"#99ffcc",
|
|
||||||
"#cc99ff",
|
|
||||||
"#ffcc99",
|
|
||||||
"#66ccff",
|
|
||||||
"#ffffcc"
|
|
||||||
];
|
|
||||||
const handleModal = () => {
|
const handleModal = () => {
|
||||||
setIsSignersModal(!isSignersModal);
|
setIsSignersModal(!isSignersModal);
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -2,7 +2,11 @@ import React, { useEffect, useState } from "react";
|
|||||||
import ModalUi from "../../primitives/ModalUi";
|
import ModalUi from "../../primitives/ModalUi";
|
||||||
import "../../styles/AddUser.css";
|
import "../../styles/AddUser.css";
|
||||||
import RegexParser from "regex-parser";
|
import RegexParser from "regex-parser";
|
||||||
import { textInputWidget, textWidget } from "../../constant/Utils";
|
import {
|
||||||
|
signatureTypes,
|
||||||
|
textInputWidget,
|
||||||
|
textWidget
|
||||||
|
} from "../../constant/Utils";
|
||||||
import Upgrade from "../../primitives/Upgrade";
|
import Upgrade from "../../primitives/Upgrade";
|
||||||
import { isEnableSubscription } from "../../constant/const";
|
import { isEnableSubscription } from "../../constant/const";
|
||||||
import Tooltip from "../../primitives/Tooltip";
|
import Tooltip from "../../primitives/Tooltip";
|
||||||
@@ -11,6 +15,7 @@ import { useTranslation } from "react-i18next";
|
|||||||
|
|
||||||
const WidgetNameModal = (props) => {
|
const WidgetNameModal = (props) => {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
|
const signTypes = props?.signatureType || signatureTypes;
|
||||||
const [formdata, setFormdata] = useState({
|
const [formdata, setFormdata] = useState({
|
||||||
name: "",
|
name: "",
|
||||||
defaultValue: "",
|
defaultValue: "",
|
||||||
@@ -21,6 +26,7 @@ const WidgetNameModal = (props) => {
|
|||||||
const [isValid, setIsValid] = useState(true);
|
const [isValid, setIsValid] = useState(true);
|
||||||
const statusArr = ["Required", "Optional"];
|
const statusArr = ["Required", "Optional"];
|
||||||
const inputOpt = ["text", "email", "number"];
|
const inputOpt = ["text", "email", "number"];
|
||||||
|
const [signatureType, setSignatureType] = useState([]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (props.defaultdata) {
|
if (props.defaultdata) {
|
||||||
@@ -40,12 +46,32 @@ const WidgetNameModal = (props) => {
|
|||||||
name: props.defaultdata?.options?.name || ""
|
name: props.defaultdata?.options?.name || ""
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (signTypes.length > 0) {
|
||||||
|
const defaultSignatureType = signTypes || [];
|
||||||
|
setSignatureType(defaultSignatureType);
|
||||||
|
}
|
||||||
// eslint-disable-next-line
|
// eslint-disable-next-line
|
||||||
}, [props.defaultdata]);
|
}, [props.defaultdata]);
|
||||||
const handleSubmit = (e) => {
|
const handleSubmit = (e) => {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
if (props.handleData) {
|
if (props.handleData) {
|
||||||
props.handleData(formdata);
|
if (["signature", "initials"].includes(props.defaultdata?.type)) {
|
||||||
|
const enabledSignTypes = signatureType?.filter((x) => x.enabled);
|
||||||
|
const isDefaultSignTypeOnly =
|
||||||
|
enabledSignTypes?.length === 1 &&
|
||||||
|
enabledSignTypes[0]?.name === "default";
|
||||||
|
if (enabledSignTypes.length === 0) {
|
||||||
|
alert(t("at-least-one-signature-type"));
|
||||||
|
} else if (isDefaultSignTypeOnly) {
|
||||||
|
alert(t("expect-default-one-more-signature-type"));
|
||||||
|
} else {
|
||||||
|
const data = { ...formdata, signatureType };
|
||||||
|
props.handleData(data, props.defaultdata?.type);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
props.handleData(formdata);
|
||||||
|
}
|
||||||
setFormdata({
|
setFormdata({
|
||||||
name: "",
|
name: "",
|
||||||
defaultValue: "",
|
defaultValue: "",
|
||||||
@@ -53,6 +79,7 @@ const WidgetNameModal = (props) => {
|
|||||||
hint: "",
|
hint: "",
|
||||||
textvalidate: ""
|
textvalidate: ""
|
||||||
});
|
});
|
||||||
|
setSignatureType(signTypes);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
const handleChange = (e) => {
|
const handleChange = (e) => {
|
||||||
@@ -102,6 +129,15 @@ const WidgetNameModal = (props) => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const handleCheckboxChange = (index) => {
|
||||||
|
// Create a copy of the signatureType array
|
||||||
|
const updatedSignatureType = [...signatureType];
|
||||||
|
// Toggle the enabled value for the clicked item
|
||||||
|
updatedSignatureType[index].enabled = !updatedSignatureType[index].enabled;
|
||||||
|
// Update the state with the modified array
|
||||||
|
setSignatureType(updatedSignatureType);
|
||||||
|
};
|
||||||
return (
|
return (
|
||||||
<ModalUi
|
<ModalUi
|
||||||
isOpen={props.isOpen}
|
isOpen={props.isOpen}
|
||||||
@@ -111,24 +147,30 @@ const WidgetNameModal = (props) => {
|
|||||||
<form
|
<form
|
||||||
onSubmit={handleSubmit}
|
onSubmit={handleSubmit}
|
||||||
className={`${
|
className={`${
|
||||||
props.defaultdata?.type === textInputWidget ? "pt-0" : ""
|
props.defaultdata?.type === textInputWidget
|
||||||
|
? "pt-0"
|
||||||
|
: ["signature", "initials"].includes(props.defaultdata?.type)
|
||||||
|
? "pt-2"
|
||||||
|
: ""
|
||||||
} p-[20px] text-base-content`}
|
} p-[20px] text-base-content`}
|
||||||
>
|
>
|
||||||
<div className="mb-[0.75rem] text-[13px]">
|
{!["signature", "initials"].includes(props.defaultdata?.type) && (
|
||||||
<label htmlFor="name">
|
<div className="mb-[0.75rem] text-[13px]">
|
||||||
{t("name")}
|
<label htmlFor="name">
|
||||||
<span className="text-[red]"> *</span>
|
{t("name")}
|
||||||
</label>
|
<span className="text-[red]"> *</span>
|
||||||
<input
|
</label>
|
||||||
className="op-input op-input-bordered op-input-sm focus:outline-none hover:border-base-content w-full text-xs"
|
<input
|
||||||
name="name"
|
className="op-input op-input-bordered op-input-sm focus:outline-none hover:border-base-content w-full text-xs"
|
||||||
value={formdata.name}
|
name="name"
|
||||||
onChange={(e) => handleChange(e)}
|
value={formdata.name}
|
||||||
onInvalid={(e) => e.target.setCustomValidity(t("input-required"))}
|
onChange={(e) => handleChange(e)}
|
||||||
onInput={(e) => e.target.setCustomValidity("")}
|
onInvalid={(e) => e.target.setCustomValidity(t("input-required"))}
|
||||||
required
|
onInput={(e) => e.target.setCustomValidity("")}
|
||||||
/>
|
required
|
||||||
</div>
|
/>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
{props.defaultdata?.type === textInputWidget && (
|
{props.defaultdata?.type === textInputWidget && (
|
||||||
<>
|
<>
|
||||||
{isEnableSubscription && (
|
{isEnableSubscription && (
|
||||||
@@ -226,30 +268,63 @@ const WidgetNameModal = (props) => {
|
|||||||
</div>
|
</div>
|
||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
<div className="mb-[0.75rem]">
|
{!["signature", "initials"].includes(props.defaultdata?.type) && (
|
||||||
<div className="flex flex-row gap-[10px] mb-[0.5rem]">
|
<div className="mb-[0.75rem]">
|
||||||
{statusArr.map((data, ind) => {
|
<div className="flex flex-row gap-[10px] mb-[0.5rem]">
|
||||||
return (
|
{statusArr.map((data, ind) => {
|
||||||
<div key={ind} className="flex flex-row gap-[5px] items-center">
|
return (
|
||||||
<input
|
<div
|
||||||
className="mr-[2px] op-radio op-radio-xs"
|
key={ind}
|
||||||
type="radio"
|
className="flex flex-row gap-[5px] items-center"
|
||||||
name="status"
|
>
|
||||||
onChange={() =>
|
<input
|
||||||
setFormdata({ ...formdata, status: data.toLowerCase() })
|
className="mr-[2px] op-radio op-radio-xs"
|
||||||
}
|
type="radio"
|
||||||
checked={
|
name="status"
|
||||||
formdata.status.toLowerCase() === data.toLowerCase()
|
onChange={() =>
|
||||||
}
|
setFormdata({ ...formdata, status: data.toLowerCase() })
|
||||||
/>
|
}
|
||||||
<div className="text-[13px] font-medium">
|
checked={
|
||||||
{t(`widget-status.${data}`)}
|
formdata.status.toLowerCase() === data.toLowerCase()
|
||||||
|
}
|
||||||
|
/>
|
||||||
|
<div className="text-[13px] font-medium">
|
||||||
|
{t(`widget-status.${data}`)}
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
);
|
||||||
);
|
})}
|
||||||
})}
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
)}
|
||||||
|
{["signature", "initials"].includes(props.defaultdata?.type) && (
|
||||||
|
<div className="mb-[0.75rem]">
|
||||||
|
<label htmlFor="signaturetype" className="text-[14px] mb-[0.7rem]">
|
||||||
|
{t("allowed-signature-types")}
|
||||||
|
</label>
|
||||||
|
<div className=" ml-[7px] flex flex-col md:flex-row gap-[10px] mb-[0.7rem]">
|
||||||
|
{signatureType.map((type, i) => {
|
||||||
|
return (
|
||||||
|
<div key={i} className="flex flex-row gap-[5px] items-center">
|
||||||
|
<input
|
||||||
|
className="mr-[2px] op-checkbox op-checkbox-xs"
|
||||||
|
type="checkbox"
|
||||||
|
name="signaturetype"
|
||||||
|
onChange={() => handleCheckboxChange(i)}
|
||||||
|
checked={type.enabled}
|
||||||
|
/>
|
||||||
|
<div
|
||||||
|
className="text-[13px] font-medium hover:underline underline-offset-2 cursor-default capitalize"
|
||||||
|
title={`Enabling this allow signers to ${type.name} signature`}
|
||||||
|
>
|
||||||
|
{type.name}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
})}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
{props.defaultdata?.type === textInputWidget && (
|
{props.defaultdata?.type === textInputWidget && (
|
||||||
<div className="mb-[0.75rem]">
|
<div className="mb-[0.75rem]">
|
||||||
<label htmlFor="hint" className="text-[13px]">
|
<label htmlFor="hint" className="text-[13px]">
|
||||||
@@ -276,9 +351,9 @@ const WidgetNameModal = (props) => {
|
|||||||
<select
|
<select
|
||||||
className="ml-[7px] op-select op-select-bordered op-select-sm focus:outline-none hover:border-base-content text-xs"
|
className="ml-[7px] op-select op-select-bordered op-select-sm focus:outline-none hover:border-base-content text-xs"
|
||||||
value={
|
value={
|
||||||
props.fontSize || props.defaultdata?.options?.fontSize || "12"
|
props.fontSize || props.defaultdata?.options?.fontSize || 12
|
||||||
}
|
}
|
||||||
onChange={(e) => props.setFontSize(e.target.value)}
|
onChange={(e) => props.setFontSize(parseInt(e.target.value))}
|
||||||
>
|
>
|
||||||
{fontsizeArr.map((size, ind) => {
|
{fontsizeArr.map((size, ind) => {
|
||||||
return (
|
return (
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import React, { useState } from "react";
|
import React, { useState } from "react";
|
||||||
import Parse from "parse";
|
|
||||||
import AsyncSelect from "react-select/async";
|
import AsyncSelect from "react-select/async";
|
||||||
import { useTranslation } from "react-i18next";
|
import { useTranslation } from "react-i18next";
|
||||||
|
import axios from "axios";
|
||||||
|
|
||||||
const SelectSigners = (props) => {
|
const SelectSigners = (props) => {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
@@ -31,17 +31,19 @@ const SelectSigners = (props) => {
|
|||||||
|
|
||||||
const loadOptions = async (inputValue) => {
|
const loadOptions = async (inputValue) => {
|
||||||
try {
|
try {
|
||||||
const currentUser = Parse.User.current();
|
const baseURL = localStorage.getItem("baseUrl");
|
||||||
const contactbook = new Parse.Query("contracts_Contactbook");
|
const url = `${baseURL}functions/getsigners`;
|
||||||
contactbook.equalTo(
|
const token = props.jwttoken
|
||||||
"CreatedBy",
|
? { jwttoken: props.jwttoken }
|
||||||
Parse.User.createWithoutData(currentUser.id)
|
: { "X-Parse-Session-Token": localStorage.getItem("accesstoken") };
|
||||||
);
|
const headers = {
|
||||||
if (inputValue.length > 1) {
|
"Content-Type": "application/json",
|
||||||
contactbook.matches("Name", new RegExp(inputValue, "i"));
|
"X-Parse-Application-Id": localStorage.getItem("parseAppId"),
|
||||||
}
|
...token
|
||||||
contactbook.notEqualTo("IsDeleted", true);
|
};
|
||||||
const contactRes = await contactbook.find();
|
const searchEmail = inputValue ? inputValue : "";
|
||||||
|
const axiosRes = await axios.post(url, { searchEmail }, { headers });
|
||||||
|
const contactRes = axiosRes?.data?.result || [];
|
||||||
if (contactRes) {
|
if (contactRes) {
|
||||||
const res = JSON.parse(JSON.stringify(contactRes));
|
const res = JSON.parse(JSON.stringify(contactRes));
|
||||||
//compareArrays is a function where compare between two array (total signersList and dcument signers list)
|
//compareArrays is a function where compare between two array (total signersList and dcument signers list)
|
||||||
@@ -52,11 +54,9 @@ const SelectSigners = (props) => {
|
|||||||
!signerObj.find((item2) => item2.objectId === item1.objectId)
|
!signerObj.find((item2) => item2.objectId === item1.objectId)
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
//get update signer's List if signersdata is present
|
//get update signer's List if signersdata is present
|
||||||
const updateSignersList =
|
const updateSignersList =
|
||||||
props?.signersData && compareArrays(res, props?.signersData);
|
props?.signersData && compareArrays(res, props?.signersData);
|
||||||
|
|
||||||
const result = updateSignersList ? updateSignersList : res;
|
const result = updateSignersList ? updateSignersList : res;
|
||||||
setUserList(result);
|
setUserList(result);
|
||||||
return await result.map((item) => ({
|
return await result.map((item) => ({
|
||||||
@@ -68,7 +68,6 @@ const SelectSigners = (props) => {
|
|||||||
console.log("err", error);
|
console.log("err", error);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="h-full px-[20px] py-[10px] text-base-content">
|
<div className="h-full px-[20px] py-[10px] text-base-content">
|
||||||
<div className="w-full mx-auto p-[8px]">
|
<div className="w-full mx-auto p-[8px]">
|
||||||
@@ -85,6 +84,7 @@ const SelectSigners = (props) => {
|
|||||||
loadOptions={loadOptions}
|
loadOptions={loadOptions}
|
||||||
onChange={handleOptions}
|
onChange={handleOptions}
|
||||||
unstyled
|
unstyled
|
||||||
|
onFocus={() => loadOptions()}
|
||||||
classNames={{
|
classNames={{
|
||||||
control: () =>
|
control: () =>
|
||||||
"op-input op-input-bordered op-input-sm focus:outline-none hover:border-base-content w-full h-full text-[11px]",
|
"op-input op-input-bordered op-input-sm focus:outline-none hover:border-base-content w-full h-full text-[11px]",
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ const SuggestionInput = (props) => {
|
|||||||
if (timer) clearTimeout(timer);
|
if (timer) clearTimeout(timer);
|
||||||
timer = setTimeout(() => {
|
timer = setTimeout(() => {
|
||||||
(async () => {
|
(async () => {
|
||||||
const res = await findContact(inputValue);
|
const res = await findContact(inputValue, props.jwttoken);
|
||||||
if (res?.length > 0) {
|
if (res?.length > 0) {
|
||||||
setSuggestions(res);
|
setSuggestions(res);
|
||||||
setShowSuggestions(true);
|
setShowSuggestions(true);
|
||||||
@@ -37,6 +37,7 @@ const SuggestionInput = (props) => {
|
|||||||
}, 1000);
|
}, 1000);
|
||||||
}
|
}
|
||||||
return () => clearTimeout(timer);
|
return () => clearTimeout(timer);
|
||||||
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||||
}, [inputValue]);
|
}, [inputValue]);
|
||||||
|
|
||||||
const handleInputChange = async (e) => {
|
const handleInputChange = async (e) => {
|
||||||
|
|||||||
+138
-100
@@ -34,7 +34,8 @@ export async function fetchSubscription(
|
|||||||
extUserId,
|
extUserId,
|
||||||
contactObjId,
|
contactObjId,
|
||||||
isGuestSign = false,
|
isGuestSign = false,
|
||||||
isPublic = false
|
isPublic = false,
|
||||||
|
jwtToken
|
||||||
) {
|
) {
|
||||||
try {
|
try {
|
||||||
const Extand_Class = localStorage.getItem("Extand_Class");
|
const Extand_Class = localStorage.getItem("Extand_Class");
|
||||||
@@ -48,10 +49,13 @@ export async function fetchSubscription(
|
|||||||
}
|
}
|
||||||
const baseURL = localStorage.getItem("baseUrl");
|
const baseURL = localStorage.getItem("baseUrl");
|
||||||
const url = `${baseURL}functions/getsubscriptions`;
|
const url = `${baseURL}functions/getsubscriptions`;
|
||||||
|
const token = jwtToken
|
||||||
|
? { jwttoken: jwtToken }
|
||||||
|
: { sessionToken: localStorage.getItem("accesstoken") };
|
||||||
const headers = {
|
const headers = {
|
||||||
"Content-Type": "application/json",
|
"Content-Type": "application/json",
|
||||||
"X-Parse-Application-Id": localStorage.getItem("parseAppId"),
|
"X-Parse-Application-Id": localStorage.getItem("parseAppId"),
|
||||||
sessionToken: localStorage.getItem("accesstoken")
|
...token
|
||||||
};
|
};
|
||||||
const params = isGuestSign
|
const params = isGuestSign
|
||||||
? { contactId: contactObjId }
|
? { contactId: contactObjId }
|
||||||
@@ -122,9 +126,9 @@ export async function fetchSubscriptionInfo() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
//function to get subcripition details from subscription class
|
//function to get subcripition details from subscription class
|
||||||
export async function checkIsSubscribed() {
|
export async function checkIsSubscribed(jwttoken) {
|
||||||
try {
|
try {
|
||||||
const res = await fetchSubscription();
|
const res = await fetchSubscription("", "", false, false, jwttoken);
|
||||||
if (res.plan === "freeplan") {
|
if (res.plan === "freeplan") {
|
||||||
return { plan: res.plan, isValid: false, adminId: res?.adminId };
|
return { plan: res.plan, isValid: false, adminId: res?.adminId };
|
||||||
} else if (res.billingDate) {
|
} else if (res.billingDate) {
|
||||||
@@ -226,12 +230,25 @@ export const pdfNewWidthFun = (divRef) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
//`contractUsers` function is used to get contract_User details
|
//`contractUsers` function is used to get contract_User details
|
||||||
export const contractUsers = async () => {
|
export const contractUsers = async (jwttoken) => {
|
||||||
try {
|
try {
|
||||||
const userDetails = await Parse.Cloud.run("getUserDetails");
|
const url = `${localStorage.getItem("baseUrl")}functions/getUserDetails`;
|
||||||
|
const parseAppId = localStorage.getItem("parseAppId");
|
||||||
|
const accesstoken = localStorage.getItem("accesstoken");
|
||||||
|
const token = jwttoken
|
||||||
|
? { jwttoken: jwttoken }
|
||||||
|
: { "X-Parse-Session-Token": accesstoken };
|
||||||
|
const headers = {
|
||||||
|
headers: {
|
||||||
|
"Content-Type": "application/json",
|
||||||
|
"X-Parse-Application-Id": parseAppId,
|
||||||
|
...token
|
||||||
|
}
|
||||||
|
};
|
||||||
|
const userDetails = await axios.post(url, {}, headers);
|
||||||
let data = [];
|
let data = [];
|
||||||
if (userDetails) {
|
if (userDetails?.data?.result) {
|
||||||
const json = JSON.parse(JSON.stringify(userDetails));
|
const json = JSON.parse(JSON.stringify(userDetails.data.result));
|
||||||
data.push(json);
|
data.push(json);
|
||||||
}
|
}
|
||||||
return data;
|
return data;
|
||||||
@@ -446,29 +463,29 @@ export const defaultWidthHeight = (type) => {
|
|||||||
case "stamp":
|
case "stamp":
|
||||||
return { width: 150, height: 60 };
|
return { width: 150, height: 60 };
|
||||||
case "checkbox":
|
case "checkbox":
|
||||||
return { width: 15, height: 15 };
|
return { width: 15, height: 19 };
|
||||||
case textInputWidget:
|
case textInputWidget:
|
||||||
return { width: 150, height: 25 };
|
return { width: 150, height: 19 };
|
||||||
case "dropdown":
|
case "dropdown":
|
||||||
return { width: 120, height: 22 };
|
return { width: 120, height: 22 };
|
||||||
case "initials":
|
case "initials":
|
||||||
return { width: 50, height: 50 };
|
return { width: 50, height: 50 };
|
||||||
case "name":
|
case "name":
|
||||||
return { width: 150, height: 25 };
|
return { width: 150, height: 19 };
|
||||||
case "company":
|
case "company":
|
||||||
return { width: 150, height: 25 };
|
return { width: 150, height: 19 };
|
||||||
case "job title":
|
case "job title":
|
||||||
return { width: 150, height: 25 };
|
return { width: 150, height: 19 };
|
||||||
case "date":
|
case "date":
|
||||||
return { width: 100, height: 20 };
|
return { width: 100, height: 20 };
|
||||||
case "image":
|
case "image":
|
||||||
return { width: 70, height: 70 };
|
return { width: 70, height: 70 };
|
||||||
case "email":
|
case "email":
|
||||||
return { width: 150, height: 20 };
|
return { width: 150, height: 19 };
|
||||||
case radioButtonWidget:
|
case radioButtonWidget:
|
||||||
return { width: 5, height: 10 };
|
return { width: 5, height: 10 };
|
||||||
case textWidget:
|
case textWidget:
|
||||||
return { width: 150, height: 25 };
|
return { width: 150, height: 19 };
|
||||||
default:
|
default:
|
||||||
return { width: 150, height: 60 };
|
return { width: 150, height: 60 };
|
||||||
}
|
}
|
||||||
@@ -620,10 +637,10 @@ export const signPdfFun = async (
|
|||||||
return { status: "error", message: "something went wrong." };
|
return { status: "error", message: "something went wrong." };
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//change image width and height to 100/40 in png base64
|
//change image width and height to 300/120 in png base64
|
||||||
const getNewse64 = await changeImageWH(base64Sign);
|
const imagebase64 = await changeImageWH(base64Sign);
|
||||||
//remove suffiix of base64
|
//remove suffiix of base64 (without type)
|
||||||
const suffixbase64 = getNewse64 && getNewse64.split(",").pop();
|
const suffixbase64 = imagebase64 && imagebase64.split(",").pop();
|
||||||
|
|
||||||
const params = {
|
const params = {
|
||||||
mailProvider: activeMailAdapter,
|
mailProvider: activeMailAdapter,
|
||||||
@@ -645,9 +662,7 @@ export const signPdfFun = async (
|
|||||||
status: "error",
|
status: "error",
|
||||||
message: "Currently encrypted pdf files are not supported."
|
message: "Currently encrypted pdf files are not supported."
|
||||||
};
|
};
|
||||||
} else if (
|
} else if (e?.message?.includes("password")) {
|
||||||
e.message === "PKCS#12 MAC could not be verified. Invalid password?"
|
|
||||||
) {
|
|
||||||
return { status: "error", message: "PFX file password is invalid." };
|
return { status: "error", message: "PFX file password is invalid." };
|
||||||
} else {
|
} else {
|
||||||
return { status: "error", message: "something went wrong." };
|
return { status: "error", message: "something went wrong." };
|
||||||
@@ -670,7 +685,6 @@ export const createDocument = async (
|
|||||||
) => {
|
) => {
|
||||||
if (template && template.length > 0) {
|
if (template && template.length > 0) {
|
||||||
const Doc = template[0];
|
const Doc = template[0];
|
||||||
|
|
||||||
let placeholdersArr = [];
|
let placeholdersArr = [];
|
||||||
if (placeholders?.length > 0) {
|
if (placeholders?.length > 0) {
|
||||||
placeholdersArr = placeholders;
|
placeholdersArr = placeholders;
|
||||||
@@ -688,6 +702,9 @@ export const createDocument = async (
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
const SignatureType = Doc?.SignatureType
|
||||||
|
? { SignatureType: Doc?.SignatureType }
|
||||||
|
: {};
|
||||||
const data = {
|
const data = {
|
||||||
Name: Doc.Name,
|
Name: Doc.Name,
|
||||||
URL: pdfUrl,
|
URL: pdfUrl,
|
||||||
@@ -712,7 +729,8 @@ export const createDocument = async (
|
|||||||
RemindOnceInEvery: parseInt(Doc?.RemindOnceInEvery || 5),
|
RemindOnceInEvery: parseInt(Doc?.RemindOnceInEvery || 5),
|
||||||
IsEnableOTP: Doc?.IsEnableOTP || false,
|
IsEnableOTP: Doc?.IsEnableOTP || false,
|
||||||
IsTourEnabled: Doc?.IsTourEnabled || false,
|
IsTourEnabled: Doc?.IsTourEnabled || false,
|
||||||
FileAdapterId: Doc?.FileAdapterId || ""
|
FileAdapterId: Doc?.FileAdapterId || "",
|
||||||
|
...SignatureType
|
||||||
};
|
};
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@@ -998,7 +1016,7 @@ export const calculateInitialWidthHeight = (widgetData) => {
|
|||||||
const intialText = widgetData;
|
const intialText = widgetData;
|
||||||
const span = document.createElement("span");
|
const span = document.createElement("span");
|
||||||
span.textContent = intialText;
|
span.textContent = intialText;
|
||||||
span.style.font = `14px`; // here put your text size and font family
|
span.style.font = `12px`; // here put your text size and font family
|
||||||
span.style.display = "hidden";
|
span.style.display = "hidden";
|
||||||
document.body.appendChild(span);
|
document.body.appendChild(span);
|
||||||
const width = span.offsetWidth;
|
const width = span.offsetWidth;
|
||||||
@@ -1151,10 +1169,7 @@ export function onSaveSign(
|
|||||||
Height: posHeight,
|
Height: posHeight,
|
||||||
SignUrl: signatureImg,
|
SignUrl: signatureImg,
|
||||||
signatureType: type && type,
|
signatureType: type && type,
|
||||||
options: {
|
options: { ...position.options, response: signatureImg }
|
||||||
...position.options,
|
|
||||||
response: signatureImg
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
return position;
|
return position;
|
||||||
@@ -1288,16 +1303,6 @@ export const changeImageWH = async (base64Image) => {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
//function to calculate font size of text area widgets
|
|
||||||
const calculateFontSize = (position, containerScale, signyourself) => {
|
|
||||||
const font = position?.options?.fontSize || 12;
|
|
||||||
if (!signyourself && position?.isMobile && position?.scale) {
|
|
||||||
return font / position?.scale / containerScale;
|
|
||||||
} else {
|
|
||||||
return font / containerScale;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
const getWidgetsFontColor = (type) => {
|
const getWidgetsFontColor = (type) => {
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case "red":
|
case "red":
|
||||||
@@ -1313,14 +1318,7 @@ const getWidgetsFontColor = (type) => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
//function for embed multiple signature using pdf-lib
|
//function for embed multiple signature using pdf-lib
|
||||||
export const multiSignEmbed = async (
|
export const multiSignEmbed = async (widgets, pdfDoc, signyourself, scale) => {
|
||||||
widgets,
|
|
||||||
pdfDoc,
|
|
||||||
signyourself,
|
|
||||||
scale,
|
|
||||||
pdfOriginalWH,
|
|
||||||
containerWH
|
|
||||||
) => {
|
|
||||||
// `fontBytes` is used to embed custom font in pdf
|
// `fontBytes` is used to embed custom font in pdf
|
||||||
const fontBytes = await fileasbytes(
|
const fontBytes = await fileasbytes(
|
||||||
"https://cdn.opensignlabs.com/webfonts/times.ttf"
|
"https://cdn.opensignlabs.com/webfonts/times.ttf"
|
||||||
@@ -1330,11 +1328,6 @@ export const multiSignEmbed = async (
|
|||||||
let hasError = false;
|
let hasError = false;
|
||||||
for (let item of widgets) {
|
for (let item of widgets) {
|
||||||
if (hasError) break; // Stop the outer loop if an error occurred
|
if (hasError) break; // Stop the outer loop if an error occurred
|
||||||
const containerScale = getContainerScale(
|
|
||||||
pdfOriginalWH,
|
|
||||||
item?.pageNumber,
|
|
||||||
containerWH
|
|
||||||
);
|
|
||||||
const typeExist = item.pos.some((data) => data?.type);
|
const typeExist = item.pos.some((data) => data?.type);
|
||||||
let updateItem;
|
let updateItem;
|
||||||
|
|
||||||
@@ -1364,11 +1357,16 @@ export const multiSignEmbed = async (
|
|||||||
const form = pdfDoc.getForm();
|
const form = pdfDoc.getForm();
|
||||||
const page = pages[pageNo - 1];
|
const page = pages[pageNo - 1];
|
||||||
const images = await Promise.all(
|
const images = await Promise.all(
|
||||||
widgetsPositionArr.map(async (url) => {
|
widgetsPositionArr.map(async (widget) => {
|
||||||
let signUrl = url.SignUrl && url.SignUrl;
|
// `SignUrl` this is wrong nomenclature and maintain for older code in this options we save base64 of signature image from sign pad
|
||||||
if (signUrl) {
|
let signbase64 = widget.SignUrl && widget.SignUrl;
|
||||||
const res = await fetch(signUrl);
|
if (signbase64) {
|
||||||
return res.arrayBuffer();
|
let arr = signbase64.split(","),
|
||||||
|
mime = arr[0].match(/:(.*?);/)[1];
|
||||||
|
const res = await fetch(signbase64);
|
||||||
|
const arrayBuffer = await res.arrayBuffer();
|
||||||
|
const obj = { mimetype: mime, arrayBuffer: arrayBuffer };
|
||||||
|
return obj;
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
@@ -1379,17 +1377,17 @@ export const multiSignEmbed = async (
|
|||||||
if (
|
if (
|
||||||
["signature", "stamp", "initials", "image"].includes(position.type)
|
["signature", "stamp", "initials", "image"].includes(position.type)
|
||||||
) {
|
) {
|
||||||
if (position.ImageType && position.ImageType === "image/jpeg") {
|
if (images[id].mimetype === "image/png") {
|
||||||
img = await pdfDoc.embedJpg(images[id]);
|
img = await pdfDoc.embedPng(images[id].arrayBuffer);
|
||||||
} else {
|
} else {
|
||||||
img = await pdfDoc.embedPng(images[id]);
|
img = await pdfDoc.embedJpg(images[id].arrayBuffer);
|
||||||
}
|
}
|
||||||
} else if (!position.type) {
|
} else if (!position.type) {
|
||||||
// to handle old widget when only stamp and signature are exists
|
// to handle old widget when only stamp and signature are exists
|
||||||
if (position.ImageType && position.ImageType === "image/jpeg") {
|
if (images[id].mimetype === "image/png") {
|
||||||
img = await pdfDoc.embedJpg(images[id]);
|
img = await pdfDoc.embedPng(images[id].arrayBuffer);
|
||||||
} else {
|
} else {
|
||||||
img = await pdfDoc.embedPng(images[id]);
|
img = await pdfDoc.embedJpg(images[id].arrayBuffer);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
let widgetWidth, widgetHeight;
|
let widgetWidth, widgetHeight;
|
||||||
@@ -1421,7 +1419,17 @@ export const multiSignEmbed = async (
|
|||||||
return y;
|
return y;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
return resizePos;
|
const WidgetsTypeTextExist = [
|
||||||
|
textWidget,
|
||||||
|
textInputWidget,
|
||||||
|
"name",
|
||||||
|
"company",
|
||||||
|
"job title",
|
||||||
|
"date",
|
||||||
|
"email"
|
||||||
|
].includes(position.type);
|
||||||
|
const yPosition = WidgetsTypeTextExist ? resizePos + 6 : resizePos;
|
||||||
|
return yPosition;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
const color = position?.options?.fontColor;
|
const color = position?.options?.fontColor;
|
||||||
@@ -1497,11 +1505,7 @@ export const multiSignEmbed = async (
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
} else if (widgetTypeExist) {
|
} else if (widgetTypeExist) {
|
||||||
const fontSize = calculateFontSize(
|
const fontSize = position?.options?.fontSize || 12;
|
||||||
position,
|
|
||||||
containerScale,
|
|
||||||
signyourself
|
|
||||||
);
|
|
||||||
parseInt(fontSize);
|
parseInt(fontSize);
|
||||||
let textContent;
|
let textContent;
|
||||||
if (position?.options?.response) {
|
if (position?.options?.response) {
|
||||||
@@ -1534,7 +1538,6 @@ export const multiSignEmbed = async (
|
|||||||
lines.push(currentLine.trim());
|
lines.push(currentLine.trim());
|
||||||
return lines;
|
return lines;
|
||||||
};
|
};
|
||||||
|
|
||||||
// Function to break text into lines based on when user go next line on press enter button
|
// Function to break text into lines based on when user go next line on press enter button
|
||||||
const breakTextIntoLines = (textContent, width) => {
|
const breakTextIntoLines = (textContent, width) => {
|
||||||
const lines = [];
|
const lines = [];
|
||||||
@@ -1555,7 +1558,6 @@ export const multiSignEmbed = async (
|
|||||||
|
|
||||||
return lines;
|
return lines;
|
||||||
};
|
};
|
||||||
|
|
||||||
//check if text content have `\n` string it means user press enter to go next line and handle condition
|
//check if text content have `\n` string it means user press enter to go next line and handle condition
|
||||||
//else auto adjust text content according to container width
|
//else auto adjust text content according to container width
|
||||||
const lines = isNewOnEnterLineExist
|
const lines = isNewOnEnterLineExist
|
||||||
@@ -1582,7 +1584,6 @@ export const multiSignEmbed = async (
|
|||||||
}
|
}
|
||||||
} else if (position.type === "dropdown") {
|
} else if (position.type === "dropdown") {
|
||||||
const fontsize = parseInt(position?.options?.fontSize) || 12;
|
const fontsize = parseInt(position?.options?.fontSize) || 12;
|
||||||
|
|
||||||
const dropdownRandomId = "dropdown" + randomId();
|
const dropdownRandomId = "dropdown" + randomId();
|
||||||
const dropdown = form.createDropdown(dropdownRandomId);
|
const dropdown = form.createDropdown(dropdownRandomId);
|
||||||
dropdown.addOptions(position?.options?.values);
|
dropdown.addOptions(position?.options?.values);
|
||||||
@@ -1681,7 +1682,6 @@ export const multiSignEmbed = async (
|
|||||||
}
|
}
|
||||||
if (!hasError) {
|
if (!hasError) {
|
||||||
const pdfBytes = await pdfDoc.saveAsBase64({ useObjectStreams: false });
|
const pdfBytes = await pdfDoc.saveAsBase64({ useObjectStreams: false });
|
||||||
// console.log("pdf", pdfBytes);
|
|
||||||
return pdfBytes;
|
return pdfBytes;
|
||||||
} else {
|
} else {
|
||||||
return {
|
return {
|
||||||
@@ -1764,14 +1764,17 @@ export const contactBook = async (objectId) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
//function for getting document details from contract_Documents class
|
//function for getting document details from contract_Documents class
|
||||||
export const contractDocument = async (documentId) => {
|
export const contractDocument = async (documentId, JwtToken) => {
|
||||||
const data = { docId: documentId };
|
const data = { docId: documentId };
|
||||||
|
const token = JwtToken
|
||||||
|
? { jwtToken: JwtToken }
|
||||||
|
: { sessionToken: localStorage.getItem("accesstoken") };
|
||||||
const documentDeatils = await axios
|
const documentDeatils = await axios
|
||||||
.post(`${localStorage.getItem("baseUrl")}functions/getDocument`, data, {
|
.post(`${localStorage.getItem("baseUrl")}functions/getDocument`, data, {
|
||||||
headers: {
|
headers: {
|
||||||
"Content-Type": "application/json",
|
"Content-Type": "application/json",
|
||||||
"X-Parse-Application-Id": localStorage.getItem("parseAppId"),
|
"X-Parse-Application-Id": localStorage.getItem("parseAppId"),
|
||||||
sessionToken: localStorage.getItem("accesstoken")
|
...token
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.then((Listdata) => {
|
.then((Listdata) => {
|
||||||
@@ -1887,12 +1890,16 @@ export const handleCopyNextToWidget = (
|
|||||||
//get position of previous widget and create new widget next to that widget on same data except
|
//get position of previous widget and create new widget next to that widget on same data except
|
||||||
// xPosition and key
|
// xPosition and key
|
||||||
let newposition = position;
|
let newposition = position;
|
||||||
const calculateXPosition =
|
const calculateXPosition = parseInt(position.xPosition) + 10;
|
||||||
parseInt(position.xPosition) +
|
const calculateYPosition = parseInt(position.yPosition) + 10;
|
||||||
defaultWidthHeight(widgetType).width +
|
|
||||||
resizeBorderExtraWidth();
|
|
||||||
const newId = randomId();
|
const newId = randomId();
|
||||||
newposition = { ...newposition, xPosition: calculateXPosition, key: newId };
|
newposition = {
|
||||||
|
...newposition,
|
||||||
|
xPosition: calculateXPosition,
|
||||||
|
yPosition: calculateYPosition,
|
||||||
|
key: newId
|
||||||
|
};
|
||||||
//if condition to create widget in request-sign flow
|
//if condition to create widget in request-sign flow
|
||||||
if (userId) {
|
if (userId) {
|
||||||
filterSignerPos = xyPostion.filter((data) => data.Id === userId);
|
filterSignerPos = xyPostion.filter((data) => data.Id === userId);
|
||||||
@@ -1967,20 +1974,28 @@ export const getAppLogo = async () => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
export const getTenantDetails = async (objectId) => {
|
export const getTenantDetails = async (objectId, jwttoken, contactId) => {
|
||||||
try {
|
try {
|
||||||
const tenantCreditsQuery = new Parse.Query("partners_Tenant");
|
const url = `${localStorage.getItem("baseUrl")}functions/gettenant`;
|
||||||
tenantCreditsQuery.equalTo("UserId", {
|
const parseAppId = localStorage.getItem("parseAppId");
|
||||||
__type: "Pointer",
|
const accesstoken = localStorage.getItem("accesstoken");
|
||||||
className: "_User",
|
const token = jwttoken
|
||||||
objectId: objectId
|
? { jwttoken: jwttoken }
|
||||||
|
: { "X-Parse-Session-Token": accesstoken };
|
||||||
|
const data = jwttoken ? {} : { userId: objectId, contactId: contactId };
|
||||||
|
const res = await axios.post(url, data, {
|
||||||
|
headers: {
|
||||||
|
"Content-Type": "application/json",
|
||||||
|
"X-Parse-Application-Id": parseAppId,
|
||||||
|
...token
|
||||||
|
}
|
||||||
});
|
});
|
||||||
const res = await tenantCreditsQuery.first();
|
|
||||||
if (res) {
|
if (res) {
|
||||||
const updateRes = JSON.parse(JSON.stringify(res));
|
const updateRes = JSON.parse(JSON.stringify(res.data.result));
|
||||||
return updateRes;
|
return updateRes;
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (err) {
|
||||||
|
console.log("err in gettenant", err);
|
||||||
return "user does not exist!";
|
return "user does not exist!";
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -2229,18 +2244,21 @@ export const handleDownloadCertificate = async (
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
export async function findContact(value) {
|
export async function findContact(value, jwttoken) {
|
||||||
try {
|
try {
|
||||||
const currentUser = Parse.User.current();
|
const baseURL = localStorage.getItem("baseUrl");
|
||||||
const contactbook = new Parse.Query("contracts_Contactbook");
|
const url = `${baseURL}functions/getsigners`;
|
||||||
contactbook.equalTo(
|
const token = jwttoken
|
||||||
"CreatedBy",
|
? { jwttoken: jwttoken }
|
||||||
Parse.User.createWithoutData(currentUser.id)
|
: { "X-Parse-Session-Token": localStorage.getItem("accesstoken") };
|
||||||
);
|
const headers = {
|
||||||
contactbook.notEqualTo("IsDeleted", true);
|
"Content-Type": "application/json",
|
||||||
contactbook.matches("Email", new RegExp(value, "i"));
|
"X-Parse-Application-Id": localStorage.getItem("parseAppId"),
|
||||||
|
...token
|
||||||
const contactRes = await contactbook.find();
|
};
|
||||||
|
const searchEmail = value;
|
||||||
|
const axiosRes = await axios.post(url, { searchEmail }, { headers });
|
||||||
|
const contactRes = axiosRes?.data?.result || [];
|
||||||
if (contactRes) {
|
if (contactRes) {
|
||||||
const res = JSON.parse(JSON.stringify(contactRes));
|
const res = JSON.parse(JSON.stringify(contactRes));
|
||||||
return res;
|
return res;
|
||||||
@@ -2559,3 +2577,23 @@ export function generateTitleFromFilename(filename) {
|
|||||||
return "Untitled Document";
|
return "Untitled Document";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export const signatureTypes = [
|
||||||
|
{ name: "draw", enabled: true },
|
||||||
|
{ name: "typed", enabled: true },
|
||||||
|
{ name: "upload", enabled: true },
|
||||||
|
{ name: "default", enabled: true }
|
||||||
|
];
|
||||||
|
|
||||||
|
// `handleSignatureType` is used to return update signature types as per tenant or user
|
||||||
|
export async function handleSignatureType(tenantSignTypes, signatureType) {
|
||||||
|
const docSignTypes = signatureType || signatureTypes;
|
||||||
|
let updatedSignatureType = signatureType || signatureTypes;
|
||||||
|
if (tenantSignTypes?.length > 0) {
|
||||||
|
updatedSignatureType = tenantSignTypes?.map((item) => {
|
||||||
|
const match = docSignTypes.find((data) => data.name === item.name);
|
||||||
|
return match ? { ...item, enabled: match.enabled } : item;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
return updatedSignatureType;
|
||||||
|
}
|
||||||
|
|||||||
@@ -27,21 +27,21 @@ export default function reportJson(id) {
|
|||||||
const templateSubAction = isEnableSubscription
|
const templateSubAction = isEnableSubscription
|
||||||
? [
|
? [
|
||||||
{
|
{
|
||||||
btnId: "2434",
|
btnId: "2435",
|
||||||
btnLabel: "Embed",
|
btnLabel: "Embed",
|
||||||
hoverLabel: "Embed",
|
hoverLabel: "Embed",
|
||||||
btnIcon: "fa-light fa-code",
|
btnIcon: "fa-light fa-code",
|
||||||
action: "Embed"
|
action: "Embed"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
btnId: "2434",
|
btnId: "2436",
|
||||||
btnLabel: "Copy TemplateId",
|
btnLabel: "Copy TemplateId",
|
||||||
hoverLabel: "Copy TemplateId",
|
hoverLabel: "Copy TemplateId",
|
||||||
btnIcon: "fa-light fa-copy",
|
btnIcon: "fa-light fa-copy",
|
||||||
action: "CopyTemplateId"
|
action: "CopyTemplateId"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
btnId: "2434",
|
btnId: "2437",
|
||||||
btnLabel: "Copy Public URL",
|
btnLabel: "Copy Public URL",
|
||||||
hoverLabel: "Copy Public URL",
|
hoverLabel: "Copy Public URL",
|
||||||
btnIcon: "fa-light fa-copy",
|
btnIcon: "fa-light fa-copy",
|
||||||
|
|||||||
@@ -154,6 +154,14 @@ const sidebarList = [
|
|||||||
pageType: "",
|
pageType: "",
|
||||||
description: "",
|
description: "",
|
||||||
objectId: "webhook"
|
objectId: "webhook"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
icon: "fa-light fa-sliders",
|
||||||
|
title: "Preferences",
|
||||||
|
target: "_self",
|
||||||
|
pageType: "",
|
||||||
|
description: "",
|
||||||
|
objectId: "preferences"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,17 +16,18 @@ const plans = [
|
|||||||
"Unlimited digital signatures",
|
"Unlimited digital signatures",
|
||||||
"Sign documents yourself",
|
"Sign documents yourself",
|
||||||
"Request signatures from others",
|
"Request signatures from others",
|
||||||
|
"Unlimited templates",
|
||||||
"14 field types",
|
"14 field types",
|
||||||
"Automatic e-signatures",
|
"Automatic e-signatures",
|
||||||
"Completion certificates",
|
"Completion certificates",
|
||||||
"Send in order",
|
"Send in order",
|
||||||
|
"Organize docs in OpenSign™ Drive",
|
||||||
"Document templates",
|
"Document templates",
|
||||||
"Import from Dropbox",
|
"Import from Dropbox",
|
||||||
"Contact book",
|
"Contact book",
|
||||||
"Document expiry support",
|
"Document expiry support",
|
||||||
"Decline document support",
|
"Decline document support",
|
||||||
"Email notifications",
|
"Email notifications",
|
||||||
"Recipient authentication using OTP",
|
|
||||||
"Public profiles",
|
"Public profiles",
|
||||||
"And much more"
|
"And much more"
|
||||||
],
|
],
|
||||||
@@ -34,17 +35,18 @@ const plans = [
|
|||||||
"Unlimited digital signatures",
|
"Unlimited digital signatures",
|
||||||
"Sign documents yourself",
|
"Sign documents yourself",
|
||||||
"Request signatures from others",
|
"Request signatures from others",
|
||||||
|
"Unlimited templates",
|
||||||
"14 field types",
|
"14 field types",
|
||||||
"Automatic e-signatures",
|
"Automatic e-signatures",
|
||||||
"Completion certificates",
|
"Completion certificates",
|
||||||
"Send in order",
|
"Send in order",
|
||||||
|
"Organize docs in OpenSign™ Drive",
|
||||||
"Document templates",
|
"Document templates",
|
||||||
"Import from Dropbox",
|
"Import from Dropbox",
|
||||||
"Contact book",
|
"Contact book",
|
||||||
"Document expiry support",
|
"Document expiry support",
|
||||||
"Decline document support",
|
"Decline document support",
|
||||||
"Email notifications",
|
"Email notifications",
|
||||||
"Recipient authentication using OTP",
|
|
||||||
"Public profiles",
|
"Public profiles",
|
||||||
"And much more"
|
"And much more"
|
||||||
]
|
]
|
||||||
@@ -61,10 +63,10 @@ const plans = [
|
|||||||
subtitle: "Exclusive Access to advanced features.",
|
subtitle: "Exclusive Access to advanced features.",
|
||||||
btn: { text: "Subscribe", color: "op-btn-primary" },
|
btn: { text: "Subscribe", color: "op-btn-primary" },
|
||||||
url: isStaging
|
url: isStaging
|
||||||
? "https://billing.zoho.in/subscribe/9627f62a09df1c8ce500f2f4dc8328dd84ecda20eeae13878ce581d60240f206/pro-weekly"
|
? "https://billing.zohosecure.in/subscribe/9627f62a09df1c8ce500f2f4dc8328dd84ecda20eeae13878ce581d60240f206/pro-weekly"
|
||||||
: "https://billing.opensignlabs.com/subscribe/ef798486e6a0a11ea65f2bae8f2af901d1a09dfa8085585cdd4ec4d7f32137f3/professional-monthly",
|
: "https://billing.opensignlabs.com/subscribe/ef798486e6a0a11ea65f2bae8f2af901d1a09dfa8085585cdd4ec4d7f32137f3/professional-monthly",
|
||||||
yearlyUrl: isStaging
|
yearlyUrl: isStaging
|
||||||
? "https://billing.zoho.in/subscribe/9627f62a09df1c8ce500f2f4dc8328ddc184411129224f1f29ed84f6cef3b862/pro-yearly"
|
? "https://billing.zohosecure.in/subscribe/9627f62a09df1c8ce500f2f4dc8328ddc184411129224f1f29ed84f6cef3b862/pro-yearly"
|
||||||
: "https://billing.opensignlabs.com/subscribe/ef798486e6a0a11ea65f2bae8f2af901d8ad1135190dff951330360e47585a71/professional-yearly",
|
: "https://billing.opensignlabs.com/subscribe/ef798486e6a0a11ea65f2bae8f2af901d8ad1135190dff951330360e47585a71/professional-yearly",
|
||||||
target: "_self",
|
target: "_self",
|
||||||
benefits: [
|
benefits: [
|
||||||
@@ -77,10 +79,12 @@ const plans = [
|
|||||||
"API Access",
|
"API Access",
|
||||||
"upto 100 API signatures",
|
"upto 100 API signatures",
|
||||||
"Custom email templates",
|
"Custom email templates",
|
||||||
|
"Connect your own Gmail or SMTP account for sending emails",
|
||||||
"Auto reminders",
|
"Auto reminders",
|
||||||
"Bulk send (upto 100 docs)",
|
"Bulk send (upto 100 docs)",
|
||||||
"Premium Public profile usernames",
|
"Premium Public profile usernames",
|
||||||
"Embedding (coming soon)"
|
"Enforce email-based verification to confirm signer identity",
|
||||||
|
"Embedded signing"
|
||||||
],
|
],
|
||||||
yearlyBenefits: [
|
yearlyBenefits: [
|
||||||
"Everything in OpenSign™ free",
|
"Everything in OpenSign™ free",
|
||||||
@@ -92,10 +96,12 @@ const plans = [
|
|||||||
"API Access",
|
"API Access",
|
||||||
"upto 240 API signatures",
|
"upto 240 API signatures",
|
||||||
"Custom email templates",
|
"Custom email templates",
|
||||||
|
"Connect your own Gmail or SMTP account for sending emails",
|
||||||
"Auto reminders",
|
"Auto reminders",
|
||||||
"Bulk send (upto 240 docs)",
|
"Bulk send (upto 240 docs)",
|
||||||
"Premium Public profile usernames",
|
"Premium Public profile usernames",
|
||||||
"Embedding (coming soon)"
|
"Enforce email-based verification to confirm signer identity",
|
||||||
|
"Embedded signing"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -108,10 +114,10 @@ const plans = [
|
|||||||
subtitle: "Exclusive Access to advanced features.",
|
subtitle: "Exclusive Access to advanced features.",
|
||||||
btn: { text: "Subscribe", color: "op-btn-accent" },
|
btn: { text: "Subscribe", color: "op-btn-accent" },
|
||||||
url: isStaging
|
url: isStaging
|
||||||
? "https://billing.zoho.in/subscribe/ed8097273a82b6bf39892c11a3bb3c381eb2705736014cfbdbde1ccf1c7a189d/teams-monthly"
|
? "https://billing.zohosecure.in/subscribe/ed8097273a82b6bf39892c11a3bb3c381eb2705736014cfbdbde1ccf1c7a189d/teams-monthly"
|
||||||
: "https://billing.opensignlabs.com/subscribe/ef798486e6a0a11ea65f2bae8f2af901237d0702bfaa959406306635d80f138c/teams-monthly",
|
: "https://billing.opensignlabs.com/subscribe/ef798486e6a0a11ea65f2bae8f2af901237d0702bfaa959406306635d80f138c/teams-monthly",
|
||||||
yearlyUrl: isStaging
|
yearlyUrl: isStaging
|
||||||
? "https://billing.zoho.in/subscribe/ed8097273a82b6bf39892c11a3bb3c381eb2705736014cfbdbde1ccf1c7a189d/teams-yearly"
|
? "https://billing.zohosecure.in/subscribe/ed8097273a82b6bf39892c11a3bb3c381eb2705736014cfbdbde1ccf1c7a189d/teams-yearly"
|
||||||
: "https://billing.opensignlabs.com/subscribe/ef798486e6a0a11ea65f2bae8f2af9011a864994bbeeec71fcf106188630199d/teams-yearly",
|
: "https://billing.opensignlabs.com/subscribe/ef798486e6a0a11ea65f2bae8f2af9011a864994bbeeec71fcf106188630199d/teams-yearly",
|
||||||
target: "_self",
|
target: "_self",
|
||||||
benefits: [
|
benefits: [
|
||||||
@@ -120,6 +126,7 @@ const plans = [
|
|||||||
"Teams and Organizations",
|
"Teams and Organizations",
|
||||||
"Share Templates with teams",
|
"Share Templates with teams",
|
||||||
"Share Templates with individuals",
|
"Share Templates with individuals",
|
||||||
|
"BYOC - Store your documents in your own cloud storage",
|
||||||
"DocumentId removal from signed docs",
|
"DocumentId removal from signed docs",
|
||||||
"Bulk send (upto 100 docs)",
|
"Bulk send (upto 100 docs)",
|
||||||
"Request Payments (coming soon)",
|
"Request Payments (coming soon)",
|
||||||
@@ -131,6 +138,7 @@ const plans = [
|
|||||||
"Teams and Organizations",
|
"Teams and Organizations",
|
||||||
"Share Templates with teams",
|
"Share Templates with teams",
|
||||||
"Share Templates with individuals",
|
"Share Templates with individuals",
|
||||||
|
"BYOC - Store your documents in your own cloud storage",
|
||||||
"DocumentId removal from signed docs",
|
"DocumentId removal from signed docs",
|
||||||
"Bulk send (upto 500 docs)",
|
"Bulk send (upto 500 docs)",
|
||||||
"Request Payments (coming soon)",
|
"Request Payments (coming soon)",
|
||||||
@@ -231,10 +239,10 @@ export const paidUrl = (plan) => {
|
|||||||
}
|
}
|
||||||
const url = {
|
const url = {
|
||||||
monthly: isStaging
|
monthly: isStaging
|
||||||
? "https://billing.zoho.in/subscribe/ed8097273a82b6bf39892c11a3bb3c381eb2705736014cfbdbde1ccf1c7a189d/teams-monthly"
|
? "https://billing.zohosecure.in/subscribe/ed8097273a82b6bf39892c11a3bb3c381eb2705736014cfbdbde1ccf1c7a189d/teams-monthly"
|
||||||
: "https://billing.opensignlabs.com/subscribe/ef798486e6a0a11ea65f2bae8f2af901237d0702bfaa959406306635d80f138c/teams-monthly",
|
: "https://billing.opensignlabs.com/subscribe/ef798486e6a0a11ea65f2bae8f2af901237d0702bfaa959406306635d80f138c/teams-monthly",
|
||||||
yearly: isStaging
|
yearly: isStaging
|
||||||
? "https://billing.zoho.in/subscribe/ed8097273a82b6bf39892c11a3bb3c381eb2705736014cfbdbde1ccf1c7a189d/teams-yearly"
|
? "https://billing.zohosecure.in/subscribe/ed8097273a82b6bf39892c11a3bb3c381eb2705736014cfbdbde1ccf1c7a189d/teams-yearly"
|
||||||
: "https://billing.opensignlabs.com/subscribe/ef798486e6a0a11ea65f2bae8f2af9011a864994bbeeec71fcf106188630199d/teams-yearly"
|
: "https://billing.opensignlabs.com/subscribe/ef798486e6a0a11ea65f2bae8f2af9011a864994bbeeec71fcf106188630199d/teams-yearly"
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -255,7 +255,9 @@ const HomeLayout = () => {
|
|||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
<div className="sticky top-0 z-[501]">
|
<div className="sticky top-0 z-[501]">
|
||||||
{!isLoader && <Header showSidebar={showSidebar} />}
|
{!isLoader && (
|
||||||
|
<Header showSidebar={showSidebar} setIsMenu={setIsOpen} />
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
{isUserValid ? (
|
{isUserValid ? (
|
||||||
<>
|
<>
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ import { showTenant } from "../redux/reducers/ShowTenant";
|
|||||||
import Loader from "../primitives/Loader";
|
import Loader from "../primitives/Loader";
|
||||||
import Title from "../components/Title";
|
import Title from "../components/Title";
|
||||||
import { useTranslation } from "react-i18next";
|
import { useTranslation } from "react-i18next";
|
||||||
|
import { emailRegex } from "../constant/const";
|
||||||
|
|
||||||
const AddAdmin = () => {
|
const AddAdmin = () => {
|
||||||
const { t, i18n } = useTranslation();
|
const { t, i18n } = useTranslation();
|
||||||
@@ -84,77 +85,81 @@ const AddAdmin = () => {
|
|||||||
|
|
||||||
const handleSubmit = async (event) => {
|
const handleSubmit = async (event) => {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
if (lengthValid && caseDigitValid && specialCharValid) {
|
if (!emailRegex.test(email)) {
|
||||||
clearStorage();
|
alert("Please enter a valid email address.");
|
||||||
setState({ loading: true });
|
} else {
|
||||||
const userDetails = {
|
if (lengthValid && caseDigitValid && specialCharValid) {
|
||||||
name: name,
|
clearStorage();
|
||||||
email: email,
|
setState({ loading: true });
|
||||||
phone: phone,
|
const userDetails = {
|
||||||
company: company,
|
name: name,
|
||||||
jobTitle: jobTitle
|
email: email,
|
||||||
};
|
phone: phone,
|
||||||
localStorage.setItem("userDetails", JSON.stringify(userDetails));
|
company: company,
|
||||||
try {
|
jobTitle: jobTitle
|
||||||
event.preventDefault();
|
};
|
||||||
const user = new Parse.User();
|
localStorage.setItem("userDetails", JSON.stringify(userDetails));
|
||||||
user.set("name", name);
|
try {
|
||||||
user.set("email", email);
|
event.preventDefault();
|
||||||
user.set("password", password);
|
const user = new Parse.User();
|
||||||
user.set("phone", phone);
|
user.set("name", name);
|
||||||
user.set("username", email);
|
user.set("email", email);
|
||||||
const userRes = await user.save();
|
user.set("password", password);
|
||||||
if (userRes) {
|
user.set("phone", phone);
|
||||||
const params = {
|
user.set("username", email);
|
||||||
userDetails: {
|
const userRes = await user.save();
|
||||||
jobTitle: jobTitle,
|
if (userRes) {
|
||||||
company: company,
|
const params = {
|
||||||
name: name,
|
userDetails: {
|
||||||
email: email,
|
jobTitle: jobTitle,
|
||||||
phone: phone,
|
company: company,
|
||||||
role: "contracts_Admin"
|
name: name,
|
||||||
}
|
email: email,
|
||||||
};
|
phone: phone,
|
||||||
try {
|
role: "contracts_Admin"
|
||||||
const usersignup = await Parse.Cloud.run("addadmin", params);
|
|
||||||
if (usersignup) {
|
|
||||||
if (isSubscribeNews) {
|
|
||||||
subscribeNewsletter();
|
|
||||||
}
|
}
|
||||||
handleNavigation(userRes.getSessionToken());
|
};
|
||||||
}
|
|
||||||
} catch (err) {
|
|
||||||
alert(err.message);
|
|
||||||
setState({ loading: false });
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} catch (error) {
|
|
||||||
console.log("err ", error);
|
|
||||||
if (error.code === 202) {
|
|
||||||
const params = { email: email };
|
|
||||||
const res = await Parse.Cloud.run("getUserDetails", params);
|
|
||||||
// console.log("Res ", res);
|
|
||||||
if (res) {
|
|
||||||
alert(t("already-exists-this-username"));
|
|
||||||
setState({ loading: false });
|
|
||||||
} else {
|
|
||||||
// console.log("state.email ", email);
|
|
||||||
try {
|
try {
|
||||||
await Parse.User.requestPasswordReset(email).then(
|
const usersignup = await Parse.Cloud.run("addadmin", params);
|
||||||
async function (res) {
|
if (usersignup) {
|
||||||
if (res.data === undefined) {
|
if (isSubscribeNews) {
|
||||||
alert(t("verification-code-sent"));
|
subscribeNewsletter();
|
||||||
}
|
|
||||||
}
|
}
|
||||||
);
|
handleNavigation(userRes.getSessionToken());
|
||||||
|
}
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.log(err);
|
alert(err.message);
|
||||||
|
setState({ loading: false });
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.log("err ", error);
|
||||||
|
if (error.code === 202) {
|
||||||
|
const params = { email: email };
|
||||||
|
const res = await Parse.Cloud.run("getUserDetails", params);
|
||||||
|
// console.log("Res ", res);
|
||||||
|
if (res) {
|
||||||
|
alert(t("already-exists-this-username"));
|
||||||
|
setState({ loading: false });
|
||||||
|
} else {
|
||||||
|
// console.log("state.email ", email);
|
||||||
|
try {
|
||||||
|
await Parse.User.requestPasswordReset(email).then(
|
||||||
|
async function (res) {
|
||||||
|
if (res.data === undefined) {
|
||||||
|
alert(t("verification-code-sent"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
} catch (err) {
|
||||||
|
console.log(err);
|
||||||
|
}
|
||||||
|
setState({ loading: false });
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
alert(error.message);
|
||||||
setState({ loading: false });
|
setState({ loading: false });
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
alert(error.message);
|
|
||||||
setState({ loading: false });
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -7,7 +7,7 @@ import Alert from "../primitives/Alert";
|
|||||||
import { appInfo } from "../constant/appinfo";
|
import { appInfo } from "../constant/appinfo";
|
||||||
import { useDispatch } from "react-redux";
|
import { useDispatch } from "react-redux";
|
||||||
import { fetchAppInfo } from "../redux/reducers/infoReducer";
|
import { fetchAppInfo } from "../redux/reducers/infoReducer";
|
||||||
import { isEnableSubscription } from "../constant/const";
|
import { emailRegex, isEnableSubscription } from "../constant/const";
|
||||||
import { getAppLogo } from "../constant/Utils";
|
import { getAppLogo } from "../constant/Utils";
|
||||||
import { useTranslation } from "react-i18next";
|
import { useTranslation } from "react-i18next";
|
||||||
|
|
||||||
@@ -36,18 +36,22 @@ function ForgotPassword() {
|
|||||||
|
|
||||||
const handleSubmit = async (event) => {
|
const handleSubmit = async (event) => {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
localStorage.setItem("appLogo", appInfo.applogo);
|
if (!emailRegex.test(state.email)) {
|
||||||
localStorage.setItem("userSettings", JSON.stringify(appInfo.settings));
|
alert("Please enter a valid email address.");
|
||||||
if (state.email) {
|
} else {
|
||||||
const username = state.email;
|
localStorage.setItem("appLogo", appInfo.applogo);
|
||||||
try {
|
localStorage.setItem("userSettings", JSON.stringify(appInfo.settings));
|
||||||
await Parse.User.requestPasswordReset(username);
|
if (state.email) {
|
||||||
setSentStatus("success");
|
const username = state.email;
|
||||||
} catch (err) {
|
try {
|
||||||
console.log("err ", err.code);
|
await Parse.User.requestPasswordReset(username);
|
||||||
setSentStatus("failed");
|
setSentStatus("success");
|
||||||
} finally {
|
} catch (err) {
|
||||||
setTimeout(() => setSentStatus(""), 1000);
|
console.log("err ", err.code);
|
||||||
|
setSentStatus("failed");
|
||||||
|
} finally {
|
||||||
|
setTimeout(() => setSentStatus(""), 1000);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1394,20 +1394,20 @@ const Forms = (props) => {
|
|||||||
)}
|
)}
|
||||||
|
|
||||||
{isAdvanceOpt && props.title !== "Sign Yourself" ? (
|
{isAdvanceOpt && props.title !== "Sign Yourself" ? (
|
||||||
<div
|
<span
|
||||||
onClick={() => setIsAdvanceOpt(!isAdvanceOpt)}
|
onClick={() => setIsAdvanceOpt(!isAdvanceOpt)}
|
||||||
className={`mt-2.5 op-link op-link-primary text-sm`}
|
className={`mt-2.5 op-link op-link-primary text-sm`}
|
||||||
>
|
>
|
||||||
{t("hide-advanced-options")}
|
{t("hide-advanced-options")}
|
||||||
</div>
|
</span>
|
||||||
) : (
|
) : (
|
||||||
props.title !== "Sign Yourself" && (
|
props.title !== "Sign Yourself" && (
|
||||||
<div
|
<span
|
||||||
onClick={() => setIsAdvanceOpt(!isAdvanceOpt)}
|
onClick={() => setIsAdvanceOpt(!isAdvanceOpt)}
|
||||||
className={`mt-2.5 op-link op-link-primary text-sm`}
|
className={`mt-2.5 op-link op-link-primary text-sm`}
|
||||||
>
|
>
|
||||||
{t("advanced-options")}
|
{t("advanced-options")}
|
||||||
</div>
|
</span>
|
||||||
)
|
)
|
||||||
)}
|
)}
|
||||||
|
|
||||||
|
|||||||
+147
-140
@@ -9,7 +9,7 @@ import { NavLink, useNavigate, useLocation } from "react-router-dom";
|
|||||||
import login_img from "../assets/images/login_img.svg";
|
import login_img from "../assets/images/login_img.svg";
|
||||||
import { useWindowSize } from "../hook/useWindowSize";
|
import { useWindowSize } from "../hook/useWindowSize";
|
||||||
import ModalUi from "../primitives/ModalUi";
|
import ModalUi from "../primitives/ModalUi";
|
||||||
import { isEnableSubscription } from "../constant/const";
|
import { emailRegex, isEnableSubscription } from "../constant/const";
|
||||||
import Alert from "../primitives/Alert";
|
import Alert from "../primitives/Alert";
|
||||||
import { appInfo } from "../constant/appinfo";
|
import { appInfo } from "../constant/appinfo";
|
||||||
import { fetchAppInfo } from "../redux/reducers/infoReducer";
|
import { fetchAppInfo } from "../redux/reducers/infoReducer";
|
||||||
@@ -89,167 +89,174 @@ function Login() {
|
|||||||
const handleSubmit = async (event) => {
|
const handleSubmit = async (event) => {
|
||||||
localStorage.removeItem("accesstoken");
|
localStorage.removeItem("accesstoken");
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
const { email, password } = state;
|
if (!emailRegex.test(state.email)) {
|
||||||
if (email && password) {
|
alert("Please enter a valid email address.");
|
||||||
try {
|
} else {
|
||||||
setState({ ...state, loading: true });
|
const { email, password } = state;
|
||||||
localStorage.setItem("appLogo", appInfo.applogo);
|
if (email && password) {
|
||||||
// Pass the username and password to logIn function
|
try {
|
||||||
const user = await Parse.User.logIn(email, password);
|
setState({ ...state, loading: true });
|
||||||
if (user) {
|
localStorage.setItem("appLogo", appInfo.applogo);
|
||||||
let _user = user.toJSON();
|
// Pass the username and password to logIn function
|
||||||
localStorage.setItem("UserInformation", JSON.stringify(_user));
|
const user = await Parse.User.logIn(email, password);
|
||||||
localStorage.setItem("userEmail", email);
|
if (user) {
|
||||||
localStorage.setItem("accesstoken", _user.sessionToken);
|
let _user = user.toJSON();
|
||||||
localStorage.setItem("scriptId", true);
|
localStorage.setItem("UserInformation", JSON.stringify(_user));
|
||||||
if (_user.ProfilePic) {
|
localStorage.setItem("userEmail", email);
|
||||||
localStorage.setItem("profileImg", _user.ProfilePic);
|
localStorage.setItem("accesstoken", _user.sessionToken);
|
||||||
} else {
|
localStorage.setItem("scriptId", true);
|
||||||
localStorage.setItem("profileImg", "");
|
if (_user.ProfilePic) {
|
||||||
}
|
localStorage.setItem("profileImg", _user.ProfilePic);
|
||||||
// Check extended class user role and tenentId
|
} else {
|
||||||
try {
|
localStorage.setItem("profileImg", "");
|
||||||
const userSettings = appInfo.settings;
|
}
|
||||||
await Parse.Cloud.run("getUserDetails")
|
// Check extended class user role and tenentId
|
||||||
.then(async (extUser) => {
|
try {
|
||||||
if (extUser) {
|
const userSettings = appInfo.settings;
|
||||||
// console.log("extUser", extUser, extUser?.get("IsDisabled"));
|
await Parse.Cloud.run("getUserDetails")
|
||||||
const IsDisabled = extUser?.get("IsDisabled") || false;
|
.then(async (extUser) => {
|
||||||
if (!IsDisabled) {
|
if (extUser) {
|
||||||
const userRole = extUser?.get("UserRole");
|
// console.log("extUser", extUser, extUser?.get("IsDisabled"));
|
||||||
const menu =
|
const IsDisabled = extUser?.get("IsDisabled") || false;
|
||||||
userRole &&
|
if (!IsDisabled) {
|
||||||
userSettings.find((menu) => menu.role === userRole);
|
const userRole = extUser?.get("UserRole");
|
||||||
if (menu) {
|
const menu =
|
||||||
const _currentRole = userRole;
|
userRole &&
|
||||||
const redirectUrl =
|
userSettings.find((menu) => menu.role === userRole);
|
||||||
location?.state?.from ||
|
if (menu) {
|
||||||
`/${menu.pageType}/${menu.pageId}`;
|
const _currentRole = userRole;
|
||||||
let _role = _currentRole.replace("contracts_", "");
|
const redirectUrl =
|
||||||
localStorage.setItem("_user_role", _role);
|
location?.state?.from ||
|
||||||
const checkLanguage = extUser?.get("Language");
|
`/${menu.pageType}/${menu.pageId}`;
|
||||||
if (checkLanguage) {
|
let _role = _currentRole.replace("contracts_", "");
|
||||||
checkLanguage && i18n.changeLanguage(checkLanguage);
|
localStorage.setItem("_user_role", _role);
|
||||||
}
|
const checkLanguage = extUser?.get("Language");
|
||||||
|
if (checkLanguage) {
|
||||||
|
checkLanguage && i18n.changeLanguage(checkLanguage);
|
||||||
|
}
|
||||||
|
|
||||||
const results = [extUser];
|
const results = [extUser];
|
||||||
const extUser_str = JSON.stringify(results);
|
const extUser_str = JSON.stringify(results);
|
||||||
|
|
||||||
localStorage.setItem("Extand_Class", extUser_str);
|
localStorage.setItem("Extand_Class", extUser_str);
|
||||||
const extInfo = JSON.parse(JSON.stringify(extUser));
|
const extInfo = JSON.parse(JSON.stringify(extUser));
|
||||||
localStorage.setItem("userEmail", extInfo.Email);
|
localStorage.setItem("userEmail", extInfo.Email);
|
||||||
localStorage.setItem("username", extInfo.Name);
|
localStorage.setItem("username", extInfo.Name);
|
||||||
if (extInfo?.TenantId) {
|
if (extInfo?.TenantId) {
|
||||||
const tenant = {
|
const tenant = {
|
||||||
Id: extInfo?.TenantId?.objectId || "",
|
Id: extInfo?.TenantId?.objectId || "",
|
||||||
Name: extInfo?.TenantId?.TenantName || ""
|
Name: extInfo?.TenantId?.TenantName || ""
|
||||||
};
|
};
|
||||||
localStorage.setItem("TenantId", tenant?.Id);
|
localStorage.setItem("TenantId", tenant?.Id);
|
||||||
dispatch(showTenant(tenant?.Name));
|
dispatch(showTenant(tenant?.Name));
|
||||||
localStorage.setItem("TenantName", tenant?.Name);
|
localStorage.setItem("TenantName", tenant?.Name);
|
||||||
}
|
}
|
||||||
localStorage.setItem("PageLanding", menu.pageId);
|
localStorage.setItem("PageLanding", menu.pageId);
|
||||||
localStorage.setItem("defaultmenuid", menu.menuId);
|
localStorage.setItem("defaultmenuid", menu.menuId);
|
||||||
localStorage.setItem("pageType", menu.pageType);
|
localStorage.setItem("pageType", menu.pageType);
|
||||||
if (isEnableSubscription) {
|
if (isEnableSubscription) {
|
||||||
const LocalUserDetails = {
|
const LocalUserDetails = {
|
||||||
name: results[0].get("Name"),
|
name: results[0].get("Name"),
|
||||||
email: results[0].get("Email"),
|
email: results[0].get("Email"),
|
||||||
phone: results[0]?.get("Phone") || "",
|
phone: results[0]?.get("Phone") || "",
|
||||||
company: results[0].get("Company")
|
company: results[0].get("Company")
|
||||||
};
|
};
|
||||||
localStorage.setItem(
|
localStorage.setItem(
|
||||||
"userDetails",
|
"userDetails",
|
||||||
JSON.stringify(LocalUserDetails)
|
JSON.stringify(LocalUserDetails)
|
||||||
);
|
);
|
||||||
const res = await fetchSubscription();
|
const res = await fetchSubscription();
|
||||||
const plan = res.plan;
|
const plan = res.plan;
|
||||||
const billingDate = res.billingDate;
|
const billingDate = res.billingDate;
|
||||||
if (plan === "freeplan") {
|
if (plan === "freeplan") {
|
||||||
setState({ ...state, loading: false });
|
|
||||||
navigate(redirectUrl);
|
|
||||||
} else if (billingDate) {
|
|
||||||
if (new Date(billingDate) > new Date()) {
|
|
||||||
localStorage.removeItem("userDetails");
|
|
||||||
// Redirect to the appropriate URL after successful login setState({ ...state, loading: false });
|
|
||||||
setState({ ...state, loading: false });
|
setState({ ...state, loading: false });
|
||||||
navigate(redirectUrl);
|
navigate(redirectUrl);
|
||||||
|
} else if (billingDate) {
|
||||||
|
if (new Date(billingDate) > new Date()) {
|
||||||
|
localStorage.removeItem("userDetails");
|
||||||
|
// Redirect to the appropriate URL after successful login setState({ ...state, loading: false });
|
||||||
|
setState({ ...state, loading: false });
|
||||||
|
navigate(redirectUrl);
|
||||||
|
} else {
|
||||||
|
setState({ ...state, loading: false });
|
||||||
|
handlePaidRoute(plan);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
setState({ ...state, loading: false });
|
setState({ ...state, loading: false });
|
||||||
handlePaidRoute(plan);
|
handlePaidRoute(plan);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
setState({ ...state, loading: false });
|
setState({ ...state, loading: false });
|
||||||
handlePaidRoute(plan);
|
// Redirect to the appropriate URL after successful login
|
||||||
|
navigate(redirectUrl);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
setState({ ...state, loading: false });
|
setState({ ...state, loading: false });
|
||||||
// Redirect to the appropriate URL after successful login
|
setIsModal(true);
|
||||||
navigate(redirectUrl);
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
setState({ ...state, loading: false });
|
setState({
|
||||||
setIsModal(true);
|
...state,
|
||||||
|
loading: false,
|
||||||
|
alertType: "danger",
|
||||||
|
alertMsg:
|
||||||
|
"You don't have access, please contact the admin."
|
||||||
|
});
|
||||||
|
logOutUser();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
setState({
|
if (isEnableSubscription) {
|
||||||
...state,
|
setState({ ...state, loading: false });
|
||||||
loading: false,
|
setIsModal(true);
|
||||||
alertType: "danger",
|
} else {
|
||||||
alertMsg:
|
setState({ ...state, loading: false });
|
||||||
"You don't have access, please contact the admin."
|
setState({
|
||||||
});
|
...state,
|
||||||
logOutUser();
|
loading: false,
|
||||||
|
alertType: "danger",
|
||||||
|
alertMsg: "User not found."
|
||||||
|
});
|
||||||
|
logOutUser();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else {
|
})
|
||||||
if (isEnableSubscription) {
|
.catch((error) => {
|
||||||
setState({ ...state, loading: false });
|
// const payload = { sessionToken: user.getSessionToken() };
|
||||||
setIsModal(true);
|
// handleSubmitbtn(payload);
|
||||||
} else {
|
setState({
|
||||||
setState({ ...state, loading: false });
|
...state,
|
||||||
setState({
|
loading: false,
|
||||||
...state,
|
alertType: "danger",
|
||||||
loading: false,
|
alertMsg: `Something went wrong.`
|
||||||
alertType: "danger",
|
});
|
||||||
alertMsg: "User not found."
|
setTimeout(() => setState({ ...state, alertMsg: "" }), 2000);
|
||||||
});
|
console.error("Error while fetching Follow", error);
|
||||||
logOutUser();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
})
|
|
||||||
.catch((error) => {
|
|
||||||
// const payload = { sessionToken: user.getSessionToken() };
|
|
||||||
// handleSubmitbtn(payload);
|
|
||||||
setState({
|
|
||||||
...state,
|
|
||||||
loading: false,
|
|
||||||
alertType: "danger",
|
|
||||||
alertMsg: `Something went wrong.`
|
|
||||||
});
|
});
|
||||||
setTimeout(() => setState({ ...state, alertMsg: "" }), 2000);
|
} catch (error) {
|
||||||
console.error("Error while fetching Follow", error);
|
setState({
|
||||||
|
...state,
|
||||||
|
loading: false,
|
||||||
|
alertType: "danger",
|
||||||
|
alertMsg: `${error.message}`
|
||||||
});
|
});
|
||||||
} catch (error) {
|
console.log(error);
|
||||||
setState({
|
setTimeout(() => setState({ ...state, alertMsg: "" }), 2000);
|
||||||
...state,
|
}
|
||||||
loading: false,
|
|
||||||
alertType: "danger",
|
|
||||||
alertMsg: `${error.message}`
|
|
||||||
});
|
|
||||||
console.log(error);
|
|
||||||
setTimeout(() => setState({ ...state, alertMsg: "" }), 2000);
|
|
||||||
}
|
}
|
||||||
|
} catch (error) {
|
||||||
|
setState({
|
||||||
|
...state,
|
||||||
|
loading: false,
|
||||||
|
alertType: "danger",
|
||||||
|
alertMsg: "Invalid username or password!"
|
||||||
|
});
|
||||||
|
console.error("Error while logging in user", error);
|
||||||
|
} finally {
|
||||||
|
setTimeout(
|
||||||
|
() => setState((prev) => ({ ...prev, alertMsg: "" })),
|
||||||
|
2000
|
||||||
|
);
|
||||||
}
|
}
|
||||||
} catch (error) {
|
|
||||||
setState({
|
|
||||||
...state,
|
|
||||||
loading: false,
|
|
||||||
alertType: "danger",
|
|
||||||
alertMsg: "Invalid username or password!"
|
|
||||||
});
|
|
||||||
console.error("Error while logging in user", error);
|
|
||||||
} finally {
|
|
||||||
setTimeout(() => setState((prev) => ({ ...prev, alertMsg: "" })), 2000);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -136,10 +136,10 @@ const ManageSign = () => {
|
|||||||
const replaceSpace = sanitizeFileName(sanitizename);
|
const replaceSpace = sanitizeFileName(sanitizename);
|
||||||
let file;
|
let file;
|
||||||
if (signature) {
|
if (signature) {
|
||||||
file = base64StringtoFile(signature, `${replaceSpace}_sign.png`);
|
file = base64StringtoFile(signature, `${replaceSpace}_sign`);
|
||||||
} else {
|
} else {
|
||||||
if (image && !isUrl) {
|
if (image && !isUrl) {
|
||||||
file = base64StringtoFile(image, `${replaceSpace}__sign.png`);
|
file = base64StringtoFile(image, `${replaceSpace}__sign`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
let imgUrl;
|
let imgUrl;
|
||||||
@@ -153,12 +153,12 @@ const ManageSign = () => {
|
|||||||
|
|
||||||
let initialFile;
|
let initialFile;
|
||||||
if (Initials) {
|
if (Initials) {
|
||||||
initialFile = base64StringtoFile(Initials, `${replaceSpace}_sign.png`);
|
initialFile = base64StringtoFile(Initials, `${replaceSpace}_sign`);
|
||||||
} else {
|
} else {
|
||||||
if (imgInitials && !isInitialsUrl) {
|
if (imgInitials && !isInitialsUrl) {
|
||||||
initialFile = base64StringtoFile(
|
initialFile = base64StringtoFile(
|
||||||
imgInitials,
|
imgInitials,
|
||||||
`${replaceSpace}__sign.png`
|
`${replaceSpace}__sign`
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -179,14 +179,18 @@ const ManageSign = () => {
|
|||||||
};
|
};
|
||||||
function base64StringtoFile(base64String, filename) {
|
function base64StringtoFile(base64String, filename) {
|
||||||
let arr = base64String.split(","),
|
let arr = base64String.split(","),
|
||||||
|
// type of uploaded image
|
||||||
mime = arr[0].match(/:(.*?);/)[1],
|
mime = arr[0].match(/:(.*?);/)[1],
|
||||||
|
// decode base64
|
||||||
bstr = atob(arr[1]),
|
bstr = atob(arr[1]),
|
||||||
n = bstr.length,
|
n = bstr.length,
|
||||||
u8arr = new Uint8Array(n);
|
u8arr = new Uint8Array(n);
|
||||||
while (n--) {
|
while (n--) {
|
||||||
u8arr[n] = bstr.charCodeAt(n);
|
u8arr[n] = bstr.charCodeAt(n);
|
||||||
}
|
}
|
||||||
return new File([u8arr], filename, { type: mime });
|
const ext = mime.split("/").pop();
|
||||||
|
const name = `${filename}.${ext}`;
|
||||||
|
return new File([u8arr], name, { type: mime });
|
||||||
}
|
}
|
||||||
|
|
||||||
const uploadFile = async (file) => {
|
const uploadFile = async (file) => {
|
||||||
|
|||||||
@@ -1,5 +1,10 @@
|
|||||||
import React, { useState, useRef, useEffect } from "react";
|
import React, { useState, useRef, useEffect } from "react";
|
||||||
import { isEnableSubscription, isStaging, themeColor } from "../constant/const";
|
import {
|
||||||
|
emailRegex,
|
||||||
|
isEnableSubscription,
|
||||||
|
isStaging,
|
||||||
|
themeColor
|
||||||
|
} from "../constant/const";
|
||||||
import { PDFDocument } from "pdf-lib";
|
import { PDFDocument } from "pdf-lib";
|
||||||
import "../styles/signature.css";
|
import "../styles/signature.css";
|
||||||
import Parse from "parse";
|
import Parse from "parse";
|
||||||
@@ -33,7 +38,10 @@ import {
|
|||||||
getDefaultSignature,
|
getDefaultSignature,
|
||||||
onClickZoomIn,
|
onClickZoomIn,
|
||||||
onClickZoomOut,
|
onClickZoomOut,
|
||||||
fetchUrl
|
fetchUrl,
|
||||||
|
signatureTypes,
|
||||||
|
handleSignatureType,
|
||||||
|
getTenantDetails
|
||||||
} from "../constant/Utils";
|
} from "../constant/Utils";
|
||||||
import Header from "../components/pdf/PdfHeader";
|
import Header from "../components/pdf/PdfHeader";
|
||||||
import RenderPdf from "../components/pdf/RenderPdf";
|
import RenderPdf from "../components/pdf/RenderPdf";
|
||||||
@@ -132,12 +140,11 @@ function PdfRequestFiles(props) {
|
|||||||
const [publicRes, setPublicRes] = useState({});
|
const [publicRes, setPublicRes] = useState({});
|
||||||
const [documentId, setDocumentId] = useState("");
|
const [documentId, setDocumentId] = useState("");
|
||||||
const [isPublicContact, setIsPublicContact] = useState(false);
|
const [isPublicContact, setIsPublicContact] = useState(false);
|
||||||
const [pdfArrayBuffer, setPdfArrayBuffer] = useState("");
|
|
||||||
const [plancode, setPlanCode] = useState("");
|
const [plancode, setPlanCode] = useState("");
|
||||||
const isHeader = useSelector((state) => state.showHeader);
|
const isHeader = useSelector((state) => state.showHeader);
|
||||||
const divRef = useRef(null);
|
const divRef = useRef(null);
|
||||||
const [isDownloadModal, setIsDownloadModal] = useState(false);
|
const [isDownloadModal, setIsDownloadModal] = useState(false);
|
||||||
|
const [signatureType, setSignatureType] = useState([]);
|
||||||
const isMobile = window.innerWidth < 767;
|
const isMobile = window.innerWidth < 767;
|
||||||
|
|
||||||
let isGuestSignFlow = false;
|
let isGuestSignFlow = false;
|
||||||
@@ -304,17 +311,13 @@ function PdfRequestFiles(props) {
|
|||||||
: [];
|
: [];
|
||||||
if (documentData && documentData[0]?.error) {
|
if (documentData && documentData[0]?.error) {
|
||||||
props?.setTemplateStatus &&
|
props?.setTemplateStatus &&
|
||||||
props?.setTemplateStatus({
|
props?.setTemplateStatus({ status: "Invalid" });
|
||||||
status: "Invalid"
|
|
||||||
});
|
|
||||||
throw new Error("error: Invalid TemplateId");
|
throw new Error("error: Invalid TemplateId");
|
||||||
} else if (documentData && documentData.length > 0) {
|
} else if (documentData && documentData.length > 0) {
|
||||||
if (documentData[0]?.IsPublic) {
|
if (documentData[0]?.IsPublic) {
|
||||||
//handle condition when someone use plan js then setTemplateStatus is not supporting
|
//handle condition when someone use plan js then setTemplateStatus is not supporting
|
||||||
props?.setTemplateStatus &&
|
props?.setTemplateStatus &&
|
||||||
props?.setTemplateStatus({
|
props?.setTemplateStatus({ status: "Success" });
|
||||||
status: "Success"
|
|
||||||
});
|
|
||||||
const url =
|
const url =
|
||||||
documentData[0] &&
|
documentData[0] &&
|
||||||
(documentData[0]?.SignedUrl || documentData[0]?.URL);
|
(documentData[0]?.SignedUrl || documentData[0]?.URL);
|
||||||
@@ -323,8 +326,6 @@ function PdfRequestFiles(props) {
|
|||||||
const arrayBuffer = await convertPdfArrayBuffer(url);
|
const arrayBuffer = await convertPdfArrayBuffer(url);
|
||||||
if (arrayBuffer === "Error") {
|
if (arrayBuffer === "Error") {
|
||||||
setHandleError(t("something-went-wrong-mssg"));
|
setHandleError(t("something-went-wrong-mssg"));
|
||||||
} else {
|
|
||||||
setPdfArrayBuffer(arrayBuffer);
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
setHandleError(t("something-went-wrong-mssg"));
|
setHandleError(t("something-went-wrong-mssg"));
|
||||||
@@ -354,24 +355,18 @@ function PdfRequestFiles(props) {
|
|||||||
}
|
}
|
||||||
setUnSignedSigners(placeholdersOrSigners);
|
setUnSignedSigners(placeholdersOrSigners);
|
||||||
setPdfDetails(documentData);
|
setPdfDetails(documentData);
|
||||||
setIsLoading({
|
setIsLoading({ isLoad: false });
|
||||||
isLoad: false
|
|
||||||
});
|
|
||||||
} else {
|
} else {
|
||||||
props?.setTemplateStatus &&
|
props?.setTemplateStatus &&
|
||||||
props?.setTemplateStatus({
|
props?.setTemplateStatus({ status: "Private" });
|
||||||
status: "Private"
|
setIsLoading({ isLoad: false });
|
||||||
});
|
|
||||||
setIsLoading(false);
|
|
||||||
setHandleError(t("something-went-wrong-mssg"));
|
setHandleError(t("something-went-wrong-mssg"));
|
||||||
console.error("error: TemplateId is not public");
|
console.error("error: TemplateId is not public");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
props?.setTemplateStatus &&
|
props?.setTemplateStatus &&
|
||||||
props?.setTemplateStatus({
|
props?.setTemplateStatus({ status: "Invalid" });
|
||||||
status: "Invalid"
|
|
||||||
});
|
|
||||||
setIsLoading(false);
|
setIsLoading(false);
|
||||||
setHandleError(t("something-went-wrong-mssg"));
|
setHandleError(t("something-went-wrong-mssg"));
|
||||||
console.error("error: Invalid TemplateId");
|
console.error("error: Invalid TemplateId");
|
||||||
@@ -388,6 +383,33 @@ function PdfRequestFiles(props) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
const fetchTenantDetails = async (contactId) => {
|
||||||
|
const user = JSON.parse(
|
||||||
|
localStorage.getItem(
|
||||||
|
`Parse/${localStorage.getItem("parseAppId")}/currentUser`
|
||||||
|
)
|
||||||
|
);
|
||||||
|
try {
|
||||||
|
const tenantDetails = await getTenantDetails(
|
||||||
|
user?.objectId, // userId
|
||||||
|
"", // jwttoken
|
||||||
|
contactId // contactId
|
||||||
|
);
|
||||||
|
if (tenantDetails && tenantDetails === "user does not exist!") {
|
||||||
|
alert(t("user-not-exist"));
|
||||||
|
} else if (tenantDetails) {
|
||||||
|
const signatureType = tenantDetails?.SignatureType || [];
|
||||||
|
const filterSignTypes = signatureType?.filter(
|
||||||
|
(x) => x.enabled === true
|
||||||
|
);
|
||||||
|
|
||||||
|
return filterSignTypes;
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
alert(t("user-not-exist"));
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
//function for get document details for perticular signer with signer'object id
|
//function for get document details for perticular signer with signer'object id
|
||||||
const getDocumentDetails = async (docId, isNextUser) => {
|
const getDocumentDetails = async (docId, isNextUser) => {
|
||||||
try {
|
try {
|
||||||
@@ -395,11 +417,27 @@ function PdfRequestFiles(props) {
|
|||||||
`Parse/${localStorage.getItem("parseAppId")}/currentUser`
|
`Parse/${localStorage.getItem("parseAppId")}/currentUser`
|
||||||
);
|
);
|
||||||
const jsonSender = JSON.parse(senderUser);
|
const jsonSender = JSON.parse(senderUser);
|
||||||
|
const contactId = jsonSender?.objectId
|
||||||
|
? ""
|
||||||
|
: contactBookId || signerObjectId || "";
|
||||||
|
const tenantSignTypes = await fetchTenantDetails(contactId);
|
||||||
// `currUserId` will be contactId or extUserId
|
// `currUserId` will be contactId or extUserId
|
||||||
let currUserId;
|
let currUserId;
|
||||||
//getting document details
|
//getting document details
|
||||||
const documentData = await contractDocument(docId);
|
const documentData = await contractDocument(docId);
|
||||||
if (documentData && documentData.length > 0) {
|
if (documentData && documentData.length > 0) {
|
||||||
|
const userSignatureType =
|
||||||
|
documentData[0]?.ExtUserPtr?.SignatureType || signatureTypes;
|
||||||
|
const docSignTypes =
|
||||||
|
documentData?.[0]?.SignatureType || userSignatureType;
|
||||||
|
const updatedSignatureType = await handleSignatureType(
|
||||||
|
tenantSignTypes,
|
||||||
|
docSignTypes
|
||||||
|
);
|
||||||
|
setSignatureType(updatedSignatureType);
|
||||||
|
const updatedPdfDetails = [...documentData];
|
||||||
|
updatedPdfDetails[0].SignatureType = updatedSignatureType;
|
||||||
|
setPdfDetails(updatedPdfDetails);
|
||||||
const url =
|
const url =
|
||||||
documentData[0] &&
|
documentData[0] &&
|
||||||
(documentData[0]?.SignedUrl || documentData[0]?.URL);
|
(documentData[0]?.SignedUrl || documentData[0]?.URL);
|
||||||
@@ -408,8 +446,6 @@ function PdfRequestFiles(props) {
|
|||||||
const arrayBuffer = await convertPdfArrayBuffer(url);
|
const arrayBuffer = await convertPdfArrayBuffer(url);
|
||||||
if (arrayBuffer === "Error") {
|
if (arrayBuffer === "Error") {
|
||||||
setHandleError(t("something-went-wrong-mssg"));
|
setHandleError(t("something-went-wrong-mssg"));
|
||||||
} else {
|
|
||||||
setPdfArrayBuffer(arrayBuffer);
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
setHandleError(t("something-went-wrong-mssg"));
|
setHandleError(t("something-went-wrong-mssg"));
|
||||||
@@ -431,7 +467,7 @@ function PdfRequestFiles(props) {
|
|||||||
|
|
||||||
currUserId = getCurrentSigner?.objectId
|
currUserId = getCurrentSigner?.objectId
|
||||||
? getCurrentSigner.objectId
|
? getCurrentSigner.objectId
|
||||||
: contactBookId || signerObjectId || "";
|
: contactBookId || signerObjectId || ""; //signerObjectId is contactBookId refer from public template flow
|
||||||
if (isEnableSubscription) {
|
if (isEnableSubscription) {
|
||||||
await checkIsSubscribed(
|
await checkIsSubscribed(
|
||||||
documentData[0]?.ExtUserPtr?.objectId,
|
documentData[0]?.ExtUserPtr?.objectId,
|
||||||
@@ -891,9 +927,29 @@ function PdfRequestFiles(props) {
|
|||||||
setIsUiLoading(true);
|
setIsUiLoading(true);
|
||||||
// `widgets` is Used to return widgets details with page number of current user
|
// `widgets` is Used to return widgets details with page number of current user
|
||||||
const widgets = checkUser?.[0]?.placeHolder;
|
const widgets = checkUser?.[0]?.placeHolder;
|
||||||
|
let pdfArrBuffer;
|
||||||
|
//`contractDocument` function used to get updated SignedUrl
|
||||||
|
// to resolve issue of widgets get remove automatically when more than 1 signers try to sign doc at a time
|
||||||
|
const documentData = await contractDocument(documentId);
|
||||||
|
if (documentData && documentData.length > 0) {
|
||||||
|
const url = documentData[0]?.SignedUrl || documentData[0]?.URL;
|
||||||
|
//convert document url in array buffer format to use embed widgets in pdf using pdf-lib
|
||||||
|
const arrayBuffer = await convertPdfArrayBuffer(url);
|
||||||
|
if (arrayBuffer === "Error") {
|
||||||
|
setHandleError("Error: invalid document!");
|
||||||
|
} else {
|
||||||
|
pdfArrBuffer = arrayBuffer;
|
||||||
|
}
|
||||||
|
} else if (
|
||||||
|
documentData === "Error: Something went wrong!" ||
|
||||||
|
(documentData.result && documentData.result.error)
|
||||||
|
) {
|
||||||
|
setHandleError("Error: Something went wrong!");
|
||||||
|
} else {
|
||||||
|
setHandleError("Document not Found!");
|
||||||
|
}
|
||||||
// Load a PDFDocument from the existing PDF bytes
|
// Load a PDFDocument from the existing PDF bytes
|
||||||
const existingPdfBytes = pdfArrayBuffer;
|
const existingPdfBytes = pdfArrBuffer;
|
||||||
try {
|
try {
|
||||||
const pdfDoc = await PDFDocument.load(existingPdfBytes);
|
const pdfDoc = await PDFDocument.load(existingPdfBytes);
|
||||||
const isSignYourSelfFlow = false;
|
const isSignYourSelfFlow = false;
|
||||||
@@ -910,9 +966,7 @@ function PdfRequestFiles(props) {
|
|||||||
widgets,
|
widgets,
|
||||||
pdfDoc,
|
pdfDoc,
|
||||||
isSignYourSelfFlow,
|
isSignYourSelfFlow,
|
||||||
scale,
|
scale
|
||||||
pdfOriginalWH,
|
|
||||||
containerWH
|
|
||||||
);
|
);
|
||||||
// console.log("pdfte", pdfBytes);
|
// console.log("pdfte", pdfBytes);
|
||||||
//get ExistUserPtr object id of user class to get tenantDetails
|
//get ExistUserPtr object id of user class to get tenantDetails
|
||||||
@@ -954,11 +1008,7 @@ function PdfRequestFiles(props) {
|
|||||||
const newDate = new Date(expireDate);
|
const newDate = new Date(expireDate);
|
||||||
const localExpireDate = newDate.toLocaleDateString(
|
const localExpireDate = newDate.toLocaleDateString(
|
||||||
"en-US",
|
"en-US",
|
||||||
{
|
{ day: "numeric", month: "long", year: "numeric" }
|
||||||
day: "numeric",
|
|
||||||
month: "long",
|
|
||||||
year: "numeric"
|
|
||||||
}
|
|
||||||
);
|
);
|
||||||
let senderEmail = pdfDetails?.[0].ExtUserPtr.Email;
|
let senderEmail = pdfDetails?.[0].ExtUserPtr.Email;
|
||||||
let senderPhone = pdfDetails?.[0]?.ExtUserPtr?.Phone;
|
let senderPhone = pdfDetails?.[0]?.ExtUserPtr?.Phone;
|
||||||
@@ -1072,12 +1122,16 @@ function PdfRequestFiles(props) {
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
setIsUiLoading(false);
|
setIsUiLoading(false);
|
||||||
setIsAlert({ isShow: true, alertMessage: resSign.message });
|
setIsAlert({
|
||||||
|
title: "Error",
|
||||||
|
isShow: true,
|
||||||
|
alertMessage: resSign.message
|
||||||
|
});
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
setIsUiLoading(false);
|
setIsUiLoading(false);
|
||||||
setIsAlert({
|
setIsAlert({
|
||||||
header: t("error"),
|
title: "Error",
|
||||||
isShow: true,
|
isShow: true,
|
||||||
alertMessage: t("pdf-uncompatible")
|
alertMessage: t("pdf-uncompatible")
|
||||||
});
|
});
|
||||||
@@ -1363,9 +1417,7 @@ function PdfRequestFiles(props) {
|
|||||||
try {
|
try {
|
||||||
await axios.post(
|
await axios.post(
|
||||||
`${localStorage.getItem("baseUrl")}functions/updatecontacttour`,
|
`${localStorage.getItem("baseUrl")}functions/updatecontacttour`,
|
||||||
{
|
{ contactId: signerObjectId },
|
||||||
contactId: signerObjectId
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
headers: {
|
headers: {
|
||||||
"Content-Type": "application/json",
|
"Content-Type": "application/json",
|
||||||
@@ -1506,65 +1558,69 @@ function PdfRequestFiles(props) {
|
|||||||
//`handlePublicUser` function to use create user from public role and create document from public template
|
//`handlePublicUser` function to use create user from public role and create document from public template
|
||||||
const handlePublicUser = async (e) => {
|
const handlePublicUser = async (e) => {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
setLoading(true);
|
if (!emailRegex.test(contact.email)) {
|
||||||
try {
|
alert("Please enter a valid email address.");
|
||||||
const params = {
|
} else {
|
||||||
...contact,
|
setLoading(true);
|
||||||
templateid: pdfDetails[0]?.objectId,
|
try {
|
||||||
role: pdfDetails[0]?.PublicRole[0]
|
const params = {
|
||||||
};
|
...contact,
|
||||||
const userRes = await axios.post(
|
templateid: pdfDetails[0]?.objectId,
|
||||||
`${localStorage.getItem(
|
role: pdfDetails[0]?.PublicRole[0]
|
||||||
"baseUrl"
|
};
|
||||||
)}/functions/publicuserlinkcontacttodoc`,
|
const userRes = await axios.post(
|
||||||
params,
|
`${localStorage.getItem(
|
||||||
{
|
"baseUrl"
|
||||||
headers: {
|
)}/functions/publicuserlinkcontacttodoc`,
|
||||||
"Content-Type": "application/json",
|
params,
|
||||||
"X-Parse-Application-Id": localStorage.getItem("parseAppId")
|
{
|
||||||
|
headers: {
|
||||||
|
"Content-Type": "application/json",
|
||||||
|
"X-Parse-Application-Id": localStorage.getItem("parseAppId")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
);
|
||||||
);
|
|
||||||
|
|
||||||
if (userRes?.data?.result) {
|
if (userRes?.data?.result) {
|
||||||
setPublicRes(userRes.data.result);
|
setPublicRes(userRes.data.result);
|
||||||
const isEnableOTP = pdfDetails?.[0]?.IsEnableOTP || false;
|
const isEnableOTP = pdfDetails?.[0]?.IsEnableOTP || false;
|
||||||
if (isEnableOTP) {
|
if (isEnableOTP) {
|
||||||
await SendOtp();
|
await SendOtp();
|
||||||
|
} else {
|
||||||
|
setIsPublicContact(false);
|
||||||
|
setIsPublicTemplate(false);
|
||||||
|
setDocumentId(userRes.data?.result?.docId);
|
||||||
|
const contactId = userRes.data.result?.contactId;
|
||||||
|
setSignerObjectId(contactId);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
setIsPublicContact(false);
|
console.log("error in public-sign to create user details");
|
||||||
setIsPublicTemplate(false);
|
setIsAlert({
|
||||||
setDocumentId(userRes.data?.result?.docId);
|
title: "Error",
|
||||||
const contactId = userRes.data.result?.contactId;
|
isShow: true,
|
||||||
setSignerObjectId(contactId);
|
alertMessage: t("something-went-wrong-mssg")
|
||||||
|
});
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
console.log("e", e);
|
||||||
|
if (
|
||||||
|
e?.response?.data?.error === "Insufficient Credit" ||
|
||||||
|
e?.response?.data?.error === "Plan expired"
|
||||||
|
) {
|
||||||
|
handleCloseOtp();
|
||||||
|
setIsAlert({
|
||||||
|
title: t("insufficient-credits"),
|
||||||
|
isShow: true,
|
||||||
|
alertMessage: t("insufficient-credits-mssg")
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
handleCloseOtp();
|
||||||
|
setIsAlert({
|
||||||
|
title: "Error",
|
||||||
|
isShow: true,
|
||||||
|
alertMessage: t("something-went-wrong-mssg")
|
||||||
|
});
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
console.log("error in public-sign to create user details");
|
|
||||||
setIsAlert({
|
|
||||||
title: "Error",
|
|
||||||
isShow: true,
|
|
||||||
alertMessage: t("something-went-wrong-mssg")
|
|
||||||
});
|
|
||||||
}
|
|
||||||
} catch (e) {
|
|
||||||
console.log("e", e);
|
|
||||||
if (
|
|
||||||
e?.response?.data?.error === "Insufficient Credit" ||
|
|
||||||
e?.response?.data?.error === "Plan expired"
|
|
||||||
) {
|
|
||||||
handleCloseOtp();
|
|
||||||
setIsAlert({
|
|
||||||
title: t("insufficient-credits"),
|
|
||||||
isShow: true,
|
|
||||||
alertMessage: t("insufficient-credits-mssg")
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
handleCloseOtp();
|
|
||||||
setIsAlert({
|
|
||||||
title: "Error",
|
|
||||||
isShow: true,
|
|
||||||
alertMessage: t("something-went-wrong-mssg")
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -1946,7 +2002,7 @@ function PdfRequestFiles(props) {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
type="button"
|
type="button"
|
||||||
className="op-btn op-btn-secondary"
|
className="op-btn op-btn-secondary ml-1"
|
||||||
>
|
>
|
||||||
{t("close")}
|
{t("close")}
|
||||||
</button>
|
</button>
|
||||||
@@ -2089,27 +2145,30 @@ function PdfRequestFiles(props) {
|
|||||||
</div>
|
</div>
|
||||||
</ModalUi>
|
</ModalUi>
|
||||||
{/* this component is used for signature pad modal */}
|
{/* this component is used for signature pad modal */}
|
||||||
<SignPad
|
{documentId && (
|
||||||
isSignPad={isSignPad}
|
<SignPad
|
||||||
isStamp={isStamp}
|
signatureTypes={signatureType}
|
||||||
setIsImageSelect={setIsImageSelect}
|
isSignPad={isSignPad}
|
||||||
setIsSignPad={setIsSignPad}
|
isStamp={isStamp}
|
||||||
setImage={setImage}
|
setIsImageSelect={setIsImageSelect}
|
||||||
isImageSelect={isImageSelect}
|
setIsSignPad={setIsSignPad}
|
||||||
imageRef={imageRef}
|
setImage={setImage}
|
||||||
onImageChange={onImageChange}
|
isImageSelect={isImageSelect}
|
||||||
setSignature={setSignature}
|
imageRef={imageRef}
|
||||||
image={image}
|
onImageChange={onImageChange}
|
||||||
onSaveImage={saveImage}
|
setSignature={setSignature}
|
||||||
onSaveSign={saveSign}
|
image={image}
|
||||||
defaultSign={defaultSignImg}
|
onSaveImage={saveImage}
|
||||||
myInitial={myInitial}
|
onSaveSign={saveSign}
|
||||||
isInitial={isInitial}
|
defaultSign={defaultSignImg}
|
||||||
setIsInitial={setIsInitial}
|
myInitial={myInitial}
|
||||||
setIsStamp={setIsStamp}
|
isInitial={isInitial}
|
||||||
currWidgetsDetails={currWidgetsDetails}
|
setIsInitial={setIsInitial}
|
||||||
setCurrWidgetsDetails={setCurrWidgetsDetails}
|
setIsStamp={setIsStamp}
|
||||||
/>
|
currWidgetsDetails={currWidgetsDetails}
|
||||||
|
setCurrWidgetsDetails={setCurrWidgetsDetails}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
{/* pdf header which contain funish back button */}
|
{/* pdf header which contain funish back button */}
|
||||||
<Header
|
<Header
|
||||||
isPdfRequestFiles={isPublicTemplate ? false : true}
|
isPdfRequestFiles={isPublicTemplate ? false : true}
|
||||||
@@ -2238,6 +2297,10 @@ function PdfRequestFiles(props) {
|
|||||||
setIsLoading={setIsLoading}
|
setIsLoading={setIsLoading}
|
||||||
xyPostion={signerPos}
|
xyPostion={signerPos}
|
||||||
setDefaultSignAlert={setDefaultSignAlert}
|
setDefaultSignAlert={setDefaultSignAlert}
|
||||||
|
isDefault={
|
||||||
|
signatureType?.find((x) => x.name === "default")
|
||||||
|
?.enabled || false
|
||||||
|
}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -38,7 +38,9 @@ import {
|
|||||||
onClickZoomOut,
|
onClickZoomOut,
|
||||||
rotatePdfPage,
|
rotatePdfPage,
|
||||||
handleRemoveWidgets,
|
handleRemoveWidgets,
|
||||||
handleRotateWarning
|
handleRotateWarning,
|
||||||
|
signatureTypes,
|
||||||
|
handleSignatureType
|
||||||
} from "../constant/Utils";
|
} from "../constant/Utils";
|
||||||
import RenderPdf from "../components/pdf/RenderPdf";
|
import RenderPdf from "../components/pdf/RenderPdf";
|
||||||
import { useNavigate } from "react-router-dom";
|
import { useNavigate } from "react-router-dom";
|
||||||
@@ -151,28 +153,23 @@ function PlaceHolderSign() {
|
|||||||
const [scale, setScale] = useState(1);
|
const [scale, setScale] = useState(1);
|
||||||
const [pdfRotateBase64, setPdfRotatese64] = useState("");
|
const [pdfRotateBase64, setPdfRotatese64] = useState("");
|
||||||
const [planCode, setPlanCode] = useState("");
|
const [planCode, setPlanCode] = useState("");
|
||||||
|
const [unSignedWidgetId, setUnSignedWidgetId] = useState("");
|
||||||
|
const [signatureType, setSignatureType] = useState(signatureTypes);
|
||||||
const isMobile = window.innerWidth < 767;
|
const isMobile = window.innerWidth < 767;
|
||||||
const [, drop] = useDrop({
|
const [, drop] = useDrop({
|
||||||
accept: "BOX",
|
accept: "BOX",
|
||||||
drop: (item, monitor) => addPositionOfSignature(item, monitor),
|
drop: (item, monitor) => addPositionOfSignature(item, monitor),
|
||||||
collect: (monitor) => ({
|
collect: (monitor) => ({ isOver: !!monitor.isOver() })
|
||||||
isOver: !!monitor.isOver()
|
|
||||||
})
|
|
||||||
});
|
});
|
||||||
|
|
||||||
const [{ isDragSign }, dragSignature] = useDrag({
|
const [{ isDragSign }, dragSignature] = useDrag({
|
||||||
type: "BOX",
|
type: "BOX",
|
||||||
item: { type: "BOX", id: 1, text: "signature" },
|
item: { type: "BOX", id: 1, text: "signature" },
|
||||||
collect: (monitor) => ({
|
collect: (monitor) => ({ isDragSign: !!monitor.isDragging() })
|
||||||
isDragSign: !!monitor.isDragging()
|
|
||||||
})
|
|
||||||
});
|
});
|
||||||
const [{ isDragStamp }, dragStamp] = useDrag({
|
const [{ isDragStamp }, dragStamp] = useDrag({
|
||||||
type: "BOX",
|
type: "BOX",
|
||||||
item: { type: "BOX", id: 2, text: "stamp" },
|
item: { type: "BOX", id: 2, text: "stamp" },
|
||||||
collect: (monitor) => ({
|
collect: (monitor) => ({ isDragStamp: !!monitor.isDragging() })
|
||||||
isDragStamp: !!monitor.isDragging()
|
|
||||||
})
|
|
||||||
});
|
});
|
||||||
const documentId = docId;
|
const documentId = docId;
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
@@ -201,10 +198,15 @@ function PlaceHolderSign() {
|
|||||||
if (tenantDetails && tenantDetails === "user does not exist!") {
|
if (tenantDetails && tenantDetails === "user does not exist!") {
|
||||||
alert(t("user-not-exist"));
|
alert(t("user-not-exist"));
|
||||||
} else if (tenantDetails) {
|
} else if (tenantDetails) {
|
||||||
|
const signatureType = tenantDetails?.SignatureType || [];
|
||||||
|
const filterSignTypes = signatureType?.filter(
|
||||||
|
(x) => x.enabled === true
|
||||||
|
);
|
||||||
if (tenantDetails?.RequestBody) {
|
if (tenantDetails?.RequestBody) {
|
||||||
setRequestBody(tenantDetails?.RequestBody);
|
setRequestBody(tenantDetails?.RequestBody);
|
||||||
setRequestSubject(tenantDetails?.RequestSubject);
|
setRequestSubject(tenantDetails?.RequestSubject);
|
||||||
}
|
}
|
||||||
|
return filterSignTypes;
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
alert(t("user-not-exist"));
|
alert(t("user-not-exist"));
|
||||||
@@ -255,7 +257,7 @@ function PlaceHolderSign() {
|
|||||||
}
|
}
|
||||||
//function for get document details
|
//function for get document details
|
||||||
const getDocumentDetails = async () => {
|
const getDocumentDetails = async () => {
|
||||||
fetchTenantDetails();
|
const tenantSignTypes = await fetchTenantDetails();
|
||||||
//getting document details
|
//getting document details
|
||||||
const documentData = await contractDocument(documentId);
|
const documentData = await contractDocument(documentId);
|
||||||
if (documentData && documentData.length > 0) {
|
if (documentData && documentData.length > 0) {
|
||||||
@@ -312,7 +314,18 @@ function PlaceHolderSign() {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
setPdfDetails(documentData);
|
const userSignatureType =
|
||||||
|
documentData[0]?.ExtUserPtr?.SignatureType || signatureTypes;
|
||||||
|
const docSignTypes =
|
||||||
|
documentData?.[0]?.SignatureType || userSignatureType;
|
||||||
|
const updatedSignatureType = await handleSignatureType(
|
||||||
|
tenantSignTypes,
|
||||||
|
docSignTypes
|
||||||
|
);
|
||||||
|
setSignatureType(updatedSignatureType);
|
||||||
|
const updatedPdfDetails = [...documentData];
|
||||||
|
updatedPdfDetails[0].SignatureType = updatedSignatureType;
|
||||||
|
setPdfDetails(updatedPdfDetails);
|
||||||
//condition when placeholder have empty array with role details and signers array have signers data
|
//condition when placeholder have empty array with role details and signers array have signers data
|
||||||
//and both array length are same
|
//and both array length are same
|
||||||
//this case happen using placeholder form in auto save funtionality to save draft type document without adding any placehlder
|
//this case happen using placeholder form in auto save funtionality to save draft type document without adding any placehlder
|
||||||
@@ -475,8 +488,10 @@ function PlaceHolderSign() {
|
|||||||
let dropData = [];
|
let dropData = [];
|
||||||
let placeHolder;
|
let placeHolder;
|
||||||
const dragTypeValue = item?.text ? item.text : monitor.type;
|
const dragTypeValue = item?.text ? item.text : monitor.type;
|
||||||
const widgetWidth = defaultWidthHeight(dragTypeValue).width;
|
const widgetWidth =
|
||||||
const widgetHeight = defaultWidthHeight(dragTypeValue).height;
|
defaultWidthHeight(dragTypeValue).width * containerScale;
|
||||||
|
const widgetHeight =
|
||||||
|
defaultWidthHeight(dragTypeValue).height * containerScale;
|
||||||
//adding and updating drop position in array when user drop signature button in div
|
//adding and updating drop position in array when user drop signature button in div
|
||||||
if (item === "onclick") {
|
if (item === "onclick") {
|
||||||
const divHeight = divRef.current.getBoundingClientRect().height;
|
const divHeight = divRef.current.getBoundingClientRect().height;
|
||||||
@@ -813,9 +828,7 @@ function PlaceHolderSign() {
|
|||||||
placeholder,
|
placeholder,
|
||||||
pdfDoc,
|
pdfDoc,
|
||||||
isSignYourSelfFlow,
|
isSignYourSelfFlow,
|
||||||
scale,
|
scale
|
||||||
pdfOriginalWH,
|
|
||||||
containerWH
|
|
||||||
);
|
);
|
||||||
const pdfUrl = await convertBase64ToFile(pdfDetails[0].Name, pdfBase64);
|
const pdfUrl = await convertBase64ToFile(pdfDetails[0].Name, pdfBase64);
|
||||||
const tenantId = localStorage.getItem("TenantId");
|
const tenantId = localStorage.getItem("TenantId");
|
||||||
@@ -844,17 +857,24 @@ function PlaceHolderSign() {
|
|||||||
};
|
};
|
||||||
const alertSendEmail = async () => {
|
const alertSendEmail = async () => {
|
||||||
const filterPrefill = signerPos?.filter((data) => data.Role !== "prefill");
|
const filterPrefill = signerPos?.filter((data) => data.Role !== "prefill");
|
||||||
const getPrefill = signerPos?.filter((data) => data.Role === "prefill");
|
const getPrefill = signerPos?.find((data) => data.Role === "prefill");
|
||||||
let isLabel = false;
|
let isLabel = false;
|
||||||
|
let unfilledTextWidgetId = "";
|
||||||
//checking all signers placeholder exist or not
|
//checking all signers placeholder exist or not
|
||||||
const isPlaceholderExist = filterPrefill.every((data) => data.placeHolder);
|
const isPlaceholderExist = filterPrefill.every((data) => data.placeHolder);
|
||||||
const prefillPlaceholder = getPrefill[0]?.placeHolder;
|
const prefillPlaceholder = getPrefill?.placeHolder;
|
||||||
//condition is used to check text widget data is empty or have response
|
//condition is used to check text widget data is empty or have response
|
||||||
if (getPrefill && getPrefill.length > 0) {
|
if (getPrefill) {
|
||||||
if (prefillPlaceholder) {
|
if (prefillPlaceholder) {
|
||||||
prefillPlaceholder.map((data) => {
|
prefillPlaceholder.map((data) => {
|
||||||
if (!isLabel) {
|
if (!isLabel) {
|
||||||
isLabel = data.pos.some((position) => !position.options.response);
|
const unfilledTextWidgets = data.pos.find(
|
||||||
|
(position) => !position.options.response
|
||||||
|
);
|
||||||
|
if (unfilledTextWidgets) {
|
||||||
|
isLabel = true;
|
||||||
|
unfilledTextWidgetId = unfilledTextWidgets.key;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -882,6 +902,7 @@ function PlaceHolderSign() {
|
|||||||
}
|
}
|
||||||
if (getPrefill && isLabel) {
|
if (getPrefill && isLabel) {
|
||||||
setIsSendAlert({ mssg: textWidget, alert: true });
|
setIsSendAlert({ mssg: textWidget, alert: true });
|
||||||
|
setUnSignedWidgetId(unfilledTextWidgetId);
|
||||||
} else if (isSignatureExist) {
|
} else if (isSignatureExist) {
|
||||||
if (isPlaceholderExist) {
|
if (isPlaceholderExist) {
|
||||||
const IsSignerNotExist = filterPrefill?.filter((x) => !x.signerObjId);
|
const IsSignerNotExist = filterPrefill?.filter((x) => !x.signerObjId);
|
||||||
@@ -907,24 +928,26 @@ function PlaceHolderSign() {
|
|||||||
}, 2000);
|
}, 2000);
|
||||||
return () => clearTimeout(timer);
|
return () => clearTimeout(timer);
|
||||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||||
}, [signerPos, signersdata]);
|
}, [signerPos, signersdata, signatureType]);
|
||||||
|
|
||||||
// `autosavedetails` is used to save doc details after every 2 sec when changes are happern in placeholder like drag-drop widgets, remove signers
|
// `autosavedetails` is used to save doc details after every 2 sec when changes are happern in placeholder like drag-drop widgets, remove signers
|
||||||
const autosavedetails = async () => {
|
const autosavedetails = async () => {
|
||||||
const signers = signersdata?.filter(
|
const signers = signersdata?.reduce((acc, x) => {
|
||||||
(x) =>
|
if (x.objectId) {
|
||||||
x?.Role !== "prefill" &&
|
acc.push({
|
||||||
x.objectId && {
|
|
||||||
__type: "Pointer",
|
__type: "Pointer",
|
||||||
className: "contracts_Contactbook",
|
className: "contracts_Contactbook",
|
||||||
objectId: x.objectId
|
objectId: x.objectId
|
||||||
}
|
});
|
||||||
);
|
}
|
||||||
|
return acc;
|
||||||
|
}, []);
|
||||||
try {
|
try {
|
||||||
const docCls = new Parse.Object("contracts_Document");
|
const docCls = new Parse.Object("contracts_Document");
|
||||||
docCls.id = documentId;
|
docCls.id = documentId;
|
||||||
docCls.set("Placeholders", signerPos);
|
docCls.set("Placeholders", signerPos);
|
||||||
docCls.set("Signers", signers);
|
docCls.set("Signers", signers);
|
||||||
|
docCls.set("SignatureType", signatureType);
|
||||||
await docCls.save();
|
await docCls.save();
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.log("error", e);
|
console.log("error", e);
|
||||||
@@ -964,21 +987,15 @@ function PlaceHolderSign() {
|
|||||||
//filter label widgets after add label widgets data on pdf
|
//filter label widgets after add label widgets data on pdf
|
||||||
const filterPrefill = signerPos.filter((data) => data.Role !== "prefill");
|
const filterPrefill = signerPos.filter((data) => data.Role !== "prefill");
|
||||||
try {
|
try {
|
||||||
|
data = {
|
||||||
|
Placeholders: filterPrefill,
|
||||||
|
SignedUrl: pdfUrl,
|
||||||
|
Signers: signers,
|
||||||
|
SentToOthers: true,
|
||||||
|
SignatureType: pdfDetails?.[0]?.SignatureType
|
||||||
|
};
|
||||||
if (updateExpiryDate) {
|
if (updateExpiryDate) {
|
||||||
data = {
|
data["ExpiryDate"] = { iso: updateExpiryDate, __type: "Date" };
|
||||||
Placeholders: filterPrefill,
|
|
||||||
SignedUrl: pdfUrl,
|
|
||||||
Signers: signers,
|
|
||||||
SentToOthers: true,
|
|
||||||
ExpiryDate: { iso: updateExpiryDate, __type: "Date" }
|
|
||||||
};
|
|
||||||
} else {
|
|
||||||
data = {
|
|
||||||
Placeholders: filterPrefill,
|
|
||||||
SignedUrl: pdfUrl,
|
|
||||||
Signers: signers,
|
|
||||||
SentToOthers: true
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
await axios
|
await axios
|
||||||
.put(
|
.put(
|
||||||
@@ -1330,7 +1347,7 @@ function PlaceHolderSign() {
|
|||||||
isHideLabel: isHideLabel || false,
|
isHideLabel: isHideLabel || false,
|
||||||
defaultValue: defaultValue,
|
defaultValue: defaultValue,
|
||||||
fontSize:
|
fontSize:
|
||||||
fontSize || currWidgetsDetails?.options?.fontSize || "12",
|
fontSize || currWidgetsDetails?.options?.fontSize || 12,
|
||||||
fontColor:
|
fontColor:
|
||||||
fontColor ||
|
fontColor ||
|
||||||
currWidgetsDetails?.options?.fontColor ||
|
currWidgetsDetails?.options?.fontColor ||
|
||||||
@@ -1368,7 +1385,7 @@ function PlaceHolderSign() {
|
|||||||
isReadOnly: isReadOnly || false,
|
isReadOnly: isReadOnly || false,
|
||||||
isHideLabel: isHideLabel || false,
|
isHideLabel: isHideLabel || false,
|
||||||
fontSize:
|
fontSize:
|
||||||
fontSize || currWidgetsDetails?.options?.fontSize || "12",
|
fontSize || currWidgetsDetails?.options?.fontSize || 12,
|
||||||
fontColor:
|
fontColor:
|
||||||
fontColor ||
|
fontColor ||
|
||||||
currWidgetsDetails?.options?.fontColor ||
|
currWidgetsDetails?.options?.fontColor ||
|
||||||
@@ -1386,7 +1403,7 @@ function PlaceHolderSign() {
|
|||||||
values: dropdownOptions,
|
values: dropdownOptions,
|
||||||
defaultValue: defaultValue,
|
defaultValue: defaultValue,
|
||||||
fontSize:
|
fontSize:
|
||||||
fontSize || currWidgetsDetails?.options?.fontSize || "12",
|
fontSize || currWidgetsDetails?.options?.fontSize || 12,
|
||||||
fontColor:
|
fontColor:
|
||||||
fontColor ||
|
fontColor ||
|
||||||
currWidgetsDetails?.options?.fontColor ||
|
currWidgetsDetails?.options?.fontColor ||
|
||||||
@@ -1420,7 +1437,15 @@ function PlaceHolderSign() {
|
|||||||
setFontSize();
|
setFontSize();
|
||||||
setFontColor();
|
setFontColor();
|
||||||
};
|
};
|
||||||
const handleWidgetdefaultdata = (defaultdata) => {
|
const handleWidgetdefaultdata = (defaultdata, isSignWidget) => {
|
||||||
|
if (isSignWidget) {
|
||||||
|
const updatedPdfDetails = [...pdfDetails];
|
||||||
|
const signtypes = defaultdata.signatureType || signatureType;
|
||||||
|
updatedPdfDetails[0].SignatureType = signtypes;
|
||||||
|
// Update the SignatureType with the modified array
|
||||||
|
setPdfDetails(updatedPdfDetails);
|
||||||
|
setSignatureType(signtypes);
|
||||||
|
}
|
||||||
const options = ["email", "number", "text"];
|
const options = ["email", "number", "text"];
|
||||||
let inputype;
|
let inputype;
|
||||||
if (defaultdata.textvalidate) {
|
if (defaultdata.textvalidate) {
|
||||||
@@ -1459,7 +1484,7 @@ function PlaceHolderSign() {
|
|||||||
}
|
}
|
||||||
: {},
|
: {},
|
||||||
fontSize:
|
fontSize:
|
||||||
fontSize || currWidgetsDetails?.options?.fontSize || "12",
|
fontSize || currWidgetsDetails?.options?.fontSize || 12,
|
||||||
fontColor:
|
fontColor:
|
||||||
fontColor ||
|
fontColor ||
|
||||||
currWidgetsDetails?.options?.fontColor ||
|
currWidgetsDetails?.options?.fontColor ||
|
||||||
@@ -1475,7 +1500,7 @@ function PlaceHolderSign() {
|
|||||||
status: defaultdata.status,
|
status: defaultdata.status,
|
||||||
defaultValue: defaultdata.defaultValue,
|
defaultValue: defaultdata.defaultValue,
|
||||||
fontSize:
|
fontSize:
|
||||||
fontSize || currWidgetsDetails?.options?.fontSize || "12",
|
fontSize || currWidgetsDetails?.options?.fontSize || 12,
|
||||||
fontColor:
|
fontColor:
|
||||||
fontColor ||
|
fontColor ||
|
||||||
currWidgetsDetails?.options?.fontColor ||
|
currWidgetsDetails?.options?.fontColor ||
|
||||||
@@ -1541,14 +1566,12 @@ function PlaceHolderSign() {
|
|||||||
} else {
|
} else {
|
||||||
updatedTourStatus = [{ placeholder: true }];
|
updatedTourStatus = [{ placeholder: true }];
|
||||||
}
|
}
|
||||||
await axios
|
try {
|
||||||
.put(
|
await axios.put(
|
||||||
`${localStorage.getItem(
|
`${localStorage.getItem(
|
||||||
"baseUrl"
|
"baseUrl"
|
||||||
)}classes/contracts_Users/${signerUserId}`,
|
)}classes/contracts_Users/${signerUserId}`,
|
||||||
{
|
{ TourStatus: updatedTourStatus },
|
||||||
TourStatus: updatedTourStatus
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
headers: {
|
headers: {
|
||||||
"Content-Type": "application/json",
|
"Content-Type": "application/json",
|
||||||
@@ -1556,14 +1579,10 @@ function PlaceHolderSign() {
|
|||||||
sessionToken: localStorage.getItem("accesstoken")
|
sessionToken: localStorage.getItem("accesstoken")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
)
|
);
|
||||||
.then(() => {
|
} catch (err) {
|
||||||
// const json = Listdata.data;
|
console.log("axois err ", err);
|
||||||
// const res = json.results;
|
}
|
||||||
})
|
|
||||||
.catch((err) => {
|
|
||||||
console.log("axois err ", err);
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
const handleRecipientSign = () => {
|
const handleRecipientSign = () => {
|
||||||
@@ -1648,8 +1667,15 @@ function PlaceHolderSign() {
|
|||||||
const signerAssignTour = [
|
const signerAssignTour = [
|
||||||
{
|
{
|
||||||
selector: '[data-tut="assignSigner"]',
|
selector: '[data-tut="assignSigner"]',
|
||||||
content:
|
content: t("attach-signer-tour"),
|
||||||
"You need to attach a Signer to every role. You can do that by clicking this icon. Once you select a Signer it will be attached to all the fields associated with that role which appear in the same colour. ",
|
position: "top",
|
||||||
|
style: { fontSize: "13px" }
|
||||||
|
}
|
||||||
|
];
|
||||||
|
const textFieldTour = [
|
||||||
|
{
|
||||||
|
selector: '[data-tut="IsSigned"]',
|
||||||
|
content: t("text-field-tour"),
|
||||||
position: "top",
|
position: "top",
|
||||||
style: { fontSize: "13px" }
|
style: { fontSize: "13px" }
|
||||||
}
|
}
|
||||||
@@ -1759,6 +1785,13 @@ function PlaceHolderSign() {
|
|||||||
rounded={5}
|
rounded={5}
|
||||||
closeWithMask={false}
|
closeWithMask={false}
|
||||||
/>
|
/>
|
||||||
|
<Tour
|
||||||
|
onRequestClose={() => setIsSendAlert({})}
|
||||||
|
steps={textFieldTour}
|
||||||
|
isOpen={isSendAlert.mssg === textWidget}
|
||||||
|
rounded={5}
|
||||||
|
closeWithMask={false}
|
||||||
|
/>
|
||||||
{/* this component used to render all pdf pages in left side */}
|
{/* this component used to render all pdf pages in left side */}
|
||||||
<RenderAllPdfPage
|
<RenderAllPdfPage
|
||||||
signPdfUrl={pdfDetails[0].URL}
|
signPdfUrl={pdfDetails[0].URL}
|
||||||
@@ -1779,20 +1812,18 @@ function PlaceHolderSign() {
|
|||||||
<div className=" w-full md:w-[95%] ">
|
<div className=" w-full md:w-[95%] ">
|
||||||
{/* this modal is used show alert set placeholder for all signers before send mail */}
|
{/* this modal is used show alert set placeholder for all signers before send mail */}
|
||||||
<ModalUi
|
<ModalUi
|
||||||
isOpen={isSendAlert.alert}
|
isOpen={
|
||||||
|
isSendAlert.alert && isSendAlert.mssg !== textWidget
|
||||||
|
}
|
||||||
title={
|
title={
|
||||||
isSendAlert.mssg === "sure" ||
|
isSendAlert.mssg === "sure" ||
|
||||||
isSendAlert.mssg === textWidget
|
(isSendAlert.mssg === "confirm" && t("send-mail"))
|
||||||
? t("fields-required")
|
|
||||||
: isSendAlert.mssg === "confirm" && t("send-mail")
|
|
||||||
}
|
}
|
||||||
handleClose={() => handleCloseSendmailModal()}
|
handleClose={() => handleCloseSendmailModal()}
|
||||||
>
|
>
|
||||||
<div className="max-h-96 overflow-y-scroll scroll-hide p-[20px] text-base-content">
|
<div className="max-h-96 overflow-y-scroll scroll-hide p-[20px] text-base-content">
|
||||||
{isSendAlert.mssg === "sure" ? (
|
{isSendAlert.mssg === "sure" ? (
|
||||||
<span>{t("placeholder-alert-1")}</span>
|
<span>{t("placeholder-alert-1")}</span>
|
||||||
) : isSendAlert.mssg === textWidget ? (
|
|
||||||
<p>{t("placeholder-alert-2")}</p>
|
|
||||||
) : (
|
) : (
|
||||||
isSendAlert.mssg === "confirm" && (
|
isSendAlert.mssg === "confirm" && (
|
||||||
<>
|
<>
|
||||||
@@ -1873,9 +1904,11 @@ function PlaceHolderSign() {
|
|||||||
<ModalUi
|
<ModalUi
|
||||||
isOpen={isSend}
|
isOpen={isSend}
|
||||||
title={
|
title={
|
||||||
mailStatus === "quotareached"
|
mailStatus === "success"
|
||||||
? t("quota-mail-head")
|
? t("mails-sent")
|
||||||
: t("Mails Sent")
|
: mailStatus === "quotareached"
|
||||||
|
? t("quota-mail-head")
|
||||||
|
: t("mail-not-delivered")
|
||||||
}
|
}
|
||||||
handleClose={() => {
|
handleClose={() => {
|
||||||
setIsSend(false);
|
setIsSend(false);
|
||||||
@@ -1902,7 +1935,12 @@ function PlaceHolderSign() {
|
|||||||
<div className="my-3">{handleShareList()}</div>
|
<div className="my-3">{handleShareList()}</div>
|
||||||
</div>
|
</div>
|
||||||
) : (
|
) : (
|
||||||
<p>{t("placeholder-alert-6")}</p>
|
<div className="mb-[10px]">
|
||||||
|
<p>{t("placeholder-alert-6")}</p>
|
||||||
|
{isCurrUser && (
|
||||||
|
<p className="mt-1">{t("placeholder-alert-5")}</p>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
)}
|
)}
|
||||||
{!mailStatus && (
|
{!mailStatus && (
|
||||||
<div className="w-full h-[1px] bg-[#9f9f9f] my-[15px]"></div>
|
<div className="w-full h-[1px] bg-[#9f9f9f] my-[15px]"></div>
|
||||||
@@ -2018,6 +2056,7 @@ function PlaceHolderSign() {
|
|||||||
|
|
||||||
{/* pdf header which contain funish back button */}
|
{/* pdf header which contain funish back button */}
|
||||||
<Header
|
<Header
|
||||||
|
completeBtnTitle={t("next")}
|
||||||
isPlaceholder={true}
|
isPlaceholder={true}
|
||||||
pageNumber={pageNumber}
|
pageNumber={pageNumber}
|
||||||
allPages={allPages}
|
allPages={allPages}
|
||||||
@@ -2085,6 +2124,7 @@ function PlaceHolderSign() {
|
|||||||
setFontSize={setFontSize}
|
setFontSize={setFontSize}
|
||||||
fontColor={fontColor}
|
fontColor={fontColor}
|
||||||
setFontColor={setFontColor}
|
setFontColor={setFontColor}
|
||||||
|
unSignedWidgetId={unSignedWidgetId}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
@@ -2209,6 +2249,7 @@ function PlaceHolderSign() {
|
|||||||
signersData={signersdata}
|
signersData={signersdata}
|
||||||
/>
|
/>
|
||||||
<WidgetNameModal
|
<WidgetNameModal
|
||||||
|
signatureType={signatureType}
|
||||||
widgetName={widgetName}
|
widgetName={widgetName}
|
||||||
defaultdata={currWidgetsDetails}
|
defaultdata={currWidgetsDetails}
|
||||||
isOpen={isNameModal}
|
isOpen={isNameModal}
|
||||||
|
|||||||
@@ -0,0 +1,218 @@
|
|||||||
|
import React, { useEffect, useState } from "react";
|
||||||
|
import Title from "../components/Title";
|
||||||
|
import Alert from "../primitives/Alert";
|
||||||
|
import { useTranslation } from "react-i18next";
|
||||||
|
import Loader from "../primitives/Loader";
|
||||||
|
import Tooltip from "../primitives/Tooltip";
|
||||||
|
import {
|
||||||
|
getTenantDetails,
|
||||||
|
handleSignatureType,
|
||||||
|
signatureTypes
|
||||||
|
} from "../constant/Utils";
|
||||||
|
import Parse from "parse";
|
||||||
|
import { Tooltip as ReactTooltip } from "react-tooltip";
|
||||||
|
const Preferences = () => {
|
||||||
|
const { t } = useTranslation();
|
||||||
|
const [isalert, setIsAlert] = useState({ type: "success", msg: "" });
|
||||||
|
const [isTopLoader, setIsTopLoader] = useState(false);
|
||||||
|
const [isLoader, setIsLoader] = useState(false);
|
||||||
|
const [signatureType, setSignatureType] = useState([]);
|
||||||
|
const [errMsg, setErrMsg] = useState("");
|
||||||
|
useEffect(() => {
|
||||||
|
fetchSignType();
|
||||||
|
}, []);
|
||||||
|
|
||||||
|
const fetchSignType = async () => {
|
||||||
|
setIsTopLoader(true);
|
||||||
|
try {
|
||||||
|
const user = JSON.parse(
|
||||||
|
localStorage.getItem(
|
||||||
|
`Parse/${localStorage.getItem("parseAppId")}/currentUser`
|
||||||
|
)
|
||||||
|
);
|
||||||
|
const tenantDetails = await getTenantDetails(user?.objectId);
|
||||||
|
const signatureType = tenantDetails?.SignatureType || [];
|
||||||
|
const tenantSignTypes = signatureType?.filter((x) => x.enabled === true);
|
||||||
|
const getUser = await Parse.Cloud.run("getUserDetails");
|
||||||
|
if (getUser) {
|
||||||
|
const _getUser = JSON.parse(JSON.stringify(getUser));
|
||||||
|
if (tenantSignTypes?.length > 0) {
|
||||||
|
const signatureType = _getUser?.SignatureType || signatureTypes;
|
||||||
|
const updatedSignatureType = await handleSignatureType(
|
||||||
|
tenantSignTypes,
|
||||||
|
signatureType
|
||||||
|
);
|
||||||
|
setSignatureType(updatedSignatureType);
|
||||||
|
} else {
|
||||||
|
const SignatureType = _getUser?.SignatureType || signatureTypes;
|
||||||
|
setSignatureType(SignatureType);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (err) {
|
||||||
|
console.log("err while getting user details", err);
|
||||||
|
setErrMsg("Something went wrong");
|
||||||
|
} finally {
|
||||||
|
setIsTopLoader(false);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
// `handleCheckboxChange` is trigger when user enable/disable checkbox of respective type
|
||||||
|
const handleCheckboxChange = (index) => {
|
||||||
|
// Create a copy of the signatureType array
|
||||||
|
const updatedSignatureType = [...signatureType];
|
||||||
|
// Toggle the enabled value for the clicked item
|
||||||
|
updatedSignatureType[index].enabled = !updatedSignatureType[index].enabled;
|
||||||
|
// Update the state with the modified array
|
||||||
|
setSignatureType(updatedSignatureType);
|
||||||
|
};
|
||||||
|
|
||||||
|
// `handleSave` is used save updated value signature type
|
||||||
|
const handleSave = async () => {
|
||||||
|
setIsLoader(true);
|
||||||
|
const enabledSignTypes = signatureType?.filter((x) => x.enabled);
|
||||||
|
const isDefaultSignTypeOnly =
|
||||||
|
enabledSignTypes?.length === 1 && enabledSignTypes[0]?.name === "default";
|
||||||
|
if (enabledSignTypes.length === 0) {
|
||||||
|
setIsAlert({
|
||||||
|
type: "danger",
|
||||||
|
msg: t("at-least-one-signature-type")
|
||||||
|
});
|
||||||
|
} else if (isDefaultSignTypeOnly) {
|
||||||
|
setIsAlert({
|
||||||
|
type: "danger",
|
||||||
|
msg: t("expect-default-one-more-signature-type")
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
try {
|
||||||
|
const updateRes = await Parse.Cloud.run("updatesignaturetype", {
|
||||||
|
SignatureType: signatureType
|
||||||
|
});
|
||||||
|
if (updateRes) {
|
||||||
|
setIsAlert({ type: "success", msg: "Saved successfully." });
|
||||||
|
}
|
||||||
|
} catch (err) {
|
||||||
|
console.log("Error updating signature type", err);
|
||||||
|
setIsAlert({ type: "danger", msg: err.message });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
setTimeout(() => setIsAlert({ type: "success", msg: "" }), 1500);
|
||||||
|
setIsLoader(false);
|
||||||
|
};
|
||||||
|
|
||||||
|
return (
|
||||||
|
<React.Fragment>
|
||||||
|
<Title title={"API Token"} />
|
||||||
|
{isalert.msg && <Alert type={isalert.type}>{isalert.msg}</Alert>}
|
||||||
|
{isTopLoader ? (
|
||||||
|
<div className="flex justify-center items-center h-screen">
|
||||||
|
<Loader />
|
||||||
|
</div>
|
||||||
|
) : (
|
||||||
|
<>
|
||||||
|
{errMsg ? (
|
||||||
|
<div className="flex justify-center items-center h-screen">
|
||||||
|
{errMsg}
|
||||||
|
</div>
|
||||||
|
) : (
|
||||||
|
<div className="relative bg-base-100 text-base-content flex flex-col justify-center shadow-md rounded-box mb-3">
|
||||||
|
{isLoader && (
|
||||||
|
<div className="flex justify-center items-center absolute w-full h-full rounded-box bg-black/30">
|
||||||
|
<Loader />
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
<h1 className="ml-4 mt-3 mb-2 font-semibold">
|
||||||
|
OpenSign™ {t("Preferences")}{" "}
|
||||||
|
<span>
|
||||||
|
<Tooltip
|
||||||
|
message={`OpenSign™ ${t("Preferences")}`}
|
||||||
|
isSubscribe={true}
|
||||||
|
/>
|
||||||
|
</span>
|
||||||
|
</h1>
|
||||||
|
<div className="ml-4 mt-1 mb-2 flex flex-col">
|
||||||
|
<div className="mb-[0.75rem]">
|
||||||
|
<label
|
||||||
|
htmlFor="signaturetype"
|
||||||
|
className="text-[14px] mb-[0.7rem] font-medium"
|
||||||
|
>
|
||||||
|
{t("allowed-signature-types")}
|
||||||
|
<a data-tooltip-id="signtypes-tooltip" className="ml-1">
|
||||||
|
<sup>
|
||||||
|
<i className="fa-light fa-question rounded-full border-[#33bbff] text-[#33bbff] text-[13px] border-[1px] py-[1.5px] px-[4px]"></i>
|
||||||
|
</sup>
|
||||||
|
</a>
|
||||||
|
<ReactTooltip id="signtypes-tooltip" className="z-[999]">
|
||||||
|
<div className="max-w-[200px] md:max-w-[450px] text-[11px]">
|
||||||
|
<p className="font-bold">
|
||||||
|
{t("allowed-signature-types")}
|
||||||
|
</p>
|
||||||
|
<p>{t("allowed-signature-types-help.p1")}</p>
|
||||||
|
<p className="p-[5px] ml-2">
|
||||||
|
<ol className="list-disc">
|
||||||
|
<li>
|
||||||
|
<span className="font-bold">Draw: </span>
|
||||||
|
<span>
|
||||||
|
{t("allowed-signature-types-help.l1")}
|
||||||
|
</span>
|
||||||
|
</li>
|
||||||
|
<li>
|
||||||
|
<span className="font-bold">Typed: </span>
|
||||||
|
<span>
|
||||||
|
{t("allowed-signature-types-help.l2")}
|
||||||
|
</span>
|
||||||
|
</li>
|
||||||
|
<li>
|
||||||
|
<span className="font-bold">Upload: </span>
|
||||||
|
<span>
|
||||||
|
{t("allowed-signature-types-help.l3")}
|
||||||
|
</span>
|
||||||
|
</li>
|
||||||
|
<li>
|
||||||
|
<span className="font-bold">Default: </span>
|
||||||
|
<span>
|
||||||
|
{t("allowed-signature-types-help.l4")}
|
||||||
|
</span>
|
||||||
|
</li>
|
||||||
|
</ol>
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
</ReactTooltip>
|
||||||
|
</label>
|
||||||
|
<div className=" ml-[7px] flex flex-col md:flex-row gap-[10px] mb-[0.7rem]">
|
||||||
|
{signatureType.map((type, i) => (
|
||||||
|
<div
|
||||||
|
key={i}
|
||||||
|
className="flex flex-row gap-[5px] items-center"
|
||||||
|
>
|
||||||
|
<input
|
||||||
|
className="mr-[2px] op-checkbox op-checkbox-xs"
|
||||||
|
type="checkbox"
|
||||||
|
name="signaturetype"
|
||||||
|
onChange={() => handleCheckboxChange(i)}
|
||||||
|
checked={type.enabled}
|
||||||
|
/>
|
||||||
|
<div
|
||||||
|
className="text-[13px] font-medium hover:underline underline-offset-2 cursor-default capitalize"
|
||||||
|
title={`Enabling this allow signers to ${type.name} signature`}
|
||||||
|
>
|
||||||
|
{type.name}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
))}
|
||||||
|
</div>
|
||||||
|
<button
|
||||||
|
className="op-btn op-btn-primary"
|
||||||
|
onClick={handleSave}
|
||||||
|
>
|
||||||
|
Save
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
</>
|
||||||
|
)}
|
||||||
|
</React.Fragment>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
export default Preferences;
|
||||||
@@ -10,7 +10,7 @@ import { appInfo } from "../constant/appinfo";
|
|||||||
import { useDispatch } from "react-redux";
|
import { useDispatch } from "react-redux";
|
||||||
import { fetchAppInfo } from "../redux/reducers/infoReducer";
|
import { fetchAppInfo } from "../redux/reducers/infoReducer";
|
||||||
import { showTenant } from "../redux/reducers/ShowTenant";
|
import { showTenant } from "../redux/reducers/ShowTenant";
|
||||||
import { isEnableSubscription } from "../constant/const";
|
import { emailRegex, isEnableSubscription } from "../constant/const";
|
||||||
import {
|
import {
|
||||||
getAppLogo,
|
getAppLogo,
|
||||||
openInNewTab,
|
openInNewTab,
|
||||||
@@ -83,92 +83,96 @@ const Signup = () => {
|
|||||||
};
|
};
|
||||||
const handleSubmit = (event) => {
|
const handleSubmit = (event) => {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
if (lengthValid && caseDigitValid && specialCharValid) {
|
if (!emailRegex.test(email)) {
|
||||||
clearStorage();
|
alert("Please enter a valid email address.");
|
||||||
setState({ loading: true });
|
} else {
|
||||||
const userDetails = {
|
if (lengthValid && caseDigitValid && specialCharValid) {
|
||||||
name: name,
|
clearStorage();
|
||||||
email: email,
|
setState({ loading: true });
|
||||||
phone: phone,
|
const userDetails = {
|
||||||
company: company,
|
name: name,
|
||||||
jobTitle: jobTitle
|
email: email,
|
||||||
};
|
phone: phone,
|
||||||
localStorage.setItem("userDetails", JSON.stringify(userDetails));
|
company: company,
|
||||||
try {
|
jobTitle: jobTitle
|
||||||
event.preventDefault();
|
};
|
||||||
var user = new Parse.User();
|
localStorage.setItem("userDetails", JSON.stringify(userDetails));
|
||||||
user.set("name", name);
|
try {
|
||||||
user.set("email", email);
|
event.preventDefault();
|
||||||
user.set("password", password);
|
var user = new Parse.User();
|
||||||
user.set("phone", phone);
|
user.set("name", name);
|
||||||
user.set("username", email);
|
user.set("email", email);
|
||||||
let res = user.save();
|
user.set("password", password);
|
||||||
res
|
user.set("phone", phone);
|
||||||
.then(async (r) => {
|
user.set("username", email);
|
||||||
if (r) {
|
let res = user.save();
|
||||||
let roleData = appInfo.settings;
|
res
|
||||||
if (roleData && roleData.length > 0) {
|
.then(async (r) => {
|
||||||
const params = {
|
if (r) {
|
||||||
userDetails: {
|
let roleData = appInfo.settings;
|
||||||
jobTitle: jobTitle,
|
if (roleData && roleData.length > 0) {
|
||||||
company: company,
|
const params = {
|
||||||
name: name,
|
userDetails: {
|
||||||
email: email,
|
jobTitle: jobTitle,
|
||||||
phone: phone,
|
company: company,
|
||||||
role: appInfo.defaultRole
|
name: name,
|
||||||
}
|
email: email,
|
||||||
};
|
phone: phone,
|
||||||
try {
|
role: appInfo.defaultRole
|
||||||
const usersignup = await Parse.Cloud.run(
|
|
||||||
"usersignup",
|
|
||||||
params
|
|
||||||
);
|
|
||||||
if (usersignup) {
|
|
||||||
const param = new URLSearchParams(location.search);
|
|
||||||
const isFreeplan =
|
|
||||||
param?.get("subscription") === "freeplan";
|
|
||||||
if (isFreeplan) {
|
|
||||||
await handleFreePlan(r.id);
|
|
||||||
}
|
}
|
||||||
handleNavigation(r.getSessionToken(), isFreeplan);
|
};
|
||||||
|
try {
|
||||||
|
const usersignup = await Parse.Cloud.run(
|
||||||
|
"usersignup",
|
||||||
|
params
|
||||||
|
);
|
||||||
|
if (usersignup) {
|
||||||
|
const param = new URLSearchParams(location.search);
|
||||||
|
const isFreeplan =
|
||||||
|
param?.get("subscription") === "freeplan";
|
||||||
|
if (isFreeplan) {
|
||||||
|
await handleFreePlan(r.id);
|
||||||
|
}
|
||||||
|
handleNavigation(r.getSessionToken(), isFreeplan);
|
||||||
|
}
|
||||||
|
} catch (err) {
|
||||||
|
alert(err.message);
|
||||||
|
setState({ loading: false });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.catch(async (err) => {
|
||||||
|
if (err.code === 202) {
|
||||||
|
const params = { email: email };
|
||||||
|
const res = await Parse.Cloud.run("getUserDetails", params);
|
||||||
|
// console.log("Res ", res);
|
||||||
|
if (res) {
|
||||||
|
alert(t("user-already-exist-name"));
|
||||||
|
setState({ loading: false });
|
||||||
|
} else {
|
||||||
|
// console.log("state.email ", email);
|
||||||
|
try {
|
||||||
|
await Parse.User.requestPasswordReset(email).then(
|
||||||
|
async function (res1) {
|
||||||
|
if (res1.data === undefined) {
|
||||||
|
alert(t("verification-code-sent"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
} catch (err) {
|
||||||
|
console.log(err);
|
||||||
}
|
}
|
||||||
} catch (err) {
|
|
||||||
alert(err.message);
|
|
||||||
setState({ loading: false });
|
setState({ loading: false });
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
})
|
|
||||||
.catch(async (err) => {
|
|
||||||
if (err.code === 202) {
|
|
||||||
const params = { email: email };
|
|
||||||
const res = await Parse.Cloud.run("getUserDetails", params);
|
|
||||||
// console.log("Res ", res);
|
|
||||||
if (res) {
|
|
||||||
alert(t("user-already-exist-name"));
|
|
||||||
setState({ loading: false });
|
|
||||||
} else {
|
} else {
|
||||||
// console.log("state.email ", email);
|
alert(err.message);
|
||||||
try {
|
|
||||||
await Parse.User.requestPasswordReset(email).then(
|
|
||||||
async function (res1) {
|
|
||||||
if (res1.data === undefined) {
|
|
||||||
alert(t("verification-code-sent"));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
);
|
|
||||||
} catch (err) {
|
|
||||||
console.log(err);
|
|
||||||
}
|
|
||||||
setState({ loading: false });
|
setState({ loading: false });
|
||||||
}
|
}
|
||||||
} else {
|
});
|
||||||
alert(err.message);
|
} catch (error) {
|
||||||
setState({ loading: false });
|
console.log("err ", error);
|
||||||
}
|
}
|
||||||
});
|
|
||||||
} catch (error) {
|
|
||||||
console.log("err ", error);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -36,7 +36,8 @@ import {
|
|||||||
getDefaultSignature,
|
getDefaultSignature,
|
||||||
onClickZoomIn,
|
onClickZoomIn,
|
||||||
onClickZoomOut,
|
onClickZoomOut,
|
||||||
rotatePdfPage
|
rotatePdfPage,
|
||||||
|
signatureTypes
|
||||||
} from "../constant/Utils";
|
} from "../constant/Utils";
|
||||||
import { useParams } from "react-router-dom";
|
import { useParams } from "react-router-dom";
|
||||||
import Tour from "reactour";
|
import Tour from "reactour";
|
||||||
@@ -424,9 +425,7 @@ function SignYourSelf() {
|
|||||||
const getWidth = widgetTypeExist
|
const getWidth = widgetTypeExist
|
||||||
? calculateInitialWidthHeight(dragTypeValue, widgetValue).getWidth
|
? calculateInitialWidthHeight(dragTypeValue, widgetValue).getWidth
|
||||||
: defaultWidthHeight(dragTypeValue).width;
|
: defaultWidthHeight(dragTypeValue).width;
|
||||||
const getHeight = widgetTypeExist
|
const getHeight = defaultWidthHeight(dragTypeValue).height;
|
||||||
? calculateInitialWidthHeight(dragTypeValue, widgetValue).getHeight
|
|
||||||
: defaultWidthHeight(dragTypeValue).height;
|
|
||||||
|
|
||||||
dropObj = {
|
dropObj = {
|
||||||
xPosition: getWidth / 2 + containerWH.width / 2,
|
xPosition: getWidth / 2 + containerWH.width / 2,
|
||||||
@@ -457,9 +456,7 @@ function SignYourSelf() {
|
|||||||
const getWidth = widgetTypeExist
|
const getWidth = widgetTypeExist
|
||||||
? calculateInitialWidthHeight(widgetValue).getWidth
|
? calculateInitialWidthHeight(widgetValue).getWidth
|
||||||
: defaultWidthHeight(dragTypeValue).width;
|
: defaultWidthHeight(dragTypeValue).width;
|
||||||
const getHeight = widgetTypeExist
|
const getHeight = defaultWidthHeight(dragTypeValue).height;
|
||||||
? calculateInitialWidthHeight(widgetValue).getHeight
|
|
||||||
: defaultWidthHeight(dragTypeValue).height;
|
|
||||||
dropObj = {
|
dropObj = {
|
||||||
xPosition: getXPosition / (containerScale * scale),
|
xPosition: getXPosition / (containerScale * scale),
|
||||||
yPosition: getYPosition / (containerScale * scale),
|
yPosition: getYPosition / (containerScale * scale),
|
||||||
@@ -661,9 +658,7 @@ function SignYourSelf() {
|
|||||||
xyPostion,
|
xyPostion,
|
||||||
pdfDoc,
|
pdfDoc,
|
||||||
isSignYourSelfFlow,
|
isSignYourSelfFlow,
|
||||||
scale,
|
scale
|
||||||
pdfOriginalWH,
|
|
||||||
containerWH
|
|
||||||
);
|
);
|
||||||
// console.log("pdf", pdfBytes);
|
// console.log("pdf", pdfBytes);
|
||||||
//function for call to embed signature in pdf and get digital signature pdf
|
//function for call to embed signature in pdf and get digital signature pdf
|
||||||
@@ -687,10 +682,7 @@ function SignYourSelf() {
|
|||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
console.log("err in signing", err.message);
|
console.log("err in signing", err.message);
|
||||||
if (
|
if (err?.message?.includes("password")) {
|
||||||
err.message ===
|
|
||||||
"PKCS#12 MAC could not be verified. Invalid password?"
|
|
||||||
) {
|
|
||||||
setIsAlert({
|
setIsAlert({
|
||||||
header: t("error"),
|
header: t("error"),
|
||||||
isShow: true,
|
isShow: true,
|
||||||
@@ -757,10 +749,10 @@ function SignYourSelf() {
|
|||||||
alert(t("something-went-wrong-mssg"));
|
alert(t("something-went-wrong-mssg"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//change image width and height to 100/40 in png base64
|
//change image width and height to 300/120 in png base64
|
||||||
const getNewse64 = await changeImageWH(base64Sign);
|
const imagebase64 = await changeImageWH(base64Sign);
|
||||||
//remove suffiix of base64
|
//remove suffiix of base64 (without type)
|
||||||
const suffixbase64 = getNewse64 && getNewse64.split(",").pop();
|
const suffixbase64 = imagebase64 && imagebase64.split(",").pop();
|
||||||
const params = {
|
const params = {
|
||||||
pdfFile: base64Url,
|
pdfFile: base64Url,
|
||||||
docId: documentId,
|
docId: documentId,
|
||||||
@@ -1031,7 +1023,6 @@ function SignYourSelf() {
|
|||||||
const getPageNumer = xyPostion.filter(
|
const getPageNumer = xyPostion.filter(
|
||||||
(data) => data.pageNumber === pageNumber
|
(data) => data.pageNumber === pageNumber
|
||||||
);
|
);
|
||||||
|
|
||||||
if (getPageNumer.length > 0) {
|
if (getPageNumer.length > 0) {
|
||||||
const getXYdata = getPageNumer[0].pos;
|
const getXYdata = getPageNumer[0].pos;
|
||||||
const getPosData = getXYdata;
|
const getPosData = getXYdata;
|
||||||
@@ -1061,7 +1052,7 @@ function SignYourSelf() {
|
|||||||
isReadOnly: isReadOnly,
|
isReadOnly: isReadOnly,
|
||||||
isHideLabel: isHideLabel || false,
|
isHideLabel: isHideLabel || false,
|
||||||
fontSize:
|
fontSize:
|
||||||
fontSize || currWidgetsDetails?.options?.fontSize || "12",
|
fontSize || currWidgetsDetails?.options?.fontSize || 12,
|
||||||
fontColor:
|
fontColor:
|
||||||
fontColor || currWidgetsDetails?.options?.fontColor || "black"
|
fontColor || currWidgetsDetails?.options?.fontColor || "black"
|
||||||
}
|
}
|
||||||
@@ -1095,7 +1086,6 @@ function SignYourSelf() {
|
|||||||
const getPageNumer = xyPostion.filter(
|
const getPageNumer = xyPostion.filter(
|
||||||
(data) => data.pageNumber === pageNumber
|
(data) => data.pageNumber === pageNumber
|
||||||
);
|
);
|
||||||
|
|
||||||
if (getPageNumer.length > 0) {
|
if (getPageNumer.length > 0) {
|
||||||
const getXYdata = getPageNumer[0].pos;
|
const getXYdata = getPageNumer[0].pos;
|
||||||
const getPosData = getXYdata;
|
const getPosData = getXYdata;
|
||||||
@@ -1105,8 +1095,7 @@ function SignYourSelf() {
|
|||||||
...position,
|
...position,
|
||||||
options: {
|
options: {
|
||||||
...position.options,
|
...position.options,
|
||||||
fontSize:
|
fontSize: fontSize || currWidgetsDetails?.options?.fontSize || 12,
|
||||||
fontSize || currWidgetsDetails?.options?.fontSize || "12",
|
|
||||||
fontColor:
|
fontColor:
|
||||||
fontColor || currWidgetsDetails?.options?.fontColor || "black"
|
fontColor || currWidgetsDetails?.options?.fontColor || "black"
|
||||||
}
|
}
|
||||||
@@ -1305,6 +1294,7 @@ function SignYourSelf() {
|
|||||||
/>
|
/>
|
||||||
{/* this is modal of signature pad */}
|
{/* this is modal of signature pad */}
|
||||||
<SignPad
|
<SignPad
|
||||||
|
signatureTypes={signatureTypes}
|
||||||
isSignPad={isSignPad}
|
isSignPad={isSignPad}
|
||||||
isStamp={isStamp}
|
isStamp={isStamp}
|
||||||
setIsImageSelect={setIsImageSelect}
|
setIsImageSelect={setIsImageSelect}
|
||||||
|
|||||||
@@ -29,7 +29,11 @@ import {
|
|||||||
onClickZoomOut,
|
onClickZoomOut,
|
||||||
onClickZoomIn,
|
onClickZoomIn,
|
||||||
handleRemoveWidgets,
|
handleRemoveWidgets,
|
||||||
handleRotateWarning
|
handleRotateWarning,
|
||||||
|
color,
|
||||||
|
signatureTypes,
|
||||||
|
getTenantDetails,
|
||||||
|
handleSignatureType
|
||||||
} from "../constant/Utils";
|
} from "../constant/Utils";
|
||||||
import RenderPdf from "../components/pdf/RenderPdf";
|
import RenderPdf from "../components/pdf/RenderPdf";
|
||||||
import "../styles/AddUser.css";
|
import "../styles/AddUser.css";
|
||||||
@@ -68,10 +72,7 @@ const TemplatePlaceholder = () => {
|
|||||||
const [isSendAlert, setIsSendAlert] = useState(false);
|
const [isSendAlert, setIsSendAlert] = useState(false);
|
||||||
const [isCreateDocModal, setIsCreateDocModal] = useState(false);
|
const [isCreateDocModal, setIsCreateDocModal] = useState(false);
|
||||||
const [isSubscribe, setIsSubscribe] = useState(false);
|
const [isSubscribe, setIsSubscribe] = useState(false);
|
||||||
const [isRotate, setIsRotate] = useState({
|
const [isRotate, setIsRotate] = useState({ status: false, degree: 0 });
|
||||||
status: false,
|
|
||||||
degree: 0
|
|
||||||
});
|
|
||||||
const [isLoading, setIsLoading] = useState({
|
const [isLoading, setIsLoading] = useState({
|
||||||
isLoad: true,
|
isLoad: true,
|
||||||
message: t("loading-mssg")
|
message: t("loading-mssg")
|
||||||
@@ -102,50 +103,21 @@ const TemplatePlaceholder = () => {
|
|||||||
const [isTextSetting, setIsTextSetting] = useState(false);
|
const [isTextSetting, setIsTextSetting] = useState(false);
|
||||||
const [pdfLoad, setPdfLoad] = useState(false);
|
const [pdfLoad, setPdfLoad] = useState(false);
|
||||||
const [pdfRotateBase64, setPdfRotatese64] = useState("");
|
const [pdfRotateBase64, setPdfRotatese64] = useState("");
|
||||||
const color = [
|
|
||||||
"#93a3db",
|
|
||||||
"#e6c3db",
|
|
||||||
"#c0e3bc",
|
|
||||||
"#bce3db",
|
|
||||||
"#b8ccdb",
|
|
||||||
"#ceb8db",
|
|
||||||
"#ffccff",
|
|
||||||
"#99ffcc",
|
|
||||||
"#cc99ff",
|
|
||||||
"#ffcc99",
|
|
||||||
"#66ccff",
|
|
||||||
"#ffffcc"
|
|
||||||
];
|
|
||||||
const isMobile = window.innerWidth < 767;
|
const isMobile = window.innerWidth < 767;
|
||||||
const [, drop] = useDrop({
|
const [, drop] = useDrop({
|
||||||
accept: "BOX",
|
accept: "BOX",
|
||||||
drop: (item, monitor) => addPositionOfSignature(item, monitor),
|
drop: (item, monitor) => addPositionOfSignature(item, monitor),
|
||||||
collect: (monitor) => ({
|
collect: (monitor) => ({ isOver: !!monitor.isOver() })
|
||||||
isOver: !!monitor.isOver()
|
|
||||||
})
|
|
||||||
});
|
});
|
||||||
const [{ isDragSign }, dragSignature] = useDrag({
|
const [{ isDragSign }, dragSignature] = useDrag({
|
||||||
type: "BOX",
|
type: "BOX",
|
||||||
item: {
|
item: { type: "BOX", id: 1, text: "signature" },
|
||||||
type: "BOX",
|
collect: (monitor) => ({ isDragSign: !!monitor.isDragging() })
|
||||||
id: 1,
|
|
||||||
text: "signature"
|
|
||||||
},
|
|
||||||
collect: (monitor) => ({
|
|
||||||
isDragSign: !!monitor.isDragging()
|
|
||||||
})
|
|
||||||
});
|
});
|
||||||
const [{ isDragStamp }, dragStamp] = useDrag({
|
const [{ isDragStamp }, dragStamp] = useDrag({
|
||||||
type: "BOX",
|
type: "BOX",
|
||||||
|
item: { type: "BOX", id: 2, text: "stamp" },
|
||||||
item: {
|
collect: (monitor) => ({ isDragStamp: !!monitor.isDragging() })
|
||||||
type: "BOX",
|
|
||||||
id: 2,
|
|
||||||
text: "stamp"
|
|
||||||
},
|
|
||||||
collect: (monitor) => ({
|
|
||||||
isDragStamp: !!monitor.isDragging()
|
|
||||||
})
|
|
||||||
});
|
});
|
||||||
const [uniqueId, setUniqueId] = useState("");
|
const [uniqueId, setUniqueId] = useState("");
|
||||||
const [isModalRole, setIsModalRole] = useState(false);
|
const [isModalRole, setIsModalRole] = useState(false);
|
||||||
@@ -166,6 +138,7 @@ const TemplatePlaceholder = () => {
|
|||||||
const [fontColor, setFontColor] = useState();
|
const [fontColor, setFontColor] = useState();
|
||||||
const [zoomPercent, setZoomPercent] = useState(0);
|
const [zoomPercent, setZoomPercent] = useState(0);
|
||||||
const [scale, setScale] = useState(1);
|
const [scale, setScale] = useState(1);
|
||||||
|
const [signatureType, setSignatureType] = useState([]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
fetchTemplate();
|
fetchTemplate();
|
||||||
@@ -213,9 +186,38 @@ const TemplatePlaceholder = () => {
|
|||||||
handleNavigation(plan);
|
handleNavigation(plan);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//function to fetch tenant Details
|
||||||
|
const fetchTenantDetails = async () => {
|
||||||
|
const user = JSON.parse(
|
||||||
|
localStorage.getItem(
|
||||||
|
`Parse/${localStorage.getItem("parseAppId")}/currentUser`
|
||||||
|
)
|
||||||
|
);
|
||||||
|
if (user) {
|
||||||
|
try {
|
||||||
|
const tenantDetails = await getTenantDetails(user?.objectId);
|
||||||
|
if (tenantDetails && tenantDetails === "user does not exist!") {
|
||||||
|
alert(t("user-not-exist"));
|
||||||
|
} else if (tenantDetails) {
|
||||||
|
const signatureType = tenantDetails?.SignatureType || [];
|
||||||
|
const filterSignTypes = signatureType?.filter(
|
||||||
|
(x) => x.enabled === true
|
||||||
|
);
|
||||||
|
return filterSignTypes;
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
alert(t("user-not-exist"));
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
alert(t("user-not-exist"));
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
// `fetchTemplate` function in used to get Template from server and setPlaceholder ,setSigner if present
|
// `fetchTemplate` function in used to get Template from server and setPlaceholder ,setSigner if present
|
||||||
const fetchTemplate = async () => {
|
const fetchTemplate = async () => {
|
||||||
try {
|
try {
|
||||||
|
const tenantSignTypes = await fetchTenantDetails();
|
||||||
const params = { templateId: templateId };
|
const params = { templateId: templateId };
|
||||||
const templateDeatils = await axios.post(
|
const templateDeatils = await axios.post(
|
||||||
`${localStorage.getItem("baseUrl")}functions/getTemplate`,
|
`${localStorage.getItem("baseUrl")}functions/getTemplate`,
|
||||||
@@ -237,7 +239,18 @@ const TemplatePlaceholder = () => {
|
|||||||
if (isEnableSubscription) {
|
if (isEnableSubscription) {
|
||||||
checkIsSubscribed(documentData[0]?.ExtUserPtr?.Email);
|
checkIsSubscribed(documentData[0]?.ExtUserPtr?.Email);
|
||||||
}
|
}
|
||||||
setPdfDetails(documentData);
|
const userSignatureType =
|
||||||
|
documentData[0]?.ExtUserPtr?.SignatureType || signatureTypes;
|
||||||
|
const docSignTypes =
|
||||||
|
documentData?.[0]?.SignatureType || userSignatureType;
|
||||||
|
const updatedSignatureType = await handleSignatureType(
|
||||||
|
tenantSignTypes,
|
||||||
|
docSignTypes
|
||||||
|
);
|
||||||
|
setSignatureType(updatedSignatureType);
|
||||||
|
const updatedPdfDetails = [...documentData];
|
||||||
|
updatedPdfDetails[0].SignatureType = updatedSignatureType;
|
||||||
|
setPdfDetails(updatedPdfDetails);
|
||||||
setIsSigners(true);
|
setIsSigners(true);
|
||||||
if (documentData[0].Signers && documentData[0].Signers.length > 0) {
|
if (documentData[0].Signers && documentData[0].Signers.length > 0) {
|
||||||
setIsSelectId(0);
|
setIsSelectId(0);
|
||||||
@@ -260,11 +273,7 @@ const TemplatePlaceholder = () => {
|
|||||||
blockColor: x.blockColor
|
blockColor: x.blockColor
|
||||||
};
|
};
|
||||||
} else {
|
} else {
|
||||||
return {
|
return { Role: x.Role, Id: x.Id, blockColor: x.blockColor };
|
||||||
Role: x.Role,
|
|
||||||
Id: x.Id,
|
|
||||||
blockColor: x.blockColor
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
setSignersData(updatedSigners);
|
setSignersData(updatedSigners);
|
||||||
@@ -287,11 +296,7 @@ const TemplatePlaceholder = () => {
|
|||||||
documentData[0].Placeholders.length > 0
|
documentData[0].Placeholders.length > 0
|
||||||
) {
|
) {
|
||||||
let updatedSigners = documentData[0].Placeholders.map((x) => {
|
let updatedSigners = documentData[0].Placeholders.map((x) => {
|
||||||
return {
|
return { Role: x.Role, Id: x.Id, blockColor: x.blockColor };
|
||||||
Role: x.Role,
|
|
||||||
Id: x.Id,
|
|
||||||
blockColor: x.blockColor
|
|
||||||
};
|
|
||||||
});
|
});
|
||||||
setSignerPos(documentData[0].Placeholders);
|
setSignerPos(documentData[0].Placeholders);
|
||||||
setUniqueId(updatedSigners[0].Id);
|
setUniqueId(updatedSigners[0].Id);
|
||||||
@@ -304,17 +309,33 @@ const TemplatePlaceholder = () => {
|
|||||||
documentData === "Error: Something went wrong!" ||
|
documentData === "Error: Something went wrong!" ||
|
||||||
(documentData.result && documentData.result.error)
|
(documentData.result && documentData.result.error)
|
||||||
) {
|
) {
|
||||||
const loadObj = {
|
|
||||||
isLoad: false
|
|
||||||
};
|
|
||||||
setHandleError(t("something-went-wrong-mssg"));
|
setHandleError(t("something-went-wrong-mssg"));
|
||||||
setIsLoading(loadObj);
|
setIsLoading({ isLoad: false });
|
||||||
} else {
|
} else {
|
||||||
setHandleError(t("no-data-avaliable"));
|
setHandleError(t("no-data-avaliable"));
|
||||||
const loadObj = {
|
setIsLoading({ isLoad: false });
|
||||||
isLoad: false
|
}
|
||||||
};
|
const res = await contractUsers();
|
||||||
setIsLoading(loadObj);
|
if (res[0] && res.length) {
|
||||||
|
setSignerUserId(res[0].objectId);
|
||||||
|
setCurrentEmail(res[0].Email);
|
||||||
|
const tourstatus = res[0].TourStatus && res[0].TourStatus;
|
||||||
|
if (tourstatus && tourstatus.length > 0) {
|
||||||
|
setTourStatus(tourstatus);
|
||||||
|
const checkTourRecipients = tourstatus.filter(
|
||||||
|
(data) => data.templateTour
|
||||||
|
);
|
||||||
|
if (checkTourRecipients && checkTourRecipients.length > 0) {
|
||||||
|
setCheckTourStatus(checkTourRecipients[0].templateTour);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
setIsLoading({ isLoad: false });
|
||||||
|
} else if (res === "Error: Something went wrong!") {
|
||||||
|
setHandleError(t("something-went-wrong-mssg"));
|
||||||
|
setIsLoading({ isLoad: false });
|
||||||
|
} else if (res.length === 0) {
|
||||||
|
setHandleError(t("no-data-avaliable"));
|
||||||
|
setIsLoading({ isLoad: false });
|
||||||
}
|
}
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.log("err ", err);
|
console.log("err ", err);
|
||||||
@@ -324,37 +345,6 @@ const TemplatePlaceholder = () => {
|
|||||||
setHandleError(t("something-went-wrong-mssg"));
|
setHandleError(t("something-went-wrong-mssg"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
const res = await contractUsers();
|
|
||||||
if (res[0] && res.length) {
|
|
||||||
setSignerUserId(res[0].objectId);
|
|
||||||
setCurrentEmail(res[0].Email);
|
|
||||||
const tourstatus = res[0].TourStatus && res[0].TourStatus;
|
|
||||||
if (tourstatus && tourstatus.length > 0) {
|
|
||||||
setTourStatus(tourstatus);
|
|
||||||
const checkTourRecipients = tourstatus.filter(
|
|
||||||
(data) => data.templateTour
|
|
||||||
);
|
|
||||||
if (checkTourRecipients && checkTourRecipients.length > 0) {
|
|
||||||
setCheckTourStatus(checkTourRecipients[0].templateTour);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
const loadObj = {
|
|
||||||
isLoad: false
|
|
||||||
};
|
|
||||||
setIsLoading(loadObj);
|
|
||||||
} else if (res === "Error: Something went wrong!") {
|
|
||||||
const loadObj = {
|
|
||||||
isLoad: false
|
|
||||||
};
|
|
||||||
setHandleError(t("something-went-wrong-mssg"));
|
|
||||||
setIsLoading(loadObj);
|
|
||||||
} else if (res.length === 0) {
|
|
||||||
setHandleError(t("no-data-avaliable"));
|
|
||||||
const loadObj = {
|
|
||||||
isLoad: false
|
|
||||||
};
|
|
||||||
setIsLoading(loadObj);
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
//function for setting position after drop signature button over pdf
|
//function for setting position after drop signature button over pdf
|
||||||
@@ -379,8 +369,10 @@ const TemplatePlaceholder = () => {
|
|||||||
);
|
);
|
||||||
const key = randomId();
|
const key = randomId();
|
||||||
const dragTypeValue = item?.text ? item.text : monitor.type;
|
const dragTypeValue = item?.text ? item.text : monitor.type;
|
||||||
const widgetWidth = defaultWidthHeight(dragTypeValue).width;
|
const widgetWidth =
|
||||||
const widgetHeight = defaultWidthHeight(dragTypeValue).height;
|
defaultWidthHeight(dragTypeValue).width * containerScale;
|
||||||
|
const widgetHeight =
|
||||||
|
defaultWidthHeight(dragTypeValue).height * containerScale;
|
||||||
let dropData = [],
|
let dropData = [],
|
||||||
currentPagePosition;
|
currentPagePosition;
|
||||||
let placeHolder;
|
let placeHolder;
|
||||||
@@ -402,10 +394,7 @@ const TemplatePlaceholder = () => {
|
|||||||
Height: widgetHeight / (containerScale * scale)
|
Height: widgetHeight / (containerScale * scale)
|
||||||
};
|
};
|
||||||
dropData.push(dropObj);
|
dropData.push(dropObj);
|
||||||
placeHolder = {
|
placeHolder = { pageNumber: pageNumber, pos: dropData };
|
||||||
pageNumber: pageNumber,
|
|
||||||
pos: dropData
|
|
||||||
};
|
|
||||||
} else {
|
} else {
|
||||||
const offset = monitor.getClientOffset();
|
const offset = monitor.getClientOffset();
|
||||||
//adding and updating drop position in array when user drop signature button in div
|
//adding and updating drop position in array when user drop signature button in div
|
||||||
@@ -436,10 +425,7 @@ const TemplatePlaceholder = () => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
dropData.push(dropObj);
|
dropData.push(dropObj);
|
||||||
placeHolder = {
|
placeHolder = { pageNumber: pageNumber, pos: dropData };
|
||||||
pageNumber: pageNumber,
|
|
||||||
pos: dropData
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
let filterSignerPos = signerPos.find((data) => data.Id === uniqueId);
|
let filterSignerPos = signerPos.find((data) => data.Id === uniqueId);
|
||||||
const getPlaceHolder = filterSignerPos?.placeHolder;
|
const getPlaceHolder = filterSignerPos?.placeHolder;
|
||||||
@@ -456,10 +442,7 @@ const TemplatePlaceholder = () => {
|
|||||||
);
|
);
|
||||||
const getPos = currentPagePosition?.pos;
|
const getPos = currentPagePosition?.pos;
|
||||||
const newSignPos = getPos.concat(dropData);
|
const newSignPos = getPos.concat(dropData);
|
||||||
let xyPos = {
|
let xyPos = { pageNumber: pageNumber, pos: newSignPos };
|
||||||
pageNumber: pageNumber,
|
|
||||||
pos: newSignPos
|
|
||||||
};
|
|
||||||
updatePlace.push(xyPos);
|
updatePlace.push(xyPos);
|
||||||
const updatesignerPos = signerPos.map((x) =>
|
const updatesignerPos = signerPos.map((x) =>
|
||||||
x.Id === uniqueId ? { ...x, placeHolder: updatePlace } : x
|
x.Id === uniqueId ? { ...x, placeHolder: updatePlace } : x
|
||||||
@@ -495,7 +478,6 @@ const TemplatePlaceholder = () => {
|
|||||||
setWidgetType(dragTypeValue);
|
setWidgetType(dragTypeValue);
|
||||||
setSignKey(key);
|
setSignKey(key);
|
||||||
setSelectWidgetId(key);
|
setSelectWidgetId(key);
|
||||||
|
|
||||||
setIsMailSend(false);
|
setIsMailSend(false);
|
||||||
} else {
|
} else {
|
||||||
setIsReceipent(false);
|
setIsReceipent(false);
|
||||||
@@ -594,9 +576,7 @@ const TemplatePlaceholder = () => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
setIsMailSend(false);
|
setIsMailSend(false);
|
||||||
setTimeout(() => {
|
setTimeout(() => setIsDragging(false), 200);
|
||||||
setIsDragging(false);
|
|
||||||
}, 200);
|
|
||||||
};
|
};
|
||||||
//function for delete signature block
|
//function for delete signature block
|
||||||
const handleDeleteSign = (key, Id) => {
|
const handleDeleteSign = (key, Id) => {
|
||||||
@@ -712,7 +692,7 @@ const TemplatePlaceholder = () => {
|
|||||||
}, 2000);
|
}, 2000);
|
||||||
return () => clearTimeout(timer);
|
return () => clearTimeout(timer);
|
||||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||||
}, [signerPos]);
|
}, [signerPos, signatureType]);
|
||||||
|
|
||||||
// `autosavedetails` is used to save template details after every 2 sec when changes are happern in placeholder like drag-drop widgets, remove signers
|
// `autosavedetails` is used to save template details after every 2 sec when changes are happern in placeholder like drag-drop widgets, remove signers
|
||||||
const autosavedetails = async () => {
|
const autosavedetails = async () => {
|
||||||
@@ -734,6 +714,7 @@ const TemplatePlaceholder = () => {
|
|||||||
templateCls.id = templateId;
|
templateCls.id = templateId;
|
||||||
templateCls.set("Placeholders", signerPos);
|
templateCls.set("Placeholders", signerPos);
|
||||||
templateCls.set("Signers", signers);
|
templateCls.set("Signers", signers);
|
||||||
|
templateCls.set("SignatureType", signatureType);
|
||||||
await templateCls.save();
|
await templateCls.save();
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.log("error in autosave template", err);
|
console.log("error in autosave template", err);
|
||||||
@@ -742,8 +723,7 @@ const TemplatePlaceholder = () => {
|
|||||||
|
|
||||||
const handleSaveTemplate = async () => {
|
const handleSaveTemplate = async () => {
|
||||||
if (signersdata?.length) {
|
if (signersdata?.length) {
|
||||||
const loadObj = { isLoad: true, message: t("loading-mssg") };
|
setIsLoading({ isLoad: true, message: t("loading-mssg") });
|
||||||
setIsLoading(loadObj);
|
|
||||||
setIsSendAlert(false);
|
setIsSendAlert(false);
|
||||||
let signers = [];
|
let signers = [];
|
||||||
if (signersdata?.length > 0) {
|
if (signersdata?.length > 0) {
|
||||||
@@ -782,7 +762,8 @@ const TemplatePlaceholder = () => {
|
|||||||
NextReminderDate: pdfDetails[0]?.NextReminderDate,
|
NextReminderDate: pdfDetails[0]?.NextReminderDate,
|
||||||
IsEnableOTP: pdfDetails[0]?.IsEnableOTP === true ? true : false,
|
IsEnableOTP: pdfDetails[0]?.IsEnableOTP === true ? true : false,
|
||||||
IsTourEnabled: pdfDetails[0]?.IsTourEnabled === true ? true : false,
|
IsTourEnabled: pdfDetails[0]?.IsTourEnabled === true ? true : false,
|
||||||
URL: pdfUrl
|
URL: pdfUrl,
|
||||||
|
SignatureType: signatureType
|
||||||
};
|
};
|
||||||
const updateTemplate = new Parse.Object("contracts_Template");
|
const updateTemplate = new Parse.Object("contracts_Template");
|
||||||
updateTemplate.id = templateId;
|
updateTemplate.id = templateId;
|
||||||
@@ -891,9 +872,7 @@ const TemplatePlaceholder = () => {
|
|||||||
`${localStorage.getItem(
|
`${localStorage.getItem(
|
||||||
"baseUrl"
|
"baseUrl"
|
||||||
)}classes/contracts_Users/${signerUserId}`,
|
)}classes/contracts_Users/${signerUserId}`,
|
||||||
{
|
{ TourStatus: updatedTourStatus },
|
||||||
TourStatus: updatedTourStatus
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
headers: {
|
headers: {
|
||||||
"Content-Type": "application/json",
|
"Content-Type": "application/json",
|
||||||
@@ -1136,7 +1115,7 @@ const TemplatePlaceholder = () => {
|
|||||||
isReadOnly: isReadOnly || false,
|
isReadOnly: isReadOnly || false,
|
||||||
isHideLabel: isHideLabel || false,
|
isHideLabel: isHideLabel || false,
|
||||||
fontSize:
|
fontSize:
|
||||||
fontSize || currWidgetsDetails?.options?.fontSize || "12",
|
fontSize || currWidgetsDetails?.options?.fontSize || 12,
|
||||||
fontColor:
|
fontColor:
|
||||||
fontColor ||
|
fontColor ||
|
||||||
currWidgetsDetails?.options?.fontColor ||
|
currWidgetsDetails?.options?.fontColor ||
|
||||||
@@ -1174,7 +1153,7 @@ const TemplatePlaceholder = () => {
|
|||||||
defaultValue: defaultValue,
|
defaultValue: defaultValue,
|
||||||
isHideLabel: isHideLabel || false,
|
isHideLabel: isHideLabel || false,
|
||||||
fontSize:
|
fontSize:
|
||||||
fontSize || currWidgetsDetails?.options?.fontSize || "12",
|
fontSize || currWidgetsDetails?.options?.fontSize || 12,
|
||||||
fontColor:
|
fontColor:
|
||||||
fontColor ||
|
fontColor ||
|
||||||
currWidgetsDetails?.options?.fontColor ||
|
currWidgetsDetails?.options?.fontColor ||
|
||||||
@@ -1192,7 +1171,7 @@ const TemplatePlaceholder = () => {
|
|||||||
values: dropdownOptions,
|
values: dropdownOptions,
|
||||||
defaultValue: defaultValue,
|
defaultValue: defaultValue,
|
||||||
fontSize:
|
fontSize:
|
||||||
fontSize || currWidgetsDetails?.options?.fontSize || "12",
|
fontSize || currWidgetsDetails?.options?.fontSize || 12,
|
||||||
fontColor:
|
fontColor:
|
||||||
fontColor ||
|
fontColor ||
|
||||||
currWidgetsDetails?.options?.fontColor ||
|
currWidgetsDetails?.options?.fontColor ||
|
||||||
@@ -1227,7 +1206,15 @@ const TemplatePlaceholder = () => {
|
|||||||
setFontColor();
|
setFontColor();
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleWidgetdefaultdata = (defaultdata) => {
|
const handleWidgetdefaultdata = (defaultdata, isSignWidget) => {
|
||||||
|
if (isSignWidget) {
|
||||||
|
const updatedPdfDetails = [...pdfDetails];
|
||||||
|
const signtypes = defaultdata.signatureType || signatureType;
|
||||||
|
updatedPdfDetails[0].SignatureType = signtypes;
|
||||||
|
// Update the SignatureType with the modified array
|
||||||
|
setPdfDetails(updatedPdfDetails);
|
||||||
|
setSignatureType(signtypes);
|
||||||
|
}
|
||||||
const options = ["email", "number", "text"];
|
const options = ["email", "number", "text"];
|
||||||
let inputype;
|
let inputype;
|
||||||
if (defaultdata.textvalidate) {
|
if (defaultdata.textvalidate) {
|
||||||
@@ -1267,7 +1254,7 @@ const TemplatePlaceholder = () => {
|
|||||||
}
|
}
|
||||||
: {},
|
: {},
|
||||||
fontSize:
|
fontSize:
|
||||||
fontSize || currWidgetsDetails?.options?.fontSize || "12",
|
fontSize || currWidgetsDetails?.options?.fontSize || 12,
|
||||||
fontColor:
|
fontColor:
|
||||||
fontColor ||
|
fontColor ||
|
||||||
currWidgetsDetails?.options?.fontColor ||
|
currWidgetsDetails?.options?.fontColor ||
|
||||||
@@ -1283,7 +1270,7 @@ const TemplatePlaceholder = () => {
|
|||||||
status: defaultdata.status,
|
status: defaultdata.status,
|
||||||
defaultValue: defaultdata.defaultValue,
|
defaultValue: defaultdata.defaultValue,
|
||||||
fontSize:
|
fontSize:
|
||||||
fontSize || currWidgetsDetails?.options?.fontSize || "12",
|
fontSize || currWidgetsDetails?.options?.fontSize || 12,
|
||||||
fontColor:
|
fontColor:
|
||||||
fontColor ||
|
fontColor ||
|
||||||
currWidgetsDetails?.options?.fontColor ||
|
currWidgetsDetails?.options?.fontColor ||
|
||||||
@@ -1723,6 +1710,7 @@ const TemplatePlaceholder = () => {
|
|||||||
/>
|
/>
|
||||||
</ModalUi>
|
</ModalUi>
|
||||||
<WidgetNameModal
|
<WidgetNameModal
|
||||||
|
signatureType={signatureType}
|
||||||
widgetName={widgetName}
|
widgetName={widgetName}
|
||||||
defaultdata={currWidgetsDetails}
|
defaultdata={currWidgetsDetails}
|
||||||
isOpen={isNameModal}
|
isOpen={isNameModal}
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import { NavLink, useNavigate } from "react-router-dom";
|
|||||||
import Alert from "../primitives/Alert";
|
import Alert from "../primitives/Alert";
|
||||||
import Title from "../components/Title";
|
import Title from "../components/Title";
|
||||||
import { useTranslation } from "react-i18next";
|
import { useTranslation } from "react-i18next";
|
||||||
|
import { emailRegex } from "../constant/const";
|
||||||
const UpdateExistUserAdmin = () => {
|
const UpdateExistUserAdmin = () => {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
const navigate = useNavigate();
|
const navigate = useNavigate();
|
||||||
@@ -35,33 +36,37 @@ const UpdateExistUserAdmin = () => {
|
|||||||
const handleSubmit = async (e) => {
|
const handleSubmit = async (e) => {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
setIsSubmitLoading(true);
|
if (!emailRegex.test(formdata.email)) {
|
||||||
try {
|
alert("Please enter a valid email address.");
|
||||||
const updateUserAsAdmin = await Parse.Cloud.run(
|
} else {
|
||||||
"updateuserasadmin",
|
setIsSubmitLoading(true);
|
||||||
formdata
|
try {
|
||||||
);
|
const updateUserAsAdmin = await Parse.Cloud.run(
|
||||||
// console.log("updateUserAsAdmin ", updateUserAsAdmin);
|
"updateuserasadmin",
|
||||||
if (updateUserAsAdmin === "admin_created") {
|
formdata
|
||||||
setIsAlert({ type: "success", msg: t("admin-created") });
|
);
|
||||||
navigate("/");
|
// console.log("updateUserAsAdmin ", updateUserAsAdmin);
|
||||||
|
if (updateUserAsAdmin === "admin_created") {
|
||||||
|
setIsAlert({ type: "success", msg: t("admin-created") });
|
||||||
|
navigate("/");
|
||||||
|
}
|
||||||
|
} catch (err) {
|
||||||
|
console.log("err in updateuserasadmin", err.code);
|
||||||
|
if (err.code === 404) {
|
||||||
|
setIsAlert((prev) => ({ ...prev, msg: t("invalid-masterkey") }));
|
||||||
|
} else if (err.code === 101) {
|
||||||
|
setIsAlert((prev) => ({ ...prev, msg: t("user-not-found") }));
|
||||||
|
} else if (err.code === 137) {
|
||||||
|
setIsAlert((prev) => ({ ...prev, msg: t("admin-exists") }));
|
||||||
|
} else {
|
||||||
|
setErrMsg(t("something-went-wrong-mssg"));
|
||||||
|
}
|
||||||
|
} finally {
|
||||||
|
setIsSubmitLoading(false);
|
||||||
|
setTimeout(() => {
|
||||||
|
setIsAlert(() => ({ type: "danger", msg: "" }));
|
||||||
|
}, 2000);
|
||||||
}
|
}
|
||||||
} catch (err) {
|
|
||||||
console.log("err in updateuserasadmin", err.code);
|
|
||||||
if (err.code === 404) {
|
|
||||||
setIsAlert((prev) => ({ ...prev, msg: t("invalid-masterkey") }));
|
|
||||||
} else if (err.code === 101) {
|
|
||||||
setIsAlert((prev) => ({ ...prev, msg: t("user-not-found") }));
|
|
||||||
} else if (err.code === 137) {
|
|
||||||
setIsAlert((prev) => ({ ...prev, msg: t("admin-exists") }));
|
|
||||||
} else {
|
|
||||||
setErrMsg(t("something-went-wrong-mssg"));
|
|
||||||
}
|
|
||||||
} finally {
|
|
||||||
setIsSubmitLoading(false);
|
|
||||||
setTimeout(() => {
|
|
||||||
setIsAlert(() => ({ type: "danger", msg: "" }));
|
|
||||||
}, 2000);
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
return (
|
return (
|
||||||
|
|||||||
@@ -1,7 +1,9 @@
|
|||||||
import React, { useState, useEffect } from "react";
|
import React, { useState, useEffect } from "react";
|
||||||
import Parse from "parse";
|
|
||||||
import Loader from "./Loader";
|
import Loader from "./Loader";
|
||||||
import { useTranslation } from "react-i18next";
|
import { useTranslation } from "react-i18next";
|
||||||
|
import axios from "axios";
|
||||||
|
import { getTenantDetails } from "../constant/Utils";
|
||||||
|
import { emailRegex } from "../constant/const";
|
||||||
const AddContact = (props) => {
|
const AddContact = (props) => {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
const [name, setName] = useState("");
|
const [name, setName] = useState("");
|
||||||
@@ -12,6 +14,7 @@ const AddContact = (props) => {
|
|||||||
const [isUserExist, setIsUserExist] = useState(false);
|
const [isUserExist, setIsUserExist] = useState(false);
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
checkUserExist();
|
checkUserExist();
|
||||||
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||||
}, []);
|
}, []);
|
||||||
// Load user details from localStorage when the component mounts
|
// Load user details from localStorage when the component mounts
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
@@ -26,127 +29,61 @@ const AddContact = (props) => {
|
|||||||
}, [addYourself]);
|
}, [addYourself]);
|
||||||
|
|
||||||
const checkUserExist = async () => {
|
const checkUserExist = async () => {
|
||||||
const user = Parse.User.current();
|
|
||||||
try {
|
try {
|
||||||
const query = new Parse.Query("contracts_Contactbook");
|
const baseURL = localStorage.getItem("baseUrl");
|
||||||
query.equalTo("CreatedBy", user);
|
const url = `${baseURL}functions/isuserincontactbook`;
|
||||||
query.notEqualTo("IsDeleted", true);
|
const token = props?.jwttoken
|
||||||
query.equalTo("Email", user.getEmail());
|
? { jwttoken: props?.jwttoken }
|
||||||
const res = await query.first();
|
: { "X-Parse-Session-Token": localStorage.getItem("accesstoken") };
|
||||||
// console.log(res);
|
const headers = {
|
||||||
if (!res) {
|
"Content-Type": "application/json",
|
||||||
|
"X-Parse-Application-Id": localStorage.getItem("parseAppId"),
|
||||||
|
...token
|
||||||
|
};
|
||||||
|
const axiosRes = await axios.post(url, {}, { headers });
|
||||||
|
const contactRes = axiosRes?.data?.result || {};
|
||||||
|
if (!contactRes?.objectId) {
|
||||||
setIsUserExist(true);
|
setIsUserExist(true);
|
||||||
}
|
}
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.log("err", err);
|
console.log("err ", err);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
// Define a function to handle form submission
|
// Define a function to handle form submission
|
||||||
const handleSubmit = async (e) => {
|
const handleSubmit = async (e) => {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
setIsLoader(true);
|
if (!emailRegex.test(email)) {
|
||||||
if (localStorage.getItem("TenantId")) {
|
alert("Please enter a valid email address.");
|
||||||
try {
|
} else {
|
||||||
const user = Parse.User.current();
|
setIsLoader(true);
|
||||||
const query = new Parse.Query("contracts_Contactbook");
|
const user = JSON.parse(
|
||||||
query.equalTo("CreatedBy", user);
|
localStorage.getItem(
|
||||||
query.notEqualTo("IsDeleted", true);
|
`Parse/${localStorage.getItem("parseAppId")}/currentUser`
|
||||||
query.equalTo("Email", email);
|
)
|
||||||
const res = await query.first();
|
);
|
||||||
if (!res) {
|
const userId = user?.objectId || "";
|
||||||
const contactQuery = new Parse.Object("contracts_Contactbook");
|
const tenantDetails = await getTenantDetails(userId, props.jwttoken);
|
||||||
contactQuery.set("Name", name);
|
const tenantId = tenantDetails?.objectId || "";
|
||||||
if (phone) {
|
if (tenantId) {
|
||||||
contactQuery.set("Phone", phone);
|
try {
|
||||||
}
|
const baseURL = localStorage.getItem("baseUrl");
|
||||||
contactQuery.set("Email", email);
|
const url = `${baseURL}functions/savecontact`;
|
||||||
contactQuery.set("UserRole", "contracts_Guest");
|
const token = props?.jwttoken
|
||||||
|
? { jwttoken: props?.jwttoken }
|
||||||
if (localStorage.getItem("TenantId")) {
|
: { "X-Parse-Session-Token": localStorage.getItem("accesstoken") };
|
||||||
contactQuery.set("TenantId", {
|
const data = { name, email, phone, tenantId };
|
||||||
__type: "Pointer",
|
const headers = {
|
||||||
className: "partners_Tenant",
|
"Content-Type": "application/json",
|
||||||
objectId: localStorage.getItem("TenantId")
|
"X-Parse-Application-Id": localStorage.getItem("parseAppId"),
|
||||||
});
|
...token
|
||||||
}
|
};
|
||||||
|
const axiosRes = await axios.post(url, data, { headers });
|
||||||
try {
|
const contactRes = axiosRes?.data?.result || {};
|
||||||
const _users = Parse.Object.extend("User");
|
if (contactRes?.objectId) {
|
||||||
const _user = new _users();
|
props.details(contactRes);
|
||||||
_user.set("name", name);
|
if (props.closePopup) {
|
||||||
_user.set("username", email);
|
props.closePopup();
|
||||||
_user.set("email", email);
|
|
||||||
_user.set("password", email);
|
|
||||||
if (phone) {
|
|
||||||
_user.set("phone", phone);
|
|
||||||
}
|
|
||||||
|
|
||||||
const user = await _user.save();
|
|
||||||
if (user) {
|
|
||||||
const currentUser = Parse.User.current();
|
|
||||||
contactQuery.set(
|
|
||||||
"CreatedBy",
|
|
||||||
Parse.User.createWithoutData(currentUser.id)
|
|
||||||
);
|
|
||||||
|
|
||||||
contactQuery.set("UserId", user);
|
|
||||||
const acl = new Parse.ACL();
|
|
||||||
acl.setPublicReadAccess(true);
|
|
||||||
acl.setPublicWriteAccess(true);
|
|
||||||
acl.setReadAccess(currentUser.id, true);
|
|
||||||
acl.setWriteAccess(currentUser.id, true);
|
|
||||||
|
|
||||||
contactQuery.setACL(acl);
|
|
||||||
|
|
||||||
const res = await contactQuery.save();
|
|
||||||
|
|
||||||
const parseData = JSON.parse(JSON.stringify(res));
|
|
||||||
props.details(parseData);
|
|
||||||
if (props.closePopup) {
|
|
||||||
props.closePopup();
|
|
||||||
}
|
|
||||||
|
|
||||||
setIsLoader(false);
|
|
||||||
// Reset the form fields
|
|
||||||
setAddYourself(false);
|
|
||||||
setName("");
|
|
||||||
setPhone("");
|
|
||||||
setEmail("");
|
|
||||||
}
|
|
||||||
} catch (err) {
|
|
||||||
console.log("err ", err);
|
|
||||||
if (err.code === 202) {
|
|
||||||
const params = { email: email };
|
|
||||||
const userRes = await Parse.Cloud.run("getUserId", params);
|
|
||||||
const currentUser = Parse.User.current();
|
|
||||||
contactQuery.set(
|
|
||||||
"CreatedBy",
|
|
||||||
Parse.User.createWithoutData(currentUser.id)
|
|
||||||
);
|
|
||||||
|
|
||||||
contactQuery.set("UserId", {
|
|
||||||
__type: "Pointer",
|
|
||||||
className: "_User",
|
|
||||||
objectId: userRes.id
|
|
||||||
});
|
|
||||||
const acl = new Parse.ACL();
|
|
||||||
acl.setPublicReadAccess(true);
|
|
||||||
acl.setPublicWriteAccess(true);
|
|
||||||
acl.setReadAccess(currentUser.id, true);
|
|
||||||
acl.setWriteAccess(currentUser.id, true);
|
|
||||||
|
|
||||||
contactQuery.setACL(acl);
|
|
||||||
const res = await contactQuery.save();
|
|
||||||
|
|
||||||
const parseData = JSON.parse(JSON.stringify(res));
|
|
||||||
if (props.details) {
|
|
||||||
props.details(parseData);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (props.closePopup) {
|
|
||||||
props.closePopup();
|
|
||||||
}
|
|
||||||
setIsLoader(false);
|
setIsLoader(false);
|
||||||
// Reset the form fields
|
// Reset the form fields
|
||||||
setAddYourself(false);
|
setAddYourself(false);
|
||||||
@@ -155,18 +92,19 @@ const AddContact = (props) => {
|
|||||||
setEmail("");
|
setEmail("");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} catch (err) {
|
||||||
alert(t("add-signer-alert"));
|
console.log("Err", err);
|
||||||
setIsLoader(false);
|
setIsLoader(false);
|
||||||
|
if (err?.response?.data?.error?.includes("already exists")) {
|
||||||
|
alert(t("add-signer-alert"));
|
||||||
|
} else {
|
||||||
|
alert(t("something-went-wrong-mssg"));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} catch (err) {
|
} else {
|
||||||
// console.log("err", err);
|
|
||||||
setIsLoader(false);
|
setIsLoader(false);
|
||||||
alert(t("something-went-wrong-mssg"));
|
alert(t("something-went-wrong-mssg"));
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
setIsLoader(false);
|
|
||||||
alert(t("something-went-wrong-mssg"));
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -15,7 +15,10 @@ import {
|
|||||||
copytoData,
|
copytoData,
|
||||||
fetchUrl,
|
fetchUrl,
|
||||||
getSignedUrl,
|
getSignedUrl,
|
||||||
replaceMailVaribles
|
getTenantDetails,
|
||||||
|
handleSignatureType,
|
||||||
|
replaceMailVaribles,
|
||||||
|
signatureTypes
|
||||||
} from "../constant/Utils";
|
} from "../constant/Utils";
|
||||||
import Confetti from "react-confetti";
|
import Confetti from "react-confetti";
|
||||||
import EditorToolbar, {
|
import EditorToolbar, {
|
||||||
@@ -77,6 +80,7 @@ const ReportTable = (props) => {
|
|||||||
const [isDownloadModal, setIsDownloadModal] = useState(false);
|
const [isDownloadModal, setIsDownloadModal] = useState(false);
|
||||||
const [isEmbed, setIsEmbed] = useState(false);
|
const [isEmbed, setIsEmbed] = useState(false);
|
||||||
const [isPublicTour, setIsPublicTour] = useState();
|
const [isPublicTour, setIsPublicTour] = useState();
|
||||||
|
const [signatureType, setSignatureType] = useState([]);
|
||||||
const Extand_Class = localStorage.getItem("Extand_Class");
|
const Extand_Class = localStorage.getItem("Extand_Class");
|
||||||
const extClass = Extand_Class && JSON.parse(Extand_Class);
|
const extClass = Extand_Class && JSON.parse(Extand_Class);
|
||||||
const startIndex = (currentPage - 1) * props.docPerPage;
|
const startIndex = (currentPage - 1) * props.docPerPage;
|
||||||
@@ -195,6 +199,33 @@ const ReportTable = (props) => {
|
|||||||
}
|
}
|
||||||
}, [isMoreDocs, pageNumbers, currentPage, setIsNextRecord]);
|
}, [isMoreDocs, pageNumbers, currentPage, setIsNextRecord]);
|
||||||
|
|
||||||
|
//function to fetch tenant Details
|
||||||
|
const fetchTenantDetails = async () => {
|
||||||
|
const user = JSON.parse(
|
||||||
|
localStorage.getItem(
|
||||||
|
`Parse/${localStorage.getItem("parseAppId")}/currentUser`
|
||||||
|
)
|
||||||
|
);
|
||||||
|
if (user) {
|
||||||
|
try {
|
||||||
|
const tenantDetails = await getTenantDetails(user?.objectId);
|
||||||
|
if (tenantDetails && tenantDetails === "user does not exist!") {
|
||||||
|
alert(t("user-not-exist"));
|
||||||
|
} else if (tenantDetails) {
|
||||||
|
const signatureType = tenantDetails?.SignatureType || [];
|
||||||
|
const filterSignTypes = signatureType?.filter(
|
||||||
|
(x) => x.enabled === true
|
||||||
|
);
|
||||||
|
return filterSignTypes;
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
alert(t("user-not-exist"));
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
alert(t("user-not-exist"));
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
// `handleURL` is used to open microapp
|
// `handleURL` is used to open microapp
|
||||||
const handleURL = async (item, act) => {
|
const handleURL = async (item, act) => {
|
||||||
if (props.ReportName === "Templates") {
|
if (props.ReportName === "Templates") {
|
||||||
@@ -203,9 +234,7 @@ const ReportTable = (props) => {
|
|||||||
} else {
|
} else {
|
||||||
setActLoader({ [`${item.objectId}_${act.btnId}`]: true });
|
setActLoader({ [`${item.objectId}_${act.btnId}`]: true });
|
||||||
try {
|
try {
|
||||||
const params = {
|
const params = { templateId: item.objectId };
|
||||||
templateId: item.objectId
|
|
||||||
};
|
|
||||||
const templateDeatils = await axios.post(
|
const templateDeatils = await axios.post(
|
||||||
`${localStorage.getItem("baseUrl")}functions/getTemplate`,
|
`${localStorage.getItem("baseUrl")}functions/getTemplate`,
|
||||||
params,
|
params,
|
||||||
@@ -249,6 +278,16 @@ const ReportTable = (props) => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
const tenantSignTypes = await fetchTenantDetails();
|
||||||
|
const docSignTypes = Doc?.SignatureType || signatureTypes;
|
||||||
|
const updatedSignatureType = await handleSignatureType(
|
||||||
|
tenantSignTypes,
|
||||||
|
docSignTypes
|
||||||
|
);
|
||||||
|
const SignatureType =
|
||||||
|
updatedSignatureType.length > 0
|
||||||
|
? { SignatureType: updatedSignatureType }
|
||||||
|
: {};
|
||||||
let placeholdersArr = [];
|
let placeholdersArr = [];
|
||||||
if (Doc.Placeholders?.length > 0) {
|
if (Doc.Placeholders?.length > 0) {
|
||||||
placeholdersArr = Doc.Placeholders;
|
placeholdersArr = Doc.Placeholders;
|
||||||
@@ -275,7 +314,8 @@ const ReportTable = (props) => {
|
|||||||
AutomaticReminders: Doc?.AutomaticReminders || false,
|
AutomaticReminders: Doc?.AutomaticReminders || false,
|
||||||
RemindOnceInEvery: Doc?.RemindOnceInEvery || 5,
|
RemindOnceInEvery: Doc?.RemindOnceInEvery || 5,
|
||||||
IsEnableOTP: Doc?.IsEnableOTP || false,
|
IsEnableOTP: Doc?.IsEnableOTP || false,
|
||||||
FileAdapterId: Doc?.FileAdapterId || ""
|
FileAdapterId: Doc?.FileAdapterId || "",
|
||||||
|
...SignatureType
|
||||||
};
|
};
|
||||||
try {
|
try {
|
||||||
const res = await axios.post(
|
const res = await axios.post(
|
||||||
@@ -910,6 +950,13 @@ const ReportTable = (props) => {
|
|||||||
}
|
}
|
||||||
);
|
);
|
||||||
const templateRes = axiosRes.data && axiosRes.data.result;
|
const templateRes = axiosRes.data && axiosRes.data.result;
|
||||||
|
const tenantSignTypes = await fetchTenantDetails();
|
||||||
|
const docSignTypes = templateRes?.SignatureType || signatureTypes;
|
||||||
|
const updatedSignatureType = await handleSignatureType(
|
||||||
|
tenantSignTypes,
|
||||||
|
docSignTypes
|
||||||
|
);
|
||||||
|
setSignatureType(updatedSignatureType);
|
||||||
setPlaceholders(templateRes?.Placeholders);
|
setPlaceholders(templateRes?.Placeholders);
|
||||||
setTemplateDetails(templateRes);
|
setTemplateDetails(templateRes);
|
||||||
setIsLoader({});
|
setIsLoader({});
|
||||||
@@ -1165,7 +1212,7 @@ const ReportTable = (props) => {
|
|||||||
<Loader />
|
<Loader />
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
<div className="p-2 w-full overflow-hidden bg-base-100 text-base-content op-card shadow-lg">
|
<div className="p-2 w-full bg-base-100 text-base-content op-card shadow-lg">
|
||||||
{isCelebration && (
|
{isCelebration && (
|
||||||
<div className="relative z-[1000]">
|
<div className="relative z-[1000]">
|
||||||
<Confetti
|
<Confetti
|
||||||
@@ -1226,11 +1273,17 @@ const ReportTable = (props) => {
|
|||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
<div
|
<div
|
||||||
className={`${
|
className={`overflow-auto w-full border-b ${
|
||||||
isDashboard && props.List?.length > 0 ? "min-h-[317px]" : "h-full"
|
props.List?.length > 0
|
||||||
} overflow-auto w-full`}
|
? isDashboard
|
||||||
|
? "min-h-[317px]"
|
||||||
|
: currentList?.length === props.docPerPage
|
||||||
|
? "h-fit"
|
||||||
|
: "h-screen"
|
||||||
|
: ""
|
||||||
|
}`}
|
||||||
>
|
>
|
||||||
<table className="op-table border-collapse w-full ">
|
<table className="op-table border-collapse w-full mb-4">
|
||||||
<thead className="text-[14px]">
|
<thead className="text-[14px]">
|
||||||
<tr className="border-y-[1px]">
|
<tr className="border-y-[1px]">
|
||||||
{props.heading?.map((item, index) => (
|
{props.heading?.map((item, index) => (
|
||||||
@@ -1311,7 +1364,14 @@ const ReportTable = (props) => {
|
|||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
) : (
|
) : (
|
||||||
<tr className="border-y-[1px]" key={index}>
|
<tr
|
||||||
|
className={`${
|
||||||
|
currentList?.length === props.docPerPage
|
||||||
|
? "last:border-none"
|
||||||
|
: ""
|
||||||
|
} border-y-[1px] `}
|
||||||
|
key={index}
|
||||||
|
>
|
||||||
{props.heading.includes("Sr.No") && (
|
{props.heading.includes("Sr.No") && (
|
||||||
<th className="px-4 py-2">
|
<th className="px-4 py-2">
|
||||||
{startIndex + index + 1}
|
{startIndex + index + 1}
|
||||||
@@ -1479,13 +1539,13 @@ const ReportTable = (props) => {
|
|||||||
}
|
}
|
||||||
className="op-btn op-btn-primary"
|
className="op-btn op-btn-primary"
|
||||||
>
|
>
|
||||||
{t("submit")}
|
{t("yes")}
|
||||||
</button>
|
</button>
|
||||||
<button
|
<button
|
||||||
onClick={() => handleClose(item)}
|
onClick={() => handleClose(item)}
|
||||||
className="op-btn op-btn-secondary"
|
className="op-btn op-btn-secondary"
|
||||||
>
|
>
|
||||||
{t("cancel")}
|
{t("no")}
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -1590,9 +1650,7 @@ const ReportTable = (props) => {
|
|||||||
className={
|
className={
|
||||||
act.action !== "option"
|
act.action !== "option"
|
||||||
? `${
|
? `${
|
||||||
act?.btnColor
|
act?.btnColor || ""
|
||||||
? act.btnColor
|
|
||||||
: ""
|
|
||||||
} op-btn op-btn-sm mr-1`
|
} op-btn op-btn-sm mr-1`
|
||||||
: "text-base-content focus:outline-none text-lg mr-2 relative"
|
: "text-base-content focus:outline-none text-lg mr-2 relative"
|
||||||
}
|
}
|
||||||
@@ -1609,9 +1667,10 @@ const ReportTable = (props) => {
|
|||||||
)}`}
|
)}`}
|
||||||
</span>
|
</span>
|
||||||
)}
|
)}
|
||||||
|
{/* template report */}
|
||||||
{isOption[item.objectId] &&
|
{isOption[item.objectId] &&
|
||||||
act.action === "option" && (
|
act.action === "option" && (
|
||||||
<ul className="absolute -right-1 top-auto z-[70] w-max op-dropdown-content op-menu shadow bg-base-100 text-base-content rounded-box">
|
<ul className="absolute -right-1 top-auto z-[70] w-max op-dropdown-content op-menu shadow-black/20 shadow bg-base-100 text-base-content rounded-box">
|
||||||
{act.subaction?.map((subact) => (
|
{act.subaction?.map((subact) => (
|
||||||
<li
|
<li
|
||||||
key={subact.btnId}
|
key={subact.btnId}
|
||||||
@@ -1665,9 +1724,10 @@ const ReportTable = (props) => {
|
|||||||
{t(`btnLabel.${act.btnLabel}`)}
|
{t(`btnLabel.${act.btnLabel}`)}
|
||||||
</span>
|
</span>
|
||||||
)}
|
)}
|
||||||
|
{/* doc report */}
|
||||||
{isOption[item.objectId] &&
|
{isOption[item.objectId] &&
|
||||||
act.action === "option" && (
|
act.action === "option" && (
|
||||||
<ul className="absolute -right-1 top-auto z-[70] w-max op-dropdown-content op-menu shadow bg-base-100 text-base-content rounded-box">
|
<ul className="absolute -right-1 top-auto z-[70] w-max op-dropdown-content op-menu shadow-black/20 shadow bg-base-100 text-base-content rounded-box">
|
||||||
{act.subaction?.map((subact) => (
|
{act.subaction?.map((subact) => (
|
||||||
<li
|
<li
|
||||||
key={subact.btnId}
|
key={subact.btnId}
|
||||||
@@ -1920,6 +1980,7 @@ const ReportTable = (props) => {
|
|||||||
Placeholders={placeholders}
|
Placeholders={placeholders}
|
||||||
item={templateDeatils}
|
item={templateDeatils}
|
||||||
handleClose={handleQuickSendClose}
|
handleClose={handleQuickSendClose}
|
||||||
|
signatureType={signatureType}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
</ModalUi>
|
</ModalUi>
|
||||||
@@ -2129,6 +2190,24 @@ const ReportTable = (props) => {
|
|||||||
)}
|
)}
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
|
{props.List?.length <= 0 && (
|
||||||
|
<div
|
||||||
|
className={`${
|
||||||
|
isDashboard ? "h-[317px]" : ""
|
||||||
|
} flex flex-col items-center justify-center w-ful bg-base-100 text-base-content rounded-xl py-4`}
|
||||||
|
>
|
||||||
|
<div className="w-[60px] h-[60px] overflow-hidden">
|
||||||
|
<img
|
||||||
|
className="w-full h-full object-contain"
|
||||||
|
src={pad}
|
||||||
|
alt="img"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
<div className="text-sm font-semibold">
|
||||||
|
{t("no-data-avaliable")}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
<div className="op-join flex flex-wrap items-center p-2">
|
<div className="op-join flex flex-wrap items-center p-2">
|
||||||
{props.List.length > props.docPerPage && (
|
{props.List.length > props.docPerPage && (
|
||||||
@@ -2160,24 +2239,6 @@ const ReportTable = (props) => {
|
|||||||
</button>
|
</button>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
{props.List?.length <= 0 && (
|
|
||||||
<div
|
|
||||||
className={`${
|
|
||||||
isDashboard ? "h-[317px]" : ""
|
|
||||||
} flex flex-col items-center justify-center w-ful bg-base-100 text-base-content rounded-xl py-4`}
|
|
||||||
>
|
|
||||||
<div className="w-[60px] h-[60px] overflow-hidden">
|
|
||||||
<img
|
|
||||||
className="w-full h-full object-contain"
|
|
||||||
src={pad}
|
|
||||||
alt="img"
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
<div className="text-sm font-semibold">
|
|
||||||
{t("no-data-avaliable")}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
<ModalUi
|
<ModalUi
|
||||||
title={t("add-contact")}
|
title={t("add-contact")}
|
||||||
isOpen={isContactform}
|
isOpen={isContactform}
|
||||||
|
|||||||
@@ -19,11 +19,16 @@ const LinkUserModal = (props) => {
|
|||||||
details={props.handleAddUser}
|
details={props.handleAddUser}
|
||||||
closePopup={props.closePopup}
|
closePopup={props.closePopup}
|
||||||
signersData={props?.signersData}
|
signersData={props?.signersData}
|
||||||
|
jwttoken={props?.jwttoken}
|
||||||
/>
|
/>
|
||||||
<div className="op-divider text-base-content mx-[25%] my-1">
|
<div className="op-divider text-base-content mx-[25%] my-1">
|
||||||
{t("or")}
|
{t("or")}
|
||||||
</div>
|
</div>
|
||||||
<AddContact details={props.handleAddUser} closePopup={props.closePopup} />
|
<AddContact
|
||||||
|
details={props.handleAddUser}
|
||||||
|
closePopup={props.closePopup}
|
||||||
|
jwttoken={props?.jwttoken}
|
||||||
|
/>
|
||||||
</ModalUi>
|
</ModalUi>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -94,6 +94,7 @@
|
|||||||
"My Signature": "My Signature",
|
"My Signature": "My Signature",
|
||||||
"API Token": "API Token",
|
"API Token": "API Token",
|
||||||
"Webhook": "Webhook",
|
"Webhook": "Webhook",
|
||||||
|
"Preferences": "Preferences",
|
||||||
"Teams": "Teams",
|
"Teams": "Teams",
|
||||||
"Team-update-successfully": "Team Updated successfully.",
|
"Team-update-successfully": "Team Updated successfully.",
|
||||||
"Users": "Users"
|
"Users": "Users"
|
||||||
@@ -291,7 +292,7 @@
|
|||||||
"subject": "Subject",
|
"subject": "Subject",
|
||||||
"body": "Body",
|
"body": "Body",
|
||||||
"add-contact": "Add Contact",
|
"add-contact": "Add Contact",
|
||||||
"add-signer-alert": "Contact already exist!",
|
"add-signer-alert": "Contact already exist! Please select it from ‘Signers’ dropdown",
|
||||||
"record-delete-alert": "Record deleted successfully!",
|
"record-delete-alert": "Record deleted successfully!",
|
||||||
"record-revoke-alert": "Record revoked successfully!",
|
"record-revoke-alert": "Record revoked successfully!",
|
||||||
"mail-sent-alert": "Mail sent successfully.",
|
"mail-sent-alert": "Mail sent successfully.",
|
||||||
@@ -445,7 +446,8 @@
|
|||||||
"cutomize-email": "Cutomize Email",
|
"cutomize-email": "Cutomize Email",
|
||||||
"upgrade-to-customize-email": "Upgrade to customize Email",
|
"upgrade-to-customize-email": "Upgrade to customize Email",
|
||||||
"sign-url": "Sign url",
|
"sign-url": "Sign url",
|
||||||
"Mails Sent": "Mails Sent",
|
"mails-sent": "Mails Sent",
|
||||||
|
"mail-not-delivered": "Mail not delivered",
|
||||||
"document-alert": "Document Alert",
|
"document-alert": "Document Alert",
|
||||||
"owner-subscription-expired": "Owner's subscription has expired.",
|
"owner-subscription-expired": "Owner's subscription has expired.",
|
||||||
"subscription-expired": "Subscription Expired",
|
"subscription-expired": "Subscription Expired",
|
||||||
@@ -679,9 +681,21 @@
|
|||||||
"p3": "Tip: If your signers are familiar with OpenSign and frequently use it, you may want to disable the guided tour for a more seamless experience. Choose the option that best fits your document signing needs."
|
"p3": "Tip: If your signers are familiar with OpenSign and frequently use it, you may want to disable the guided tour for a more seamless experience. Choose the option that best fits your document signing needs."
|
||||||
},
|
},
|
||||||
"form-title-1": "Document Flow Setting",
|
"form-title-1": "Document Flow Setting",
|
||||||
"form-title-2": "Security Setting",
|
"form-title-2": "Security Settings",
|
||||||
"public-tour-message": "The template needs to be public before you can generate a shareable link.",
|
"public-tour-message": "The template needs to be public before you can generate a shareable link.",
|
||||||
"add-user-template": "You need to add a role before you can add fields for it.",
|
"add-user-template": "You need to add a role before you can add fields for it.",
|
||||||
"pdf-uncompatible": "This pdf is not compatible with opensign, please contact <support@opensignlabs.com>"
|
"pdf-uncompatible": "This pdf is not compatible with opensign, please contact <support@opensignlabs.com>",
|
||||||
|
"text-field-tour": "Fields of type 'Text' must be filled in advance before the document is sent. If you need the signers to provide input, use the 'Text Input' field instead.",
|
||||||
|
"attach-signer-tour": "You need to attach a Signer to every role. You can do that by clicking this icon. Once you select a Signer it will be attached to all the fields associated with that role which appear in the same colour.",
|
||||||
|
"allowed-signature-types": "Allowed signature types",
|
||||||
|
"at-least-one-signature-type": "At least one signature type should be enabled.",
|
||||||
|
"expect-default-one-signature-type": "Please enable one additional signature type apart from the default.",
|
||||||
|
"add-signer-note": "Note - This contact will be added to your contact list",
|
||||||
|
"allowed-signature-types-help": {
|
||||||
|
"p1": "This signature preference controls which signing options are available to your signers. Only the signature types you select will appear in the signature widget when a document is signed. For example, if you choose only the 'Draw' option in preferences, your signer will see only the 'Draw' option in the signature widget, while the other three options will not be available.",
|
||||||
|
"l1": "Create a handwritten signature directly on the screen using your finger or a stylus.",
|
||||||
|
"l2": "Enter your name and choose from various font styles to create a signature.",
|
||||||
|
"l3": "Upload an existing digital version of your signature.",
|
||||||
|
"l4": "Use a pre-set signature style saved under 'My Signature' in your settings."
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -94,6 +94,7 @@
|
|||||||
"My Signature": "Mi firma",
|
"My Signature": "Mi firma",
|
||||||
"API Token": "Token API",
|
"API Token": "Token API",
|
||||||
"Webhook": "Webhook",
|
"Webhook": "Webhook",
|
||||||
|
"Preferences": "Preferencias",
|
||||||
"Teams": "Equipos",
|
"Teams": "Equipos",
|
||||||
"Team-update-successfully": "Equipo actualizado correctamente.",
|
"Team-update-successfully": "Equipo actualizado correctamente.",
|
||||||
"Users": "Usuarios"
|
"Users": "Usuarios"
|
||||||
@@ -291,7 +292,7 @@
|
|||||||
"subject": "Asunto",
|
"subject": "Asunto",
|
||||||
"body": "Cuerpo",
|
"body": "Cuerpo",
|
||||||
"add-contact": "Agregar contacto",
|
"add-contact": "Agregar contacto",
|
||||||
"add-signer-alert": "¡El contacto ya existe!",
|
"add-signer-alert": "¡El contacto ya existe! Selecciónelo en el menú desplegable 'Firmantes'",
|
||||||
"record-delete-alert": "¡Entrada eliminada exitosamente!",
|
"record-delete-alert": "¡Entrada eliminada exitosamente!",
|
||||||
"record-revoke-alert": "¡Entrada revocada exitosamente!",
|
"record-revoke-alert": "¡Entrada revocada exitosamente!",
|
||||||
"mail-sent-alert": "Correo enviado exitosamente.",
|
"mail-sent-alert": "Correo enviado exitosamente.",
|
||||||
@@ -445,7 +446,8 @@
|
|||||||
"cutomize-email": "Personalizar correo",
|
"cutomize-email": "Personalizar correo",
|
||||||
"upgrade-to-customize-email": "Mejora para personalizar el correo",
|
"upgrade-to-customize-email": "Mejora para personalizar el correo",
|
||||||
"sign-url": "URL de firma",
|
"sign-url": "URL de firma",
|
||||||
"Mails Sent": "Correos enviados",
|
"mails-sent": "Correos enviados",
|
||||||
|
"mail-not-delivered": "correo no entregado",
|
||||||
"document-alert": "Alerta de documento",
|
"document-alert": "Alerta de documento",
|
||||||
"owner-subscription-expired": "La suscripción del propietario ha expirado.",
|
"owner-subscription-expired": "La suscripción del propietario ha expirado.",
|
||||||
"subscription-expired": "Suscripción expirada",
|
"subscription-expired": "Suscripción expirada",
|
||||||
@@ -676,11 +678,24 @@
|
|||||||
"add-user-template": "Es necesario agregar un rol antes de poder agregarle campos.",
|
"add-user-template": "Es necesario agregar un rol antes de poder agregarle campos.",
|
||||||
"pdf-uncompatible": "Este pdf no es compatible con opensign, comuníquese con <support@opensignlabs.com>",
|
"pdf-uncompatible": "Este pdf no es compatible con opensign, comuníquese con <support@opensignlabs.com>",
|
||||||
"enable-tour": "Habilitar recorrido",
|
"enable-tour": "Habilitar recorrido",
|
||||||
"istourenabled-help":{
|
"istourenabled-help": {
|
||||||
"p1": "Esto permitirá realizar una visita guiada para los firmantes, brindando instrucciones durante el proceso de firma.",
|
"p1": "Esto permitirá realizar una visita guiada para los firmantes, brindando instrucciones durante el proceso de firma.",
|
||||||
"p2": "Esto desactivará la visita guiada, lo que garantizará una experiencia de firma más rápida e ininterrumpida.",
|
"p2": "Esto desactivará la visita guiada, lo que garantizará una experiencia de firma más rápida e ininterrumpida.",
|
||||||
"p3": "Consejo: si sus firmantes están familiarizados con OpenSign y lo utilizan con frecuencia, es posible que desee desactivar la visita guiada para disfrutar de una experiencia más fluida. Elija la opción que mejor se adapte a sus necesidades de firma de documentos"
|
"p3": "Consejo: si sus firmantes están familiarizados con OpenSign y lo utilizan con frecuencia, es posible que desee desactivar la visita guiada para disfrutar de una experiencia más fluida. Elija la opción que mejor se adapte a sus necesidades de firma de documentos"
|
||||||
},
|
},
|
||||||
"form-title-1": "Configuración del flujo de documentos",
|
"form-title-1": "Configuración del flujo de documentos",
|
||||||
"form-title-2": "Configuración de seguridad"
|
"form-title-2": "Configuración de seguridad",
|
||||||
|
"text-field-tour": "Los campos de tipo 'Texto' deben completarse con anticipación antes de enviar el documento. Si necesita que los firmantes proporcionen información, utilice el campo 'Entrada de texto'",
|
||||||
|
"attach-signer-tour": "Debe adjuntar un firmante a cada función. Puede hacerlo haciendo clic en este icono. Una vez que seleccione un Firmante, se adjuntará a todos los campos asociados con ese rol que aparecen en el mismo color.",
|
||||||
|
"allowed-signature-types": "Tipos de firma permitidos",
|
||||||
|
"at-least-one-signature-type": "Se debe habilitar al menos un tipo de firma.",
|
||||||
|
"expect-default-one-signature-type": "Habilite un tipo de firma adicional aparte del predeterminado.",
|
||||||
|
"add-signer-note": "Nota - Este contacto se agregará a su lista de contactos",
|
||||||
|
"allowed-signature-types-help": {
|
||||||
|
"p1": "Esta preferencia de firma controla qué opciones de firma están disponibles para sus firmantes. Solo los tipos de firma que seleccione aparecerán en el widget de firma cuando se firme un documento. Por ejemplo, si elige sólo la opción 'Draw' en las preferencias, su firmante verá sólo la opción 'Draw' en el widget de firma, mientras que las otras tres opciones no estarán disponibles.",
|
||||||
|
"l1": "Cree una firma manuscrita directamente en la pantalla usando su dedo o un lápiz.",
|
||||||
|
"l2": "Ingrese su nombre y elija entre varios estilos de fuente para crear una firma.",
|
||||||
|
"l3": "Cargue una versión digital existente de su firma.",
|
||||||
|
"l4": "Utilice un estilo de firma preestablecido guardado en 'Mi firma' en su configuración."
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -94,6 +94,7 @@
|
|||||||
"My Signature": "Ma signature",
|
"My Signature": "Ma signature",
|
||||||
"API Token": "Jeton API",
|
"API Token": "Jeton API",
|
||||||
"Webhook": "Webhook",
|
"Webhook": "Webhook",
|
||||||
|
"Preferences": "Préférences",
|
||||||
"Teams": "Équipe",
|
"Teams": "Équipe",
|
||||||
"Team-update-successfully": "Équipe mise à jour avec succès.",
|
"Team-update-successfully": "Équipe mise à jour avec succès.",
|
||||||
"Users": "Utilisateurs"
|
"Users": "Utilisateurs"
|
||||||
@@ -290,7 +291,7 @@
|
|||||||
"subject": "Sujet",
|
"subject": "Sujet",
|
||||||
"body": "Corps",
|
"body": "Corps",
|
||||||
"add-contact": "Ajouter le contact",
|
"add-contact": "Ajouter le contact",
|
||||||
"add-signer-alert": "Le contact existe déjà !",
|
"add-signer-alert": "Le contact existe déjà ! Veuillez le sélectionner dans la liste déroulante 'Signataires'",
|
||||||
"record-delete-alert": "Enregistrement supprimé avec succès !",
|
"record-delete-alert": "Enregistrement supprimé avec succès !",
|
||||||
"record-revoke-alert": " Enregistrement révoqué avec succès ! ",
|
"record-revoke-alert": " Enregistrement révoqué avec succès ! ",
|
||||||
"mail-sent-alert": "Courriel envoyé avec succès.",
|
"mail-sent-alert": "Courriel envoyé avec succès.",
|
||||||
@@ -444,7 +445,8 @@
|
|||||||
"cutomize-email": "Personnaliser l'e-mail",
|
"cutomize-email": "Personnaliser l'e-mail",
|
||||||
"upgrade-to-customize-email": "Mise à niveau pour personnaliser l'e-mail",
|
"upgrade-to-customize-email": "Mise à niveau pour personnaliser l'e-mail",
|
||||||
"sign-url": "Signer l'URL",
|
"sign-url": "Signer l'URL",
|
||||||
"Mails Sent": "Mails envoyés avec succès !",
|
"mails-sent": "Mails envoyés avec succès !",
|
||||||
|
"mail-not-delivered": "Courrier non distribué",
|
||||||
"document-alert": "Alerte document",
|
"document-alert": "Alerte document",
|
||||||
"owner-subscription-expired": "L'abonnement du propriétaire a expiré.",
|
"owner-subscription-expired": "L'abonnement du propriétaire a expiré.",
|
||||||
"subscription-expired": "Abonnement expiré",
|
"subscription-expired": "Abonnement expiré",
|
||||||
@@ -672,14 +674,27 @@
|
|||||||
"server-down": "Impossible de se connecter au serveur OpenSign. Si vous hébergez vous-même OpenSign, veuillez vous assurer que toutes les étapes de la documentation ont été correctement suivies. Si vous exécutez OpenSign localement, vous y accédez peut-être via un numéro de port incorrect.",
|
"server-down": "Impossible de se connecter au serveur OpenSign. Si vous hébergez vous-même OpenSign, veuillez vous assurer que toutes les étapes de la documentation ont été correctement suivies. Si vous exécutez OpenSign localement, vous y accédez peut-être via un numéro de port incorrect.",
|
||||||
"admin-exists": "L'administrateur existe déjà. Veuillez vous connecter à l'application en utilisant les informations d'identification de l'administrateur afin de gérer les utilisateurs.",
|
"admin-exists": "L'administrateur existe déjà. Veuillez vous connecter à l'application en utilisant les informations d'identification de l'administrateur afin de gérer les utilisateurs.",
|
||||||
"enable-tour": "Activer la visite",
|
"enable-tour": "Activer la visite",
|
||||||
"istourenabled-otp-help":{
|
"istourenabled-otp-help": {
|
||||||
"p1": "Cela permettra une visite guidée pour les signataires, fournissant des instructions pendant le processus de signature.",
|
"p1": "Cela permettra une visite guidée pour les signataires, fournissant des instructions pendant le processus de signature.",
|
||||||
"p2": "Cela désactivera la visite guidée, garantissant ainsi une expérience de signature plus rapide et ininterrompue.",
|
"p2": "Cela désactivera la visite guidée, garantissant ainsi une expérience de signature plus rapide et ininterrompue.",
|
||||||
"p3": "Conseil : si vos signataires connaissent OpenSign et l'utilisent fréquemment, vous souhaiterez peut-être désactiver la visite guidée pour une expérience plus fluide. Choisissez l'option qui correspond le mieux à vos besoins en matière de signature de documents."
|
"p3": "Conseil : si vos signataires connaissent OpenSign et l'utilisent fréquemment, vous souhaiterez peut-être désactiver la visite guidée pour une expérience plus fluide. Choisissez l'option qui correspond le mieux à vos besoins en matière de signature de documents."
|
||||||
},
|
},
|
||||||
"form-title-1": "Paramètre du flux de documents",
|
"form-title-1": "Paramètre du flux de documents",
|
||||||
"form-title-2": "Paramètre de sécurité",
|
"form-title-2": "Paramètre de sécurité",
|
||||||
"public-tour-message": "Le modèle doit être public avant que vous puissiez générer un lien partageable.",
|
"public-tour-message": "Le modèle doit être public avant que vous puissiez générer un lien partageable.",
|
||||||
"add-user-template": "Vous devez ajouter un rôle avant de pouvoir lui ajouter des champs. ",
|
"add-user-template": "Vous devez ajouter un rôle avant de pouvoir lui ajouter des champs. ",
|
||||||
"pdf-uncompatible": "Ce pdf n'est pas compatible avec opensign, veuillez contacter <support@opensignlabs.com>"
|
"pdf-uncompatible": "Ce pdf n'est pas compatible avec opensign, veuillez contacter <support@opensignlabs.com>",
|
||||||
|
"text-field-tour": "Les champs de type 'Texte' doivent être remplis à l'avance avant l'envoi du document. Si vous avez besoin que les signataires fournissent des informations, utilisez plutôt le champ 'Saisie de texte'.",
|
||||||
|
"attach-signer-tour": "Vous devez associer un signataire à chaque rôle. Vous pouvez le faire en cliquant sur cette icône. Une fois que vous avez sélectionné un signataire, il sera attaché à tous les champs associés à ce rôle qui apparaissent dans la même couleur.",
|
||||||
|
"allowed-signature-types": "Types de signature autorisés",
|
||||||
|
"at-least-one-signature-type": "Au moins un type de signature doit être activé.",
|
||||||
|
"expect-default-one-signature-type": "Veuillez activer un type de signature supplémentaire en plus de celui par défaut.",
|
||||||
|
"add-signer-note": "Remarque - Ce contact sera ajouté à votre liste de contacts",
|
||||||
|
"allowed-signature-types-help": {
|
||||||
|
"p1": "Cette préférence de signature contrôle les options de signature disponibles pour vos signataires. Seuls les types de signature que vous sélectionnez apparaîtront dans le widget de signature lorsqu'un document est signé. Par exemple, si vous choisissez uniquement l'option 'Draw' dans les préférences, votre signataire ne verra que l'option 'Draw' dans le widget de signature, tandis que les trois autres options ne seront pas disponibles.",
|
||||||
|
"l1": "Créez une signature manuscrite directement sur l'écran à l'aide de votre doigt ou d'un stylet.",
|
||||||
|
"l2": "Entrez votre nom et choisissez parmi différents styles de police pour créer une signature.",
|
||||||
|
"l3": "Téléchargez une version numérique existante de votre signature.",
|
||||||
|
"l4": "Utilisez un style de signature prédéfini enregistré sous 'Ma signature' dans vos paramètres."
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -127,9 +127,15 @@ export const updateMailCount = async (extUserId, plan, monthchange) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
export function formatWidgetOptions(type, options) {
|
export function formatWidgetOptions(type, options) {
|
||||||
|
const colorsArr = ['red', 'black', 'blue', 'yellow'];
|
||||||
|
const fontSizes = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28];
|
||||||
const status = options?.required === true ? 'required' : 'optional' || 'required';
|
const status = options?.required === true ? 'required' : 'optional' || 'required';
|
||||||
const defaultValue = options?.default || '';
|
const defaultValue = options?.default || '';
|
||||||
const values = options?.values || [];
|
const values = options?.values || [];
|
||||||
|
const color = options?.color ? options.color : 'black';
|
||||||
|
const fontColor = colorsArr.includes(color) ? color : 'black';
|
||||||
|
const size = options?.fontsize ? parseInt(options.fontsize) : 12;
|
||||||
|
const fontSize = fontSizes.includes(size) ? size : 12;
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case 'signature':
|
case 'signature':
|
||||||
return { name: 'signature', status: 'required' };
|
return { name: 'signature', status: 'required' };
|
||||||
@@ -140,13 +146,34 @@ export function formatWidgetOptions(type, options) {
|
|||||||
case 'image':
|
case 'image':
|
||||||
return { status: status, name: options.name || 'image' };
|
return { status: status, name: options.name || 'image' };
|
||||||
case 'email':
|
case 'email':
|
||||||
return { status: status, name: options.name || 'email', validation: { type: 'email' } };
|
return {
|
||||||
|
status: status,
|
||||||
|
name: options.name || 'email',
|
||||||
|
validation: { type: 'email' },
|
||||||
|
fontColor: fontColor,
|
||||||
|
fontSize: fontSize,
|
||||||
|
};
|
||||||
case 'name':
|
case 'name':
|
||||||
return { status: status, name: options.name || 'name' };
|
return {
|
||||||
|
status: status,
|
||||||
|
name: options.name || 'name',
|
||||||
|
fontColor: fontColor,
|
||||||
|
fontSize: fontSize,
|
||||||
|
};
|
||||||
case 'job title':
|
case 'job title':
|
||||||
return { status: status, name: options.name || 'job title' };
|
return {
|
||||||
|
status: status,
|
||||||
|
name: options.name || 'job title',
|
||||||
|
fontColor: fontColor,
|
||||||
|
fontSize: fontSize,
|
||||||
|
};
|
||||||
case 'company':
|
case 'company':
|
||||||
return { status: status, name: options.name || 'company' };
|
return {
|
||||||
|
status: status,
|
||||||
|
name: options.name || 'company',
|
||||||
|
fontColor: fontColor,
|
||||||
|
fontSize: fontSize,
|
||||||
|
};
|
||||||
case 'date': {
|
case 'date': {
|
||||||
let today = new Date();
|
let today = new Date();
|
||||||
let dd = String(today.getDate()).padStart(2, '0');
|
let dd = String(today.getDate()).padStart(2, '0');
|
||||||
@@ -160,6 +187,8 @@ export function formatWidgetOptions(type, options) {
|
|||||||
name: options.name || 'date',
|
name: options.name || 'date',
|
||||||
response: defaultValue || today,
|
response: defaultValue || today,
|
||||||
validation: { format: dateFormat || 'dd-MM-yyyy', type: 'date-format' },
|
validation: { format: dateFormat || 'dd-MM-yyyy', type: 'date-format' },
|
||||||
|
fontColor: fontColor,
|
||||||
|
fontSize: fontSize,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
case 'textbox':
|
case 'textbox':
|
||||||
@@ -169,6 +198,8 @@ export function formatWidgetOptions(type, options) {
|
|||||||
defaultValue: defaultValue,
|
defaultValue: defaultValue,
|
||||||
hint: options.hint,
|
hint: options.hint,
|
||||||
validation: { type: 'regex', pattern: options?.regularexpression || '/^[a-zA-Z0-9s]+$/' },
|
validation: { type: 'regex', pattern: options?.regularexpression || '/^[a-zA-Z0-9s]+$/' },
|
||||||
|
fontColor: fontColor,
|
||||||
|
fontSize: fontSize,
|
||||||
};
|
};
|
||||||
case 'checkbox': {
|
case 'checkbox': {
|
||||||
const arr = options?.values;
|
const arr = options?.values;
|
||||||
@@ -188,6 +219,8 @@ export function formatWidgetOptions(type, options) {
|
|||||||
maxRequiredCount: options?.validation?.maxselections || 0,
|
maxRequiredCount: options?.validation?.maxselections || 0,
|
||||||
},
|
},
|
||||||
defaultValue: selectedvalues || [],
|
defaultValue: selectedvalues || [],
|
||||||
|
fontColor: fontColor,
|
||||||
|
fontSize: fontSize,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
case 'radio button': {
|
case 'radio button': {
|
||||||
@@ -198,6 +231,8 @@ export function formatWidgetOptions(type, options) {
|
|||||||
isReadOnly: options?.readonly || false,
|
isReadOnly: options?.readonly || false,
|
||||||
isHideLabel: options?.hidelabel || false,
|
isHideLabel: options?.hidelabel || false,
|
||||||
defaultValue: defaultValue,
|
defaultValue: defaultValue,
|
||||||
|
fontColor: fontColor,
|
||||||
|
fontSize: fontSize,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
case 'dropdown':
|
case 'dropdown':
|
||||||
@@ -206,6 +241,8 @@ export function formatWidgetOptions(type, options) {
|
|||||||
name: options.name || 'dropdown',
|
name: options.name || 'dropdown',
|
||||||
values: values,
|
values: values,
|
||||||
defaultValue: defaultValue,
|
defaultValue: defaultValue,
|
||||||
|
fontColor: fontColor,
|
||||||
|
fontSize: fontSize,
|
||||||
};
|
};
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
@@ -234,3 +271,7 @@ export const planCredits = {
|
|||||||
'teams-monthly': 100,
|
'teams-monthly': 100,
|
||||||
'teams-yearly': 500,
|
'teams-yearly': 500,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export function parseJwt(token) {
|
||||||
|
return JSON.parse(Buffer.from(token.split('.')[1], 'base64').toString());
|
||||||
|
}
|
||||||
|
|||||||
@@ -9,7 +9,6 @@ import getDocument from './routes/getDocument.js';
|
|||||||
import getContact from './routes/getContact.js';
|
import getContact from './routes/getContact.js';
|
||||||
import deleteContact from './routes/deleteContact.js';
|
import deleteContact from './routes/deleteContact.js';
|
||||||
import getContactList from './routes/getContactList.js';
|
import getContactList from './routes/getContactList.js';
|
||||||
import draftDocument from './routes/draftDocument.js';
|
|
||||||
import getTemplate from './routes/getTemplate.js';
|
import getTemplate from './routes/getTemplate.js';
|
||||||
import deletedTemplate from './routes/deleteTemplate.js';
|
import deletedTemplate from './routes/deleteTemplate.js';
|
||||||
import getTemplatetList from './routes/getTemplateList.js';
|
import getTemplatetList from './routes/getTemplateList.js';
|
||||||
@@ -30,6 +29,7 @@ import createFolder from './routes/createFolder.js';
|
|||||||
import updateFolder from './routes/updateFolder.js';
|
import updateFolder from './routes/updateFolder.js';
|
||||||
import getFolderList from './routes/getFolderList.js';
|
import getFolderList from './routes/getFolderList.js';
|
||||||
import deleteFolder from './routes/deleteFolder.js';
|
import deleteFolder from './routes/deleteFolder.js';
|
||||||
|
import draftTemplate from './routes/draftTemplate.js';
|
||||||
dotenv.config();
|
dotenv.config();
|
||||||
const storage = multer.memoryStorage();
|
const storage = multer.memoryStorage();
|
||||||
const upload = multer({ storage: storage });
|
const upload = multer({ storage: storage });
|
||||||
@@ -59,9 +59,6 @@ app.post('/createdocumentwithbinary', upload.array('file', 1), createDocumentwit
|
|||||||
// create Document with co-ordinate
|
// create Document with co-ordinate
|
||||||
app.post('/createdocument', createDocumentwithCoordinate);
|
app.post('/createdocument', createDocumentwithCoordinate);
|
||||||
|
|
||||||
// create Document with base64 without placeholder
|
|
||||||
app.post('/draftdocument', draftDocument);
|
|
||||||
|
|
||||||
// create Document with templateId
|
// create Document with templateId
|
||||||
app.post('/createdocument/:template_id', createDocumentWithTemplate);
|
app.post('/createdocument/:template_id', createDocumentWithTemplate);
|
||||||
|
|
||||||
@@ -77,6 +74,9 @@ app.delete('/document/:document_id', deleteDocument);
|
|||||||
// get all types of documents on the basis of doctype
|
// get all types of documents on the basis of doctype
|
||||||
app.get('/documentlist/:doctype', getDocumentList);
|
app.get('/documentlist/:doctype', getDocumentList);
|
||||||
|
|
||||||
|
// create draft template with file base64
|
||||||
|
app.post('/drafttemplate', draftTemplate);
|
||||||
|
|
||||||
// create Template with co-ordinate
|
// create Template with co-ordinate
|
||||||
app.post('/createtemplate', createTemplatewithCoordinate);
|
app.post('/createtemplate', createTemplatewithCoordinate);
|
||||||
|
|
||||||
|
|||||||
@@ -49,7 +49,7 @@ export default async function createDocumentWithTemplate(request, response) {
|
|||||||
const send_email = request.body.send_email;
|
const send_email = request.body.send_email;
|
||||||
const email_subject = request.body.email_subject;
|
const email_subject = request.body.email_subject;
|
||||||
const email_body = request.body.email_body;
|
const email_body = request.body.email_body;
|
||||||
const sendInOrder = request.body.sendInOrder || false;
|
const sendInOrder = request.body.sendInOrder || true;
|
||||||
const TimeToCompleteDays = request.body.timeToCompleteDays || 15;
|
const TimeToCompleteDays = request.body.timeToCompleteDays || 15;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|||||||
@@ -62,7 +62,7 @@ export default async function createDocumentwithCoordinate(request, response) {
|
|||||||
const fileData = request.files?.[0] ? request.files[0].buffer : null;
|
const fileData = request.files?.[0] ? request.files[0].buffer : null;
|
||||||
const email_subject = request.body.email_subject;
|
const email_subject = request.body.email_subject;
|
||||||
const email_body = request.body.email_body;
|
const email_body = request.body.email_body;
|
||||||
const sendInOrder = request.body.sendInOrder || false;
|
const sendInOrder = request.body.sendInOrder || true;
|
||||||
const TimeToCompleteDays = request.body.timeToCompleteDays || 15;
|
const TimeToCompleteDays = request.body.timeToCompleteDays || 15;
|
||||||
const IsEnableOTP = request.body?.enableOTP === true ? true : false;
|
const IsEnableOTP = request.body?.enableOTP === true ? true : false;
|
||||||
const isTourEnabled = request.body?.enableTour || false;
|
const isTourEnabled = request.body?.enableTour || false;
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ export default async function createTemplatewithCoordinate(request, response) {
|
|||||||
const folderId = request.body.folderId;
|
const folderId = request.body.folderId;
|
||||||
const base64File = request.body.file;
|
const base64File = request.body.file;
|
||||||
const fileData = request.files?.[0] ? request.files[0].buffer : null;
|
const fileData = request.files?.[0] ? request.files[0].buffer : null;
|
||||||
const SendinOrder = request.body.sendInOrder || false;
|
const SendinOrder = request.body.sendInOrder || true;
|
||||||
const isEnableOTP = request.body?.enableOTP === true ? true : false;
|
const isEnableOTP = request.body?.enableOTP === true ? true : false;
|
||||||
const isTourEnabled = request.body?.enableTour || false;
|
const isTourEnabled = request.body?.enableTour || false;
|
||||||
|
|
||||||
|
|||||||
@@ -1,168 +0,0 @@
|
|||||||
import axios from 'axios';
|
|
||||||
import { customAPIurl, saveFileUsage } from '../../../../Utils.js';
|
|
||||||
|
|
||||||
// const randomId = () => Math.floor(1000 + Math.random() * 9000);
|
|
||||||
export default async function draftDocument(request, response) {
|
|
||||||
const name = request.body.title;
|
|
||||||
const note = request.body.note;
|
|
||||||
const description = request.body.description;
|
|
||||||
const signers = request.body.signers;
|
|
||||||
const folderId = request.body.folderId;
|
|
||||||
const base64File = request.body.file;
|
|
||||||
const send_email = request.body.send_email || true;
|
|
||||||
const fileData = request.files?.[0] ? request.files[0].buffer : null;
|
|
||||||
const SendinOrder = request.body.sendInOrder || false;
|
|
||||||
const isEnableOTP = request.body?.enableOTP === true ? true : false;
|
|
||||||
const isTourEnabled = request.body?.enableTour || false;
|
|
||||||
|
|
||||||
// console.log('fileData ', fileData);
|
|
||||||
const protocol = customAPIurl();
|
|
||||||
const baseUrl = new URL(process.env.PUBLIC_URL);
|
|
||||||
|
|
||||||
try {
|
|
||||||
const reqToken = request.headers['x-api-token'];
|
|
||||||
if (!reqToken) {
|
|
||||||
return response.status(400).json({ error: 'Please Provide API Token' });
|
|
||||||
}
|
|
||||||
const tokenQuery = new Parse.Query('appToken');
|
|
||||||
tokenQuery.equalTo('token', reqToken);
|
|
||||||
tokenQuery.include('userId');
|
|
||||||
const token = await tokenQuery.first({ useMasterKey: true });
|
|
||||||
if (token !== undefined) {
|
|
||||||
const parseUser = JSON.parse(JSON.stringify(token));
|
|
||||||
const userPtr = {
|
|
||||||
__type: 'Pointer',
|
|
||||||
className: '_User',
|
|
||||||
objectId: parseUser.userId.objectId,
|
|
||||||
};
|
|
||||||
// Valid Token then proceed request
|
|
||||||
if (signers && signers.length > 0) {
|
|
||||||
let fileUrl;
|
|
||||||
if (request.files?.[0]) {
|
|
||||||
const base64 = fileData?.toString('base64');
|
|
||||||
const file = new Parse.File(request.files?.[0]?.originalname, {
|
|
||||||
base64: base64,
|
|
||||||
});
|
|
||||||
await file.save({ useMasterKey: true });
|
|
||||||
fileUrl = file.url();
|
|
||||||
const buffer = Buffer.from(base64, 'base64');
|
|
||||||
saveFileUsage(buffer.length, fileUrl, parseUser.userId.objectId);
|
|
||||||
} else {
|
|
||||||
const file = new Parse.File(`${name}.pdf`, {
|
|
||||||
base64: base64File,
|
|
||||||
});
|
|
||||||
await file.save({ useMasterKey: true });
|
|
||||||
fileUrl = file.url();
|
|
||||||
const buffer = Buffer.from(base64File, 'base64');
|
|
||||||
saveFileUsage(buffer.length, fileUrl, parseUser.userId.objectId);
|
|
||||||
}
|
|
||||||
const contractsUser = new Parse.Query('contracts_Users');
|
|
||||||
contractsUser.equalTo('UserId', userPtr);
|
|
||||||
const extUser = await contractsUser.first({ useMasterKey: true });
|
|
||||||
const extUserPtr = {
|
|
||||||
__type: 'Pointer',
|
|
||||||
className: 'contracts_Users',
|
|
||||||
objectId: extUser.id,
|
|
||||||
};
|
|
||||||
|
|
||||||
const folderPtr = {
|
|
||||||
__type: 'Pointer',
|
|
||||||
className: 'contracts_Document',
|
|
||||||
objectId: folderId,
|
|
||||||
};
|
|
||||||
|
|
||||||
const object = new Parse.Object('contracts_Document');
|
|
||||||
object.set('Name', name);
|
|
||||||
if (note) {
|
|
||||||
object.set('Note', note);
|
|
||||||
}
|
|
||||||
if (description) {
|
|
||||||
object.set('Description', description);
|
|
||||||
}
|
|
||||||
if (SendinOrder) {
|
|
||||||
object.set('SendinOrder', SendinOrder);
|
|
||||||
}
|
|
||||||
object.set('URL', fileUrl);
|
|
||||||
object.set('CreatedBy', userPtr);
|
|
||||||
object.set('ExtUserPtr', extUserPtr);
|
|
||||||
object.set('IsSendMail', send_email);
|
|
||||||
object.set('IsEnableOTP', isEnableOTP);
|
|
||||||
object.set('IsTourEnabled', isTourEnabled);
|
|
||||||
if (signers && signers.length > 0) {
|
|
||||||
let parseSigners;
|
|
||||||
if (base64File) {
|
|
||||||
parseSigners = signers;
|
|
||||||
} else {
|
|
||||||
parseSigners = JSON.parse(signers);
|
|
||||||
}
|
|
||||||
let createContactUrl = protocol + '/v1/createcontact';
|
|
||||||
|
|
||||||
let contact = [];
|
|
||||||
for (const obj of parseSigners) {
|
|
||||||
const body = {
|
|
||||||
name: obj?.name || '',
|
|
||||||
email: obj?.email || '',
|
|
||||||
phone: obj?.phone || '',
|
|
||||||
};
|
|
||||||
try {
|
|
||||||
const res = await axios.post(createContactUrl, body, {
|
|
||||||
headers: { 'Content-Type': 'application/json', 'x-api-token': reqToken },
|
|
||||||
});
|
|
||||||
// console.log('res ', res.data);
|
|
||||||
contact.push({
|
|
||||||
__type: 'Pointer',
|
|
||||||
className: 'contracts_Contactbook',
|
|
||||||
objectId: res.data?.objectId,
|
|
||||||
});
|
|
||||||
} catch (err) {
|
|
||||||
// console.log('err ', err.response);
|
|
||||||
if (err?.response?.data?.objectId) {
|
|
||||||
contact.push({
|
|
||||||
__type: 'Pointer',
|
|
||||||
className: 'contracts_Contactbook',
|
|
||||||
objectId: err.response.data?.objectId,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
object.set('Signers', contact);
|
|
||||||
}
|
|
||||||
if (folderId) {
|
|
||||||
object.set('Folder', folderPtr);
|
|
||||||
}
|
|
||||||
const newACL = new Parse.ACL();
|
|
||||||
newACL.setPublicReadAccess(false);
|
|
||||||
newACL.setPublicWriteAccess(false);
|
|
||||||
newACL.setReadAccess(userPtr.objectId, true);
|
|
||||||
newACL.setWriteAccess(userPtr.objectId, true);
|
|
||||||
object.setACL(newACL);
|
|
||||||
const res = await object.save(null, { useMasterKey: true });
|
|
||||||
if (request.posthog) {
|
|
||||||
request.posthog?.capture({
|
|
||||||
distinctId: parseUser.userId.email,
|
|
||||||
event: 'api_draft_document',
|
|
||||||
properties: { response_code: 200 },
|
|
||||||
});
|
|
||||||
}
|
|
||||||
return response.json({
|
|
||||||
objectId: res.id,
|
|
||||||
url: `${baseUrl.origin}/placeholdersign/${res.id}`,
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
if (request.posthog) {
|
|
||||||
request.posthog?.capture({
|
|
||||||
distinctId: parseUser.userId.email,
|
|
||||||
event: 'api_draft_document',
|
|
||||||
properties: { response_code: 400 },
|
|
||||||
});
|
|
||||||
}
|
|
||||||
return response.status(400).json({ error: 'Please provide signers!' });
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
return response.status(405).json({ error: 'Invalid API Token!' });
|
|
||||||
}
|
|
||||||
} catch (err) {
|
|
||||||
console.log('err ', err);
|
|
||||||
return response.status(400).json({ error: 'Something went wrong, please try again later!' });
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -0,0 +1,238 @@
|
|||||||
|
import axios from 'axios';
|
||||||
|
import {
|
||||||
|
color,
|
||||||
|
customAPIurl,
|
||||||
|
saveFileUsage,
|
||||||
|
formatWidgetOptions,
|
||||||
|
sanitizeFileName,
|
||||||
|
} from '../../../../Utils.js';
|
||||||
|
import uploadFileToS3 from '../../../parsefunction/uploadFiletoS3.js';
|
||||||
|
import jwt from 'jsonwebtoken';
|
||||||
|
|
||||||
|
const randomId = () => Math.floor(1000 + Math.random() * 9000);
|
||||||
|
export default async function draftTemplate(request, response) {
|
||||||
|
const name = request.body.title;
|
||||||
|
const note = request.body.note;
|
||||||
|
const description = request.body.description;
|
||||||
|
const signers = request.body.signers;
|
||||||
|
const folderId = request.body.folderId;
|
||||||
|
const base64File = request.body.file;
|
||||||
|
const fileData = request.files?.[0] ? request.files[0].buffer : null;
|
||||||
|
const SendinOrder = request.body.sendInOrder || true;
|
||||||
|
const isEnableOTP = request.body?.enableOTP === true ? true : false;
|
||||||
|
const isTourEnabled = request.body?.enableTour || false;
|
||||||
|
const isPublic = request.body?.isPublic;
|
||||||
|
const protocol = customAPIurl();
|
||||||
|
const baseUrl = new URL(process.env.PUBLIC_URL).origin;
|
||||||
|
|
||||||
|
try {
|
||||||
|
const reqToken = request.headers['x-api-token'];
|
||||||
|
if (!reqToken) {
|
||||||
|
return response.status(400).json({ error: 'Please Provide API Token' });
|
||||||
|
}
|
||||||
|
const tokenQuery = new Parse.Query('appToken');
|
||||||
|
tokenQuery.equalTo('token', reqToken);
|
||||||
|
tokenQuery.include('userId');
|
||||||
|
const token = await tokenQuery.first({ useMasterKey: true });
|
||||||
|
if (token !== undefined) {
|
||||||
|
// Valid Token then proceed request
|
||||||
|
const parseUser = JSON.parse(JSON.stringify(token));
|
||||||
|
const userPtr = {
|
||||||
|
__type: 'Pointer',
|
||||||
|
className: '_User',
|
||||||
|
objectId: parseUser.userId.objectId,
|
||||||
|
};
|
||||||
|
const contractsUser = new Parse.Query('contracts_Users');
|
||||||
|
contractsUser.equalTo('UserId', userPtr);
|
||||||
|
contractsUser.include('TenantId');
|
||||||
|
const extUser = await contractsUser.first({ useMasterKey: true });
|
||||||
|
const parseExtUser = JSON.parse(JSON.stringify(extUser));
|
||||||
|
let fileUrl;
|
||||||
|
if (request.files?.[0]) {
|
||||||
|
const base64 = fileData?.toString('base64');
|
||||||
|
const file = new Parse.File(request.files?.[0]?.originalname, {
|
||||||
|
base64: base64,
|
||||||
|
});
|
||||||
|
await file.save({ useMasterKey: true });
|
||||||
|
fileUrl = file.url();
|
||||||
|
const buffer = Buffer.from(base64, 'base64');
|
||||||
|
saveFileUsage(buffer.length, fileUrl, parseUser.userId.objectId);
|
||||||
|
} else {
|
||||||
|
const filename = sanitizeFileName(`${name}.pdf`);
|
||||||
|
let adapter = {};
|
||||||
|
const ActiveFileAdapter = parseExtUser?.TenantId?.ActiveFileAdapter || '';
|
||||||
|
if (ActiveFileAdapter) {
|
||||||
|
adapter =
|
||||||
|
parseExtUser?.TenantId?.FileAdapters?.find(x => (x.id = ActiveFileAdapter)) || {};
|
||||||
|
}
|
||||||
|
if (adapter?.id) {
|
||||||
|
const filedata = Buffer.from(base64File, 'base64');
|
||||||
|
// `uploadFileToS3` is used to save document in user's file storage
|
||||||
|
fileUrl = await uploadFileToS3(filedata, filename, 'application/pdf', adapter);
|
||||||
|
} else {
|
||||||
|
const file = new Parse.File(filename, { base64: base64File }, 'application/pdf');
|
||||||
|
await file.save({ useMasterKey: true });
|
||||||
|
fileUrl = file.url();
|
||||||
|
}
|
||||||
|
const buffer = Buffer.from(base64File, 'base64');
|
||||||
|
saveFileUsage(buffer.length, fileUrl, parseUser.userId.objectId);
|
||||||
|
}
|
||||||
|
const extUserPtr = {
|
||||||
|
__type: 'Pointer',
|
||||||
|
className: 'contracts_Users',
|
||||||
|
objectId: extUser.id,
|
||||||
|
};
|
||||||
|
const object = new Parse.Object('contracts_Template');
|
||||||
|
object.set('Name', name);
|
||||||
|
if (note) {
|
||||||
|
object.set('Note', note);
|
||||||
|
}
|
||||||
|
if (description) {
|
||||||
|
object.set('Description', description);
|
||||||
|
}
|
||||||
|
if (SendinOrder) {
|
||||||
|
object.set('SendinOrder', SendinOrder);
|
||||||
|
}
|
||||||
|
object.set('URL', fileUrl);
|
||||||
|
object.set('CreatedBy', userPtr);
|
||||||
|
object.set('ExtUserPtr', extUserPtr);
|
||||||
|
object.set('IsEnableOTP', isEnableOTP);
|
||||||
|
object.set('IsTourEnabled', isTourEnabled);
|
||||||
|
const Public = isPublic !== undefined ? isPublic : false;
|
||||||
|
if (isPublic !== undefined) {
|
||||||
|
object.set('IsPublic', Public);
|
||||||
|
}
|
||||||
|
let contact = [];
|
||||||
|
if (signers && signers.length > 0) {
|
||||||
|
let parseSigners;
|
||||||
|
if (base64File) {
|
||||||
|
parseSigners = signers;
|
||||||
|
} else {
|
||||||
|
parseSigners = JSON.parse(signers);
|
||||||
|
}
|
||||||
|
let createContactUrl = protocol + '/v1/createcontact';
|
||||||
|
|
||||||
|
for (const [index, element] of parseSigners.entries()) {
|
||||||
|
if (element?.name && element?.email) {
|
||||||
|
const body = {
|
||||||
|
name: element?.name,
|
||||||
|
email: element?.email,
|
||||||
|
phone: element?.phone || '',
|
||||||
|
};
|
||||||
|
try {
|
||||||
|
const res = await axios.post(createContactUrl, body, {
|
||||||
|
headers: { 'Content-Type': 'application/json', 'x-api-token': reqToken },
|
||||||
|
});
|
||||||
|
// console.log('res ', res.data);
|
||||||
|
const contactPtr = {
|
||||||
|
__type: 'Pointer',
|
||||||
|
className: 'contracts_Contactbook',
|
||||||
|
objectId: res.data?.objectId,
|
||||||
|
};
|
||||||
|
const newObj = { ...element, contactPtr: contactPtr, index: index };
|
||||||
|
contact.push(newObj);
|
||||||
|
} catch (err) {
|
||||||
|
// console.log('err ', err.response);
|
||||||
|
if (err?.response?.data?.objectId) {
|
||||||
|
const contactPtr = {
|
||||||
|
__type: 'Pointer',
|
||||||
|
className: 'contracts_Contactbook',
|
||||||
|
objectId: err.response.data?.objectId,
|
||||||
|
};
|
||||||
|
const newObj = { ...element, contactPtr: contactPtr, index: index };
|
||||||
|
contact.push(newObj);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
const newObj = { ...element, contactPtr: {}, index: index };
|
||||||
|
contact.push(newObj);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
const updatedSigners = contact?.filter(x => x.contactPtr && x.contactPtr.objectId);
|
||||||
|
if (updatedSigners && updatedSigners.length > 0) {
|
||||||
|
object.set(
|
||||||
|
'Signers',
|
||||||
|
updatedSigners?.map(x => x.contactPtr)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
let updatePlaceholders = [];
|
||||||
|
for (const signer of contact) {
|
||||||
|
const placeHolder = [];
|
||||||
|
if (signer.widgets?.length > 0) {
|
||||||
|
for (const widget of signer.widgets) {
|
||||||
|
const pageNumber = widget.page;
|
||||||
|
const page = placeHolder.find(page => page.pageNumber === pageNumber);
|
||||||
|
const options = formatWidgetOptions(widget.type, widget.options);
|
||||||
|
const widgetData = {
|
||||||
|
isStamp: widget.type === 'stamp' || widget.type === 'image',
|
||||||
|
key: randomId(),
|
||||||
|
isDrag: false,
|
||||||
|
scale: 1,
|
||||||
|
isMobile: false,
|
||||||
|
zIndex: 1,
|
||||||
|
type: widget.type === 'textbox' ? 'text input' : widget.type,
|
||||||
|
options: options,
|
||||||
|
Width: widget.w,
|
||||||
|
Height: widget.h,
|
||||||
|
xPosition: widget.x,
|
||||||
|
yPosition: widget.y,
|
||||||
|
};
|
||||||
|
|
||||||
|
if (page) {
|
||||||
|
page.pos.push(widgetData);
|
||||||
|
} else {
|
||||||
|
placeHolder.push({ pageNumber, pos: [widgetData] });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
updatePlaceholders.push({
|
||||||
|
signerObjId: signer?.contactPtr?.objectId || '',
|
||||||
|
signerPtr: signer?.contactPtr,
|
||||||
|
Role: signer.role,
|
||||||
|
Id: randomId(),
|
||||||
|
blockColor: color[signer?.index],
|
||||||
|
placeHolder,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
if (updatePlaceholders?.length > 0) {
|
||||||
|
object.set('Placeholders', updatePlaceholders);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (folderId) {
|
||||||
|
object.set('Folder', {
|
||||||
|
__type: 'Pointer',
|
||||||
|
className: 'contracts_Template',
|
||||||
|
objectId: folderId,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
if (parseExtUser?.TenantId?.ActiveFileAdapter) {
|
||||||
|
object.set('FileAdapterId', parseExtUser?.TenantId?.ActiveFileAdapter);
|
||||||
|
}
|
||||||
|
const newACL = new Parse.ACL();
|
||||||
|
newACL.setPublicReadAccess(false);
|
||||||
|
newACL.setPublicWriteAccess(false);
|
||||||
|
newACL.setReadAccess(userPtr.objectId, true);
|
||||||
|
newACL.setWriteAccess(userPtr.objectId, true);
|
||||||
|
object.setACL(newACL);
|
||||||
|
const res = await object.save(null, { useMasterKey: true });
|
||||||
|
if (request.posthog) {
|
||||||
|
request.posthog?.capture({
|
||||||
|
distinctId: parseUser.userId.email,
|
||||||
|
event: 'api_draft_template',
|
||||||
|
properties: { response_code: 200 },
|
||||||
|
});
|
||||||
|
}
|
||||||
|
const JwtToken = jwt.sign(
|
||||||
|
{ user_email: parseUser.userId.email, template_id: res.id },
|
||||||
|
reqToken
|
||||||
|
);
|
||||||
|
|
||||||
|
return response.json({ objectId: res.id, url: `${baseUrl}/drafttemplate/${JwtToken}` });
|
||||||
|
} else {
|
||||||
|
return response.status(405).json({ error: 'Invalid API Token!' });
|
||||||
|
}
|
||||||
|
} catch (err) {
|
||||||
|
console.log('err ', err);
|
||||||
|
return response.status(400).json({ error: 'Something went wrong, please try again later!' });
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -73,6 +73,17 @@ import deactivateMailAdapter from './parsefunction/deactivateMailAdapter.js';
|
|||||||
import addFileAdapter from './parsefunction/addFileAdapter.js';
|
import addFileAdapter from './parsefunction/addFileAdapter.js';
|
||||||
import saveToFileAdapter from './parsefunction/saveToFileAdapter.js';
|
import saveToFileAdapter from './parsefunction/saveToFileAdapter.js';
|
||||||
import getFileAdapter from './parsefunction/getFileAdapter.js';
|
import getFileAdapter from './parsefunction/getFileAdapter.js';
|
||||||
|
import addPfxFile from './parsefunction/addPfxFile.js';
|
||||||
|
import getPfxFile from './parsefunction/getPfxFile.js';
|
||||||
|
import getTenant from './parsefunction/getTenant.js';
|
||||||
|
import getSigners from './parsefunction/getSigners.js';
|
||||||
|
import saveFile from './parsefunction/saveFile.js';
|
||||||
|
import savecontact from './parsefunction/savecontact.js';
|
||||||
|
import isUserInContactBook from './parsefunction/isUserInContactBook.js';
|
||||||
|
import updateTourStatus from './parsefunction/updateTourStatus.js';
|
||||||
|
import saveTemplate from './parsefunction/saveTemplate.js';
|
||||||
|
import updateToPublicTemplate from './parsefunction/updateToPublicTemplate.js';
|
||||||
|
import updateSignatureType from './parsefunction/updatesignaturetype.js';
|
||||||
|
|
||||||
// This afterSave function triggers after an object is added or updated in the specified class, allowing for post-processing logic.
|
// This afterSave function triggers after an object is added or updated in the specified class, allowing for post-processing logic.
|
||||||
Parse.Cloud.afterSave('contracts_Document', DocumentAftersave);
|
Parse.Cloud.afterSave('contracts_Document', DocumentAftersave);
|
||||||
@@ -158,3 +169,14 @@ Parse.Cloud.define('deactivatemailadapter', deactivateMailAdapter);
|
|||||||
Parse.Cloud.define('savetofileadapter', saveToFileAdapter);
|
Parse.Cloud.define('savetofileadapter', saveToFileAdapter);
|
||||||
Parse.Cloud.define('addfileadapter', addFileAdapter);
|
Parse.Cloud.define('addfileadapter', addFileAdapter);
|
||||||
Parse.Cloud.define('getfileadapter', getFileAdapter);
|
Parse.Cloud.define('getfileadapter', getFileAdapter);
|
||||||
|
Parse.Cloud.define('addpfx', addPfxFile);
|
||||||
|
Parse.Cloud.define('getpfx', getPfxFile);
|
||||||
|
Parse.Cloud.define('gettenant', getTenant);
|
||||||
|
Parse.Cloud.define('getsigners', getSigners);
|
||||||
|
Parse.Cloud.define('savetemplate', saveTemplate);
|
||||||
|
Parse.Cloud.define('savefile', saveFile);
|
||||||
|
Parse.Cloud.define('savecontact', savecontact);
|
||||||
|
Parse.Cloud.define('isuserincontactbook', isUserInContactBook);
|
||||||
|
Parse.Cloud.define('updatetourstatus', updateTourStatus);
|
||||||
|
Parse.Cloud.define('updatetopublictemplate', updateToPublicTemplate);
|
||||||
|
Parse.Cloud.define('updatesignaturetype', updateSignatureType);
|
||||||
|
|||||||
@@ -1,33 +1,64 @@
|
|||||||
export default async function AllowedCredits(request) {
|
import { parseJwt } from '../../Utils.js';
|
||||||
if (!request?.user) {
|
import jwt from 'jsonwebtoken';
|
||||||
throw new Parse.Error(Parse.Error.INVALID_SESSION_TOKEN, 'User is not authenticated.');
|
async function checkCredits(userId) {
|
||||||
}
|
const extUser = new Parse.Query('contracts_Users');
|
||||||
try {
|
extUser.equalTo('UserId', {
|
||||||
const extUser = new Parse.Query('contracts_Users');
|
__type: 'Pointer',
|
||||||
extUser.equalTo('UserId', {
|
className: '_User',
|
||||||
|
objectId: userId,
|
||||||
|
});
|
||||||
|
const resExtUser = await extUser.first({ useMasterKey: true });
|
||||||
|
if (resExtUser) {
|
||||||
|
const _resExtUser = JSON.parse(JSON.stringify(resExtUser));
|
||||||
|
const subscription = new Parse.Query('contracts_Subscriptions');
|
||||||
|
subscription.equalTo('TenantId', {
|
||||||
__type: 'Pointer',
|
__type: 'Pointer',
|
||||||
className: '_User',
|
className: 'partners_Tenant',
|
||||||
objectId: request.user.id,
|
objectId: _resExtUser.TenantId.objectId,
|
||||||
});
|
});
|
||||||
const resExtUser = await extUser.first({ useMasterKey: true });
|
subscription.include('ExtUserPtr');
|
||||||
if (resExtUser) {
|
const resSub = await subscription.first({ useMasterKey: true });
|
||||||
const _resExtUser = JSON.parse(JSON.stringify(resExtUser));
|
if (resSub) {
|
||||||
const subscription = new Parse.Query('contracts_Subscriptions');
|
const _resSub = JSON.parse(JSON.stringify(resSub));
|
||||||
subscription.equalTo('TenantId', {
|
const AllowedCredits = _resSub?.AllowedCredits || 0;
|
||||||
__type: 'Pointer',
|
const AddonCredits = _resSub?.AddonCredits || 0;
|
||||||
className: 'partners_Tenant',
|
return { allowedcredits: AllowedCredits, addoncredits: AddonCredits };
|
||||||
objectId: _resExtUser.TenantId.objectId,
|
}
|
||||||
});
|
} else {
|
||||||
subscription.include('ExtUserPtr');
|
throw new Parse.Error(Parse.Error.OBJECT_NOT_FOUND, 'User not found.');
|
||||||
const resSub = await subscription.first({ useMasterKey: true });
|
}
|
||||||
if (resSub) {
|
}
|
||||||
const _resSub = JSON.parse(JSON.stringify(resSub));
|
export default async function AllowedCredits(request) {
|
||||||
const AllowedCredits = _resSub?.AllowedCredits || 0;
|
const jwttoken = request?.headers?.jwttoken || '';
|
||||||
const AddonCredits = _resSub?.AddonCredits || 0;
|
|
||||||
return { allowedcredits: AllowedCredits, addoncredits: AddonCredits };
|
try {
|
||||||
|
if (request?.user) {
|
||||||
|
return await checkCredits(request.user.id);
|
||||||
|
} else if (jwttoken) {
|
||||||
|
const jwtDecode = parseJwt(jwttoken);
|
||||||
|
if (jwtDecode?.user_email) {
|
||||||
|
const userCls = new Parse.Query(Parse.User);
|
||||||
|
userCls.equalTo('email', jwtDecode?.user_email);
|
||||||
|
const userRes = await userCls.first({ useMasterKey: true });
|
||||||
|
const userId = userRes?.id;
|
||||||
|
const tokenQuery = new Parse.Query('appToken');
|
||||||
|
tokenQuery.equalTo('userId', {
|
||||||
|
__type: 'Pointer',
|
||||||
|
className: '_User',
|
||||||
|
objectId: userId,
|
||||||
|
});
|
||||||
|
const appRes = await tokenQuery.first({ useMasterKey: true });
|
||||||
|
const decoded = jwt.verify(jwttoken, appRes?.get('token'));
|
||||||
|
if (decoded?.user_email) {
|
||||||
|
return await checkCredits(userId);
|
||||||
|
} else {
|
||||||
|
throw new Parse.Error(Parse.Error.INVALID_SESSION_TOKEN, 'Invalid token.');
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
throw new Parse.Error(Parse.Error.INVALID_SESSION_TOKEN, 'Invalid token.');
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
throw new Parse.Error(Parse.Error.OBJECT_NOT_FOUND, 'User not found.');
|
throw new Parse.Error(Parse.Error.INVALID_SESSION_TOKEN, 'User is not authenticated.');
|
||||||
}
|
}
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.log('err in allowedCredits', err);
|
console.log('err in allowedCredits', err);
|
||||||
|
|||||||
@@ -1,21 +1,54 @@
|
|||||||
import axios from 'axios';
|
import axios from 'axios';
|
||||||
import { cloudServerUrl } from '../../Utils.js';
|
import { cloudServerUrl, parseJwt } from '../../Utils.js';
|
||||||
|
import jwt from 'jsonwebtoken';
|
||||||
|
|
||||||
export default async function GetTemplate(request) {
|
export default async function GetTemplate(request) {
|
||||||
const serverUrl = cloudServerUrl; //process.env.SERVER_URL;
|
const serverUrl = cloudServerUrl; //process.env.SERVER_URL;
|
||||||
const templateId = request.params.templateId;
|
const templateId = request.params.templateId;
|
||||||
const ispublic = request.params.ispublic;
|
const ispublic = request.params.ispublic;
|
||||||
|
const jwttoken = request.headers?.jwttoken;
|
||||||
|
const sessiontoken = request.headers?.sessiontoken;
|
||||||
try {
|
try {
|
||||||
if (!ispublic) {
|
if (!ispublic) {
|
||||||
const userRes = await axios.get(serverUrl + '/users/me', {
|
let userEmail;
|
||||||
headers: {
|
if (jwttoken) {
|
||||||
'X-Parse-Application-Id': process.env.APP_ID,
|
try {
|
||||||
'X-Parse-Session-Token': request.headers['sessiontoken'],
|
const jwtDecode = parseJwt(jwttoken);
|
||||||
},
|
if (jwtDecode?.user_email) {
|
||||||
});
|
const userCls = new Parse.Query(Parse.User);
|
||||||
const userId = userRes.data && userRes.data.objectId;
|
userCls.equalTo('email', jwtDecode?.user_email);
|
||||||
if (templateId && userId) {
|
const userRes = await userCls.first({ useMasterKey: true });
|
||||||
|
const userId = userRes?.id;
|
||||||
|
const tokenQuery = new Parse.Query('appToken');
|
||||||
|
tokenQuery.equalTo('userId', {
|
||||||
|
__type: 'Pointer',
|
||||||
|
className: '_User',
|
||||||
|
objectId: userId,
|
||||||
|
});
|
||||||
|
const appRes = await tokenQuery.first({ useMasterKey: true });
|
||||||
|
const decoded = jwt.verify(jwttoken, appRes?.get('token'));
|
||||||
|
if (decoded?.user_email) {
|
||||||
|
userEmail = decoded?.user_email;
|
||||||
|
} else {
|
||||||
|
return { error: 'Invalid token!' };
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
return { error: 'Invalid token!' };
|
||||||
|
}
|
||||||
|
} catch (err) {
|
||||||
|
console.log('err in jwt', err);
|
||||||
|
return { error: "You don't have access of this document!" };
|
||||||
|
}
|
||||||
|
} else if (sessiontoken) {
|
||||||
|
const userRes = await axios.get(serverUrl + '/users/me', {
|
||||||
|
headers: {
|
||||||
|
'X-Parse-Application-Id': process.env.APP_ID,
|
||||||
|
'X-Parse-Session-Token': sessiontoken,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
userEmail = userRes.data && userRes.data.email;
|
||||||
|
}
|
||||||
|
if (templateId && userEmail) {
|
||||||
try {
|
try {
|
||||||
let template = new Parse.Query('contracts_Template');
|
let template = new Parse.Query('contracts_Template');
|
||||||
template.equalTo('objectId', templateId);
|
template.equalTo('objectId', templateId);
|
||||||
@@ -24,7 +57,7 @@ export default async function GetTemplate(request) {
|
|||||||
template.include('CreatedBy');
|
template.include('CreatedBy');
|
||||||
template.include('ExtUserPtr.TenantId');
|
template.include('ExtUserPtr.TenantId');
|
||||||
const extUserQuery = new Parse.Query('contracts_Users');
|
const extUserQuery = new Parse.Query('contracts_Users');
|
||||||
extUserQuery.equalTo('Email', userRes.data.email);
|
extUserQuery.equalTo('Email', userEmail);
|
||||||
extUserQuery.include('TeamIds');
|
extUserQuery.include('TeamIds');
|
||||||
const extUser = await extUserQuery.first({ useMasterKey: true });
|
const extUser = await extUserQuery.first({ useMasterKey: true });
|
||||||
if (extUser) {
|
if (extUser) {
|
||||||
@@ -49,12 +82,14 @@ export default async function GetTemplate(request) {
|
|||||||
template.include('Signers');
|
template.include('Signers');
|
||||||
template.include('CreatedBy');
|
template.include('CreatedBy');
|
||||||
template.include('ExtUserPtr.TenantId');
|
template.include('ExtUserPtr.TenantId');
|
||||||
|
template.include('Placeholders.signerPtr');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
const res = await template.first({ useMasterKey: true });
|
const res = await template.first({ useMasterKey: true });
|
||||||
if (res) {
|
if (res) {
|
||||||
const templateRes = JSON.parse(JSON.stringify(res));
|
const templateRes = JSON.parse(JSON.stringify(res));
|
||||||
delete templateRes?.ExtUserPtr?.TenantId?.FileAdapters;
|
delete templateRes?.ExtUserPtr?.TenantId?.FileAdapters;
|
||||||
|
delete templateRes?.ExtUserPtr?.TenantId?.PfxFile;
|
||||||
return templateRes;
|
return templateRes;
|
||||||
} else {
|
} else {
|
||||||
return { error: "You don't have access of this document!" };
|
return { error: "You don't have access of this document!" };
|
||||||
@@ -63,6 +98,8 @@ export default async function GetTemplate(request) {
|
|||||||
console.log('err', err);
|
console.log('err', err);
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
return { error: "You don't have access of this document!" };
|
||||||
}
|
}
|
||||||
} else if (templateId && ispublic) {
|
} else if (templateId && ispublic) {
|
||||||
try {
|
try {
|
||||||
@@ -77,6 +114,7 @@ export default async function GetTemplate(request) {
|
|||||||
if (res) {
|
if (res) {
|
||||||
const templateRes = JSON.parse(JSON.stringify(res));
|
const templateRes = JSON.parse(JSON.stringify(res));
|
||||||
delete templateRes?.ExtUserPtr?.TenantId?.FileAdapters;
|
delete templateRes?.ExtUserPtr?.TenantId?.FileAdapters;
|
||||||
|
delete templateRes?.ExtUserPtr?.TenantId?.PfxFile;
|
||||||
return templateRes;
|
return templateRes;
|
||||||
} else {
|
} else {
|
||||||
return { error: "You don't have access of this document!" };
|
return { error: "You don't have access of this document!" };
|
||||||
@@ -90,7 +128,7 @@ export default async function GetTemplate(request) {
|
|||||||
}
|
}
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.log('err', err);
|
console.log('err', err);
|
||||||
if (err.code == 209) {
|
if (err?.response?.data?.code === 209 || err.code == 209) {
|
||||||
return { error: 'Invalid session token' };
|
return { error: 'Invalid session token' };
|
||||||
} else {
|
} else {
|
||||||
return { error: "You don't have access of this document!" };
|
return { error: "You don't have access of this document!" };
|
||||||
|
|||||||
@@ -71,6 +71,9 @@ const createDocumentFromTemplate = async (template, existContact, index) => {
|
|||||||
object.set('IsEnableOTP', template?.IsEnableOTP || false);
|
object.set('IsEnableOTP', template?.IsEnableOTP || false);
|
||||||
object.set('IsTourEnabled', template?.IsTourEnabled || false);
|
object.set('IsTourEnabled', template?.IsTourEnabled || false);
|
||||||
object.set('FileAdapterId', template?.FileAdapterId || '');
|
object.set('FileAdapterId', template?.FileAdapterId || '');
|
||||||
|
if (template?.SignatureType?.length > 0) {
|
||||||
|
object.set('SignatureType', template?.SignatureType);
|
||||||
|
}
|
||||||
let signers = template?.Signers || [];
|
let signers = template?.Signers || [];
|
||||||
const signerobj = {
|
const signerobj = {
|
||||||
__type: 'Pointer',
|
__type: 'Pointer',
|
||||||
@@ -254,6 +257,7 @@ const deductcount = async _resSub => {
|
|||||||
export default async function PublicUserLinkContactToDoc(req) {
|
export default async function PublicUserLinkContactToDoc(req) {
|
||||||
const email = req.params.email;
|
const email = req.params.email;
|
||||||
const templateid = req.params.templateid;
|
const templateid = req.params.templateid;
|
||||||
|
const signatureType = req.params.signatureType;
|
||||||
const name = req.params.name;
|
const name = req.params.name;
|
||||||
const phone = req.params.phone;
|
const phone = req.params.phone;
|
||||||
const role = req.params.role;
|
const role = req.params.role;
|
||||||
@@ -301,8 +305,11 @@ export default async function PublicUserLinkContactToDoc(req) {
|
|||||||
const existContact = await contactCls.first({ useMasterKey: true });
|
const existContact = await contactCls.first({ useMasterKey: true });
|
||||||
if (existContact) {
|
if (existContact) {
|
||||||
const template_json = JSON.parse(JSON.stringify(tempRes));
|
const template_json = JSON.parse(JSON.stringify(tempRes));
|
||||||
|
const _template_json = template_json;
|
||||||
|
_template_json.SignatureType =
|
||||||
|
signatureType?.length > 0 ? signatureType : _template_json?.SignatureType;
|
||||||
//update contact in placeholder, signers and update ACl in provide document
|
//update contact in placeholder, signers and update ACl in provide document
|
||||||
const docRes = await createDocumentFromTemplate(template_json, existContact, index);
|
const docRes = await createDocumentFromTemplate(_template_json, existContact, index);
|
||||||
if (docRes) {
|
if (docRes) {
|
||||||
await deductcount(_resSub);
|
await deductcount(_resSub);
|
||||||
//condition will execute only if sendInOrder will be false for send email to all signers at a time.
|
//condition will execute only if sendInOrder will be false for send email to all signers at a time.
|
||||||
@@ -327,9 +334,12 @@ export default async function PublicUserLinkContactToDoc(req) {
|
|||||||
TenantId: _tempRes.ExtUserPtr?.TenantId?.objectId,
|
TenantId: _tempRes.ExtUserPtr?.TenantId?.objectId,
|
||||||
};
|
};
|
||||||
const template_json = JSON.parse(JSON.stringify(tempRes));
|
const template_json = JSON.parse(JSON.stringify(tempRes));
|
||||||
|
const _template_json = template_json;
|
||||||
|
_template_json.SignatureType =
|
||||||
|
signatureType?.length > 0 ? signatureType : _template_json?.SignatureType;
|
||||||
// if user present on platform create contact on the basis of extended user details
|
// if user present on platform create contact on the basis of extended user details
|
||||||
const contactRes = await saveRoleContact(contact);
|
const contactRes = await saveRoleContact(contact);
|
||||||
const docRes = await createDocumentFromTemplate(template_json, contactRes, index);
|
const docRes = await createDocumentFromTemplate(_template_json, contactRes, index);
|
||||||
if (docRes) {
|
if (docRes) {
|
||||||
await deductcount(_resSub);
|
await deductcount(_resSub);
|
||||||
//condition will execute only if sendInOrder will be false for send email to all signers at a time.
|
//condition will execute only if sendInOrder will be false for send email to all signers at a time.
|
||||||
@@ -354,11 +364,14 @@ export default async function PublicUserLinkContactToDoc(req) {
|
|||||||
TenantId: _tempRes.ExtUserPtr?.TenantId?.objectId,
|
TenantId: _tempRes.ExtUserPtr?.TenantId?.objectId,
|
||||||
};
|
};
|
||||||
const template_json = JSON.parse(JSON.stringify(tempRes));
|
const template_json = JSON.parse(JSON.stringify(tempRes));
|
||||||
|
const _template_json = template_json;
|
||||||
|
_template_json.SignatureType =
|
||||||
|
signatureType?.length > 0 ? signatureType : _template_json?.SignatureType;
|
||||||
// Create new contract on the basis provided contact details by user and userId from _User class
|
// Create new contract on the basis provided contact details by user and userId from _User class
|
||||||
const contactRes = await saveRoleContact(contact);
|
const contactRes = await saveRoleContact(contact);
|
||||||
//update contact in placeholder, signers and update ACl in provide document
|
//update contact in placeholder, signers and update ACl in provide document
|
||||||
const docRes = await createDocumentFromTemplate(
|
const docRes = await createDocumentFromTemplate(
|
||||||
template_json,
|
_template_json,
|
||||||
contactRes,
|
contactRes,
|
||||||
index
|
index
|
||||||
);
|
);
|
||||||
@@ -391,11 +404,14 @@ export default async function PublicUserLinkContactToDoc(req) {
|
|||||||
TenantId: _tempRes.ExtUserPtr?.TenantId?.objectId,
|
TenantId: _tempRes.ExtUserPtr?.TenantId?.objectId,
|
||||||
};
|
};
|
||||||
const template_json = JSON.parse(JSON.stringify(tempRes));
|
const template_json = JSON.parse(JSON.stringify(tempRes));
|
||||||
|
const _template_json = template_json;
|
||||||
|
_template_json.SignatureType =
|
||||||
|
signatureType?.length > 0 ? signatureType : _template_json?.SignatureType;
|
||||||
// Create new contract on the basis provided contact details by user and userId from _User class
|
// Create new contract on the basis provided contact details by user and userId from _User class
|
||||||
const contactRes = await saveRoleContact(contact);
|
const contactRes = await saveRoleContact(contact);
|
||||||
//update contact in placeholder, signers and update ACl in provide document
|
//update contact in placeholder, signers and update ACl in provide document
|
||||||
const docRes = await createDocumentFromTemplate(
|
const docRes = await createDocumentFromTemplate(
|
||||||
template_json,
|
_template_json,
|
||||||
contactRes,
|
contactRes,
|
||||||
index
|
index
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -9,6 +9,49 @@ function generateId(length) {
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// `getExtUser` get ext user details
|
||||||
|
async function getExtUser(request) {
|
||||||
|
const extUserCls = new Parse.Query('contracts_Users');
|
||||||
|
extUserCls.equalTo('UserId', request.user);
|
||||||
|
extUserCls.include('TenantId');
|
||||||
|
return await extUserCls.first({ useMasterKey: true });
|
||||||
|
}
|
||||||
|
|
||||||
|
// `saveTenant` save file adapter details in tenant class
|
||||||
|
async function saveTenant(tenantId, fileAdapters, activeAdapter) {
|
||||||
|
const tenantCls = new Parse.Object('partners_Tenant');
|
||||||
|
tenantCls.id = tenantId;
|
||||||
|
if (fileAdapters?.length > 0) {
|
||||||
|
tenantCls.set('FileAdapters', fileAdapters);
|
||||||
|
}
|
||||||
|
if (activeAdapter) {
|
||||||
|
tenantCls.set('ActiveFileAdapter', activeAdapter);
|
||||||
|
} else {
|
||||||
|
tenantCls.unset('ActiveFileAdapter');
|
||||||
|
}
|
||||||
|
return await tenantCls.save(null, { useMasterKey: true });
|
||||||
|
}
|
||||||
|
|
||||||
|
// `updateTenantSchema` is used add FileAdapter in protected fields
|
||||||
|
async function updateTenantSchema() {
|
||||||
|
const tenantSchema = new Parse.Schema('partners_Tenant');
|
||||||
|
const currentSchema = await tenantSchema.get();
|
||||||
|
let clp = currentSchema.classLevelPermissions;
|
||||||
|
// Public permission ("*")
|
||||||
|
const role = '*';
|
||||||
|
if (!clp.protectedFields || Object.keys(clp.protectedFields).length === 0) {
|
||||||
|
// Initialize protectedFields if it doesn't exist
|
||||||
|
clp.protectedFields = { [role]: [] };
|
||||||
|
}
|
||||||
|
// save FileAdapters field is in protectedFields if not exists
|
||||||
|
if (!clp.protectedFields[role]?.includes('FileAdapters')) {
|
||||||
|
clp.protectedFields[role].push('FileAdapters');
|
||||||
|
// Update the class schema with the modified CLP
|
||||||
|
tenantSchema.setCLP(clp);
|
||||||
|
await tenantSchema.update();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
export default async function addFileAdapter(request) {
|
export default async function addFileAdapter(request) {
|
||||||
if (!request?.user) {
|
if (!request?.user) {
|
||||||
throw new Parse.Error(Parse.Error.INVALID_SESSION_TOKEN, 'User is not authenticated.');
|
throw new Parse.Error(Parse.Error.INVALID_SESSION_TOKEN, 'User is not authenticated.');
|
||||||
@@ -24,24 +67,15 @@ export default async function addFileAdapter(request) {
|
|||||||
|
|
||||||
if (fileAdapterName && accessKeyId && secretAccessKey && adapter) {
|
if (fileAdapterName && accessKeyId && secretAccessKey && adapter) {
|
||||||
try {
|
try {
|
||||||
const extUserCls = new Parse.Query('contracts_Users');
|
const extUser = await getExtUser(request);
|
||||||
extUserCls.equalTo('UserId', request.user);
|
|
||||||
extUserCls.include('TenantId');
|
|
||||||
const extUser = await extUserCls.first({ useMasterKey: true });
|
|
||||||
if (extUser) {
|
if (extUser) {
|
||||||
const _extUser = JSON.parse(JSON.stringify(extUser));
|
const _extUser = JSON.parse(JSON.stringify(extUser));
|
||||||
const tenantCls = new Parse.Object('partners_Tenant');
|
const tenantId = extUser?.get('TenantId')?.id;
|
||||||
tenantCls.id = extUser?.get('TenantId')?.id;
|
|
||||||
const existsFileAdaptes = _extUser?.TenantId?.FileAdapters
|
|
||||||
? _extUser?.TenantId?.FileAdapters
|
|
||||||
: [];
|
|
||||||
|
|
||||||
// assign existing file adapters or empty array
|
// assign existing file adapters or empty array
|
||||||
let updatedFileAdapters = existsFileAdaptes;
|
let fileAdapters = _extUser?.TenantId?.FileAdapters || [];
|
||||||
const uniqueId = generateId(10);
|
const uniqueId = generateId(10);
|
||||||
let id = extUser?.get('TenantId')?.id + '_' + uniqueId;
|
let id = extUser?.get('TenantId')?.id + '_' + uniqueId;
|
||||||
const index = updatedFileAdapters?.findIndex(x => x.fileAdapterName === fileAdapterName);
|
const index = fileAdapters?.findIndex(x => x.fileAdapterName === fileAdapterName);
|
||||||
|
|
||||||
if (index !== -1) {
|
if (index !== -1) {
|
||||||
// If an object with the same fileAdapterName exists, update it
|
// If an object with the same fileAdapterName exists, update it
|
||||||
if (bucketName || region || endpoint || baseUrl) {
|
if (bucketName || region || endpoint || baseUrl) {
|
||||||
@@ -51,13 +85,13 @@ export default async function addFileAdapter(request) {
|
|||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
const adapterConfig = { accessKeyId: accessKeyId, secretAccessKey: secretAccessKey };
|
const adapterConfig = { accessKeyId: accessKeyId, secretAccessKey: secretAccessKey };
|
||||||
updatedFileAdapters[index] = { ...updatedFileAdapters[index], ...adapterConfig };
|
fileAdapters[index] = { ...fileAdapters[index], ...adapterConfig };
|
||||||
id = updatedFileAdapters[index].id;
|
id = fileAdapters[index].id;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (bucketName && region && endpoint && baseUrl) {
|
if (bucketName && region && endpoint && baseUrl) {
|
||||||
// If the object with the given fileAdapterName doesn't exist, add a new one
|
// If the object with the given fileAdapterName doesn't exist, add a new one
|
||||||
updatedFileAdapters.push({
|
fileAdapters.push({
|
||||||
id: id,
|
id: id,
|
||||||
fileAdapterName: fileAdapterName,
|
fileAdapterName: fileAdapterName,
|
||||||
fileAdapter: adapter,
|
fileAdapter: adapter,
|
||||||
@@ -72,25 +106,8 @@ export default async function addFileAdapter(request) {
|
|||||||
throw new Parse.Error(Parse.Error.INVALID_QUERY, 'Please provide all parameters.');
|
throw new Parse.Error(Parse.Error.INVALID_QUERY, 'Please provide all parameters.');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
tenantCls.set('FileAdapters', updatedFileAdapters);
|
const updateTenant = await saveTenant(tenantId, fileAdapters, id);
|
||||||
if (adapter) {
|
await updateTenantSchema();
|
||||||
tenantCls.set('ActiveFileAdapter', id);
|
|
||||||
} else {
|
|
||||||
tenantCls.unset('ActiveFileAdapter');
|
|
||||||
}
|
|
||||||
const updateTenant = await tenantCls.save(null, { useMasterKey: true });
|
|
||||||
const tenantSchema = new Parse.Schema('partners_Tenant');
|
|
||||||
tenantSchema.setCLP({
|
|
||||||
get: { '*': true },
|
|
||||||
find: { '*': true },
|
|
||||||
count: { '*': true },
|
|
||||||
create: { '*': true },
|
|
||||||
update: { '*': true },
|
|
||||||
delete: { '*': true },
|
|
||||||
addField: { '*': true },
|
|
||||||
protectedFields: { '*': ['FileAdapters'] },
|
|
||||||
});
|
|
||||||
await tenantSchema.update();
|
|
||||||
const ActiveFileAdapter = adapter === 'opensign' ? 'opensign' : id;
|
const ActiveFileAdapter = adapter === 'opensign' ? 'opensign' : id;
|
||||||
return { ActiveFileAdapter: ActiveFileAdapter, updateAt: updateTenant.updatedAt };
|
return { ActiveFileAdapter: ActiveFileAdapter, updateAt: updateTenant.updatedAt };
|
||||||
} else {
|
} else {
|
||||||
@@ -104,27 +121,11 @@ export default async function addFileAdapter(request) {
|
|||||||
}
|
}
|
||||||
} else if (adapter === 'opensign') {
|
} else if (adapter === 'opensign') {
|
||||||
try {
|
try {
|
||||||
const extUserCls = new Parse.Query('contracts_Users');
|
const extUser = await getExtUser(request);
|
||||||
extUserCls.equalTo('UserId', request.user);
|
|
||||||
extUserCls.include('TenantId');
|
|
||||||
const extUser = await extUserCls.first({ useMasterKey: true });
|
|
||||||
if (extUser) {
|
if (extUser) {
|
||||||
const tenantCls = new Parse.Object('partners_Tenant');
|
const tenantId = extUser?.get('TenantId')?.id;
|
||||||
tenantCls.id = extUser?.get('TenantId')?.id;
|
const updateTenant = await saveTenant(tenantId);
|
||||||
tenantCls.unset('ActiveFileAdapter');
|
await updateTenantSchema();
|
||||||
const updateTenant = await tenantCls.save(null, { useMasterKey: true });
|
|
||||||
const tenantSchema = new Parse.Schema('partners_Tenant');
|
|
||||||
tenantSchema.setCLP({
|
|
||||||
get: { '*': true },
|
|
||||||
find: { '*': true },
|
|
||||||
count: { '*': true },
|
|
||||||
create: { '*': true },
|
|
||||||
update: { '*': true },
|
|
||||||
delete: { '*': true },
|
|
||||||
addField: { '*': true },
|
|
||||||
protectedFields: { '*': ['FileAdapters'] },
|
|
||||||
});
|
|
||||||
await tenantSchema.update();
|
|
||||||
return { ActiveFileAdapter: 'opensign', updateAt: updateTenant.updatedAt };
|
return { ActiveFileAdapter: 'opensign', updateAt: updateTenant.updatedAt };
|
||||||
} else {
|
} else {
|
||||||
throw new Parse.Error(Parse.Error.OBJECT_NOT_FOUND, 'User not found.');
|
throw new Parse.Error(Parse.Error.OBJECT_NOT_FOUND, 'User not found.');
|
||||||
|
|||||||
@@ -0,0 +1,58 @@
|
|||||||
|
// `updateTenantSchema` is used add FileAdapter in protected fields
|
||||||
|
async function updateTenantSchema() {
|
||||||
|
const tenantSchema = new Parse.Schema('partners_Tenant');
|
||||||
|
const currentSchema = await tenantSchema.get();
|
||||||
|
let clp = currentSchema.classLevelPermissions;
|
||||||
|
// Public permission ("*")
|
||||||
|
const role = '*';
|
||||||
|
if (!clp.protectedFields || Object.keys(clp.protectedFields).length === 0) {
|
||||||
|
// Initialize protectedFields if it doesn't exist
|
||||||
|
clp.protectedFields = { [role]: [] };
|
||||||
|
}
|
||||||
|
// save PfxFile field is in protectedFields if not exists
|
||||||
|
if (!clp.protectedFields[role]?.includes('PfxFile')) {
|
||||||
|
clp.protectedFields[role].push('PfxFile');
|
||||||
|
// Update the class schema with the modified CLP
|
||||||
|
tenantSchema.setCLP(clp);
|
||||||
|
await tenantSchema.update();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export default async function addPfxFile(request) {
|
||||||
|
if (!request?.user) {
|
||||||
|
throw new Parse.Error(Parse.Error.INVALID_SESSION_TOKEN, 'User is not authenticated.');
|
||||||
|
}
|
||||||
|
const pfxBase64 = request.params.pfxBase64;
|
||||||
|
const title = request.params.title;
|
||||||
|
const password = request.params.password;
|
||||||
|
const provider = request.params.provider;
|
||||||
|
if (provider === 'opensign' || (pfxBase64 && password)) {
|
||||||
|
try {
|
||||||
|
const extUserCls = new Parse.Query('contracts_Users');
|
||||||
|
extUserCls.equalTo('UserId', request.user);
|
||||||
|
extUserCls.include('TenantId');
|
||||||
|
const extUser = await extUserCls.first({ useMasterKey: true });
|
||||||
|
if (extUser) {
|
||||||
|
const tenantCls = new Parse.Object('partners_Tenant');
|
||||||
|
tenantCls.id = extUser?.get('TenantId')?.id;
|
||||||
|
if (provider === 'opensign') {
|
||||||
|
tenantCls.unset('PfxFile');
|
||||||
|
} else {
|
||||||
|
tenantCls.set('PfxFile', { title: title, password: password, base64: pfxBase64 });
|
||||||
|
}
|
||||||
|
const updateTenant = await tenantCls.save(null, { useMasterKey: true });
|
||||||
|
await updateTenantSchema();
|
||||||
|
return { updateAt: updateTenant.updatedAt };
|
||||||
|
} else {
|
||||||
|
throw new Parse.Error(Parse.Error.OBJECT_NOT_FOUND, 'User not found.');
|
||||||
|
}
|
||||||
|
} catch (err) {
|
||||||
|
console.log('Err in add custom file adapter', err);
|
||||||
|
const code = err.code || 400;
|
||||||
|
const msg = err.message || 'Something went wrong.';
|
||||||
|
throw new Parse.Error(code, msg);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
throw new Parse.Error(Parse.Error.INVALID_QUERY, 'Please provide all parameters.');
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
import axios from 'axios';
|
import axios from 'axios';
|
||||||
import { cloudServerUrl } from '../../Utils.js';
|
import { cloudServerUrl, parseJwt } from '../../Utils.js';
|
||||||
|
import jwt from 'jsonwebtoken';
|
||||||
const serverUrl = cloudServerUrl; //process.env.SERVER_URL;
|
const serverUrl = cloudServerUrl; //process.env.SERVER_URL;
|
||||||
const appId = process.env.APP_ID;
|
const appId = process.env.APP_ID;
|
||||||
const licenseKey = process.env.LICENSE_KEY;
|
const licenseKey = process.env.LICENSE_KEY;
|
||||||
@@ -30,7 +30,8 @@ async function deductcount(docsCount, extUserId, subscription) {
|
|||||||
console.log('Err in deduct in quick send', err);
|
console.log('Err in deduct in quick send', err);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
async function sendMail(document, sessionToken) {
|
async function sendMail(document) {
|
||||||
|
//sessionToken
|
||||||
const baseUrl = new URL(process.env.PUBLIC_URL);
|
const baseUrl = new URL(process.env.PUBLIC_URL);
|
||||||
|
|
||||||
// console.log("pdfDetails", pdfDetails);
|
// console.log("pdfDetails", pdfDetails);
|
||||||
@@ -57,7 +58,7 @@ async function sendMail(document, sessionToken) {
|
|||||||
const headers = {
|
const headers = {
|
||||||
'Content-Type': 'application/json',
|
'Content-Type': 'application/json',
|
||||||
'X-Parse-Application-Id': appId,
|
'X-Parse-Application-Id': appId,
|
||||||
sessionToken: sessionToken,
|
// sessionToken: sessionToken,
|
||||||
};
|
};
|
||||||
const objectId = signerMail[i]?.signerObjId;
|
const objectId = signerMail[i]?.signerObjId;
|
||||||
const hostUrl = baseUrl.origin;
|
const hostUrl = baseUrl.origin;
|
||||||
@@ -112,13 +113,232 @@ async function sendMail(document, sessionToken) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
async function callwebhookevent(document) {
|
||||||
|
const Signers = document.Signers;
|
||||||
|
const allSigner = document?.Placeholders?.map(item => {
|
||||||
|
if (item.signerObjId) {
|
||||||
|
const signer = Signers?.find(e => item?.signerPtr?.objectId === e?.objectId);
|
||||||
|
if (signer) {
|
||||||
|
return {
|
||||||
|
role: item?.Role || '',
|
||||||
|
name: signer?.Name || '',
|
||||||
|
email: signer?.Email || '',
|
||||||
|
phone: signer?.Phone || '',
|
||||||
|
};
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
return { role: item?.Role || '', name: '', email: item?.email || '', phone: '' };
|
||||||
|
}
|
||||||
|
});
|
||||||
|
const params = {
|
||||||
|
event: 'created',
|
||||||
|
body: {
|
||||||
|
objectId: document?.objectId,
|
||||||
|
file: document?.SignedUrl || document?.URL,
|
||||||
|
name: document?.Name,
|
||||||
|
note: document?.Note || '',
|
||||||
|
description: document?.Description || '',
|
||||||
|
signers: allSigner,
|
||||||
|
createdBy: document?.ExtUserPtr.Email,
|
||||||
|
createdAt: document?.createdAt,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
try {
|
||||||
|
await axios
|
||||||
|
.post(document?.ExtUserPtr?.Webhook, params, {
|
||||||
|
headers: { 'Content-Type': 'application/json' },
|
||||||
|
})
|
||||||
|
.then(res => {
|
||||||
|
try {
|
||||||
|
const webhook = new Parse.Object('contracts_Webhook');
|
||||||
|
webhook.set('Log', res?.status);
|
||||||
|
webhook.set('UserId', {
|
||||||
|
__type: 'Pointer',
|
||||||
|
className: '_User',
|
||||||
|
objectId: document.CreatedBy.objectId,
|
||||||
|
});
|
||||||
|
webhook.save(null, { useMasterKey: true });
|
||||||
|
} catch (err) {
|
||||||
|
console.log('err save in contracts_Webhook', err);
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.catch(err => {
|
||||||
|
console.log('Err send data to webhook', err?.message);
|
||||||
|
try {
|
||||||
|
const webhook = new Parse.Object('contracts_Webhook');
|
||||||
|
webhook.set('Log', err?.status);
|
||||||
|
webhook.set('UserId', {
|
||||||
|
__type: 'Pointer',
|
||||||
|
className: '_User',
|
||||||
|
objectId: document.CreatedBy.objectId,
|
||||||
|
});
|
||||||
|
webhook.save(null, { useMasterKey: true });
|
||||||
|
} catch (err) {
|
||||||
|
console.log('err save in contracts_Webhook', err?.message);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} catch (err) {
|
||||||
|
console.log('Err ', err?.message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
async function batchQuery(userId, Documents, Ip, parseConfig) {
|
||||||
|
const extCls = new Parse.Query('contracts_Users');
|
||||||
|
extCls.equalTo('UserId', {
|
||||||
|
__type: 'Pointer',
|
||||||
|
className: '_User',
|
||||||
|
objectId: userId,
|
||||||
|
});
|
||||||
|
const resExt = await extCls.first({ useMasterKey: true });
|
||||||
|
if (resExt) {
|
||||||
|
const _resExt = JSON.parse(JSON.stringify(resExt));
|
||||||
|
try {
|
||||||
|
const requests = Documents.map(x => {
|
||||||
|
const Signers = x.Signers;
|
||||||
|
const allSigner = x?.Placeholders?.map(
|
||||||
|
item => Signers?.find(e => item?.signerPtr?.objectId === e?.objectId) || item?.signerPtr
|
||||||
|
).filter(signer => Object.keys(signer).length > 0);
|
||||||
|
const date = new Date();
|
||||||
|
const isoDate = date.toISOString();
|
||||||
|
let Acl = { [x.CreatedBy.objectId]: { read: true, write: true } };
|
||||||
|
if (allSigner && allSigner.length > 0) {
|
||||||
|
allSigner.forEach(x => {
|
||||||
|
const obj = { [x.CreatedBy.objectId]: { read: true, write: true } };
|
||||||
|
Acl = { ...Acl, ...obj };
|
||||||
|
});
|
||||||
|
}
|
||||||
|
return {
|
||||||
|
method: 'POST',
|
||||||
|
path: '/app/classes/contracts_Document',
|
||||||
|
body: {
|
||||||
|
Name: x.Name,
|
||||||
|
URL: x.URL,
|
||||||
|
Note: x.Note,
|
||||||
|
Description: x.Description,
|
||||||
|
CreatedBy: x.CreatedBy,
|
||||||
|
SendinOrder: x.SendinOrder || true,
|
||||||
|
ExtUserPtr: {
|
||||||
|
__type: 'Pointer',
|
||||||
|
className: x.ExtUserPtr.className,
|
||||||
|
objectId: x.ExtUserPtr?.objectId,
|
||||||
|
},
|
||||||
|
Placeholders: x.Placeholders.map(y =>
|
||||||
|
y?.signerPtr?.objectId
|
||||||
|
? {
|
||||||
|
...y,
|
||||||
|
signerPtr: {
|
||||||
|
__type: 'Pointer',
|
||||||
|
className: 'contracts_Contactbook',
|
||||||
|
objectId: y.signerPtr.objectId,
|
||||||
|
},
|
||||||
|
signerObjId: y.signerObjId,
|
||||||
|
}
|
||||||
|
: { ...y, signerPtr: {}, signerObjId: '' }
|
||||||
|
),
|
||||||
|
SignedUrl: x.URL || x.SignedUrl,
|
||||||
|
SentToOthers: true,
|
||||||
|
Signers: allSigner?.map(y => ({
|
||||||
|
__type: 'Pointer',
|
||||||
|
className: 'contracts_Contactbook',
|
||||||
|
objectId: y.objectId,
|
||||||
|
})),
|
||||||
|
ACL: Acl,
|
||||||
|
SentToOthers: true,
|
||||||
|
RemindOnceInEvery: x.RemindOnceInEvery || 5,
|
||||||
|
AutomaticReminders: x.AutomaticReminders || false,
|
||||||
|
TimeToCompleteDays: x.TimeToCompleteDays || 15,
|
||||||
|
OriginIp: Ip,
|
||||||
|
DocSentAt: { __type: 'Date', iso: isoDate },
|
||||||
|
IsEnableOTP: x?.IsEnableOTP || false,
|
||||||
|
IsTourEnabled: x?.IsTourEnabled || false,
|
||||||
|
FileAdapterId: x?.FileAdapterId || '',
|
||||||
|
...(x?.SignatureType ? { SignatureType: x?.SignatureType } : {}),
|
||||||
|
},
|
||||||
|
};
|
||||||
|
});
|
||||||
|
// console.log('requests ', requests);
|
||||||
|
if (licenseKey) {
|
||||||
|
const subscription = new Parse.Query('contracts_Subscriptions');
|
||||||
|
subscription.equalTo('TenantId', {
|
||||||
|
__type: 'Pointer',
|
||||||
|
className: 'partners_Tenant',
|
||||||
|
objectId: _resExt.TenantId.objectId,
|
||||||
|
});
|
||||||
|
subscription.include('ExtUserPtr');
|
||||||
|
subscription.greaterThanOrEqualTo('Next_billing_date', new Date());
|
||||||
|
const resSub = await subscription.first({ useMasterKey: true });
|
||||||
|
if (resSub) {
|
||||||
|
const _resSub = JSON.parse(JSON.stringify(resSub));
|
||||||
|
const allowedCredits = _resSub?.AllowedCredits || 0;
|
||||||
|
const addonCredits = _resSub?.AddonCredits || 0;
|
||||||
|
const totalcredits = allowedCredits + addonCredits;
|
||||||
|
if (requests?.length <= totalcredits) {
|
||||||
|
const response = await axios.post('batch', { requests: requests }, parseConfig);
|
||||||
|
// Handle the batch query response
|
||||||
|
// console.log('Batch query response:', response.data);
|
||||||
|
if (response.data && response.data.length > 0) {
|
||||||
|
const updateDocuments = Documents.map((x, i) => ({
|
||||||
|
...x,
|
||||||
|
objectId: response.data[i]?.success?.objectId,
|
||||||
|
createdAt: response.data[i]?.success?.createdAt,
|
||||||
|
}));
|
||||||
|
deductcount(response.data.length, resExt.id, _resSub);
|
||||||
|
for (let i = 0; i < updateDocuments.length; i++) {
|
||||||
|
sendMail(updateDocuments[i], ''); //sessionToken
|
||||||
|
}
|
||||||
|
callwebhookevent(Documents[0]);
|
||||||
|
return 'success';
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
throw new Parse.Error(429, 'Quota reached, Please buy credits and try again later.');
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
throw new Parse.Error(
|
||||||
|
Parse.Error.INVALID_QUERY,
|
||||||
|
'Please purchase or renew your subscription.'
|
||||||
|
);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (requests?.length > 0) {
|
||||||
|
const newrequests = [requests?.[0]];
|
||||||
|
const response = await axios.post('batch', { requests: newrequests }, parseConfig);
|
||||||
|
// Handle the batch query response
|
||||||
|
// console.log('Batch query response:', response.data);
|
||||||
|
if (response.data && response.data.length > 0) {
|
||||||
|
const document = Documents?.[0];
|
||||||
|
const updateDocuments = {
|
||||||
|
...document,
|
||||||
|
objectId: response.data[0]?.success?.objectId,
|
||||||
|
createdAt: response.data[0]?.success?.createdAt,
|
||||||
|
};
|
||||||
|
deductcount(response.data.length, resExt.id);
|
||||||
|
sendMail(updateDocuments); //sessionToken
|
||||||
|
callwebhookevent(Documents[0]);
|
||||||
|
return 'success';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
const code = error?.response?.data?.code || error?.response?.status || error?.code || 400;
|
||||||
|
const msg =
|
||||||
|
error?.response?.data?.error ||
|
||||||
|
error?.response?.data ||
|
||||||
|
error?.message ||
|
||||||
|
'Something went wrong.';
|
||||||
|
console.log('Error performing batch query:', code, msg);
|
||||||
|
throw new Parse.Error(code, msg);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
throw new Parse.Error(Parse.Error.OBJECT_NOT_FOUND, 'User not found.');
|
||||||
|
}
|
||||||
|
}
|
||||||
export default async function createBatchDocs(request) {
|
export default async function createBatchDocs(request) {
|
||||||
const strDocuments = request.params.Documents;
|
const strDocuments = request.params.Documents;
|
||||||
const sessionToken = request.headers['sessiontoken'];
|
const sessionToken = request.headers?.sessiontoken;
|
||||||
|
const jwttoken = request.headers?.jwttoken;
|
||||||
const Documents = JSON.parse(strDocuments);
|
const Documents = JSON.parse(strDocuments);
|
||||||
const Ip = request?.headers?.['x-real-ip'] || '';
|
const Ip = request?.headers?.['x-real-ip'] || '';
|
||||||
const parseConfig = {
|
const parseConfig = {
|
||||||
baseURL: serverUrl, //localStorage.getItem('baseUrl'),
|
baseURL: serverUrl,
|
||||||
headers: {
|
headers: {
|
||||||
'X-Parse-Application-Id': appId,
|
'X-Parse-Application-Id': appId,
|
||||||
'X-Parse-Session-Token': sessionToken,
|
'X-Parse-Session-Token': sessionToken,
|
||||||
@@ -126,167 +346,38 @@ export default async function createBatchDocs(request) {
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
try {
|
try {
|
||||||
const user = await axios.get(serverUrl + '/users/me', {
|
if (request?.user) {
|
||||||
headers: {
|
return await batchQuery(request.user.id, Documents, Ip, parseConfig);
|
||||||
'X-Parse-Application-Id': appId,
|
} else if (jwttoken) {
|
||||||
'X-Parse-Session-Token': request.headers['sessiontoken'],
|
const jwtDecode = parseJwt(jwttoken);
|
||||||
},
|
if (jwtDecode?.user_email) {
|
||||||
});
|
const userCls = new Parse.Query(Parse.User);
|
||||||
if (user.data) {
|
userCls.equalTo('email', jwtDecode?.user_email);
|
||||||
const extCls = new Parse.Query('contracts_Users');
|
const userRes = await userCls.first({ useMasterKey: true });
|
||||||
extCls.equalTo('UserId', {
|
const userId = userRes?.id;
|
||||||
__type: 'Pointer',
|
const tokenQuery = new Parse.Query('appToken');
|
||||||
className: '_User',
|
tokenQuery.equalTo('userId', {
|
||||||
objectId: user.data.objectId,
|
__type: 'Pointer',
|
||||||
});
|
className: '_User',
|
||||||
const resExt = await extCls.first({ useMasterKey: true });
|
objectId: userId,
|
||||||
if (resExt) {
|
});
|
||||||
const _resExt = JSON.parse(JSON.stringify(resExt));
|
const appRes = await tokenQuery.first({ useMasterKey: true });
|
||||||
try {
|
const decoded = jwt.verify(jwttoken, appRes?.get('token'));
|
||||||
const requests = Documents.map(x => {
|
if (decoded?.user_email) {
|
||||||
const Signers = x.Signers;
|
return await batchQuery(userId, Documents, Ip, parseConfig);
|
||||||
const allSigner = x?.Placeholders?.map(
|
} else {
|
||||||
item =>
|
throw new Parse.Error(Parse.Error.INVALID_SESSION_TOKEN, 'Invalid token.');
|
||||||
Signers?.find(e => item?.signerPtr?.objectId === e?.objectId) || item?.signerPtr
|
|
||||||
).filter(signer => Object.keys(signer).length > 0);
|
|
||||||
const date = new Date();
|
|
||||||
const isoDate = date.toISOString();
|
|
||||||
let Acl = { [x.CreatedBy.objectId]: { read: true, write: true } };
|
|
||||||
if (allSigner && allSigner.length > 0) {
|
|
||||||
allSigner.forEach(x => {
|
|
||||||
const obj = { [x.CreatedBy.objectId]: { read: true, write: true } };
|
|
||||||
Acl = { ...Acl, ...obj };
|
|
||||||
});
|
|
||||||
}
|
|
||||||
return {
|
|
||||||
method: 'POST',
|
|
||||||
path: '/app/classes/contracts_Document',
|
|
||||||
body: {
|
|
||||||
Name: x.Name,
|
|
||||||
URL: x.URL,
|
|
||||||
Note: x.Note,
|
|
||||||
Description: x.Description,
|
|
||||||
CreatedBy: x.CreatedBy,
|
|
||||||
SendinOrder: x.SendinOrder || true,
|
|
||||||
ExtUserPtr: {
|
|
||||||
__type: 'Pointer',
|
|
||||||
className: x.ExtUserPtr.className,
|
|
||||||
objectId: x.ExtUserPtr.objectId,
|
|
||||||
},
|
|
||||||
Placeholders: x.Placeholders.map(y =>
|
|
||||||
y?.signerPtr?.objectId
|
|
||||||
? {
|
|
||||||
...y,
|
|
||||||
signerPtr: {
|
|
||||||
__type: 'Pointer',
|
|
||||||
className: 'contracts_Contactbook',
|
|
||||||
objectId: y.signerPtr.objectId,
|
|
||||||
},
|
|
||||||
signerObjId: y.signerObjId,
|
|
||||||
}
|
|
||||||
: { ...y, signerPtr: {}, signerObjId: '' }
|
|
||||||
),
|
|
||||||
SignedUrl: x.URL || x.SignedUrl,
|
|
||||||
SentToOthers: true,
|
|
||||||
Signers: allSigner?.map(y => ({
|
|
||||||
__type: 'Pointer',
|
|
||||||
className: 'contracts_Contactbook',
|
|
||||||
objectId: y.objectId,
|
|
||||||
})),
|
|
||||||
ACL: Acl,
|
|
||||||
SentToOthers: true,
|
|
||||||
RemindOnceInEvery: x.RemindOnceInEvery || 5,
|
|
||||||
AutomaticReminders: x.AutomaticReminders || false,
|
|
||||||
TimeToCompleteDays: x.TimeToCompleteDays || 15,
|
|
||||||
OriginIp: Ip,
|
|
||||||
DocSentAt: { __type: 'Date', iso: isoDate },
|
|
||||||
IsEnableOTP: x?.IsEnableOTP || false,
|
|
||||||
IsTourEnabled: x?.IsTourEnabled || false,
|
|
||||||
FileAdapterId: x?.FileAdapterId || '',
|
|
||||||
},
|
|
||||||
};
|
|
||||||
});
|
|
||||||
// console.log('requests ', requests);
|
|
||||||
if (licenseKey) {
|
|
||||||
const subscription = new Parse.Query('contracts_Subscriptions');
|
|
||||||
subscription.equalTo('TenantId', {
|
|
||||||
__type: 'Pointer',
|
|
||||||
className: 'partners_Tenant',
|
|
||||||
objectId: _resExt.TenantId.objectId,
|
|
||||||
});
|
|
||||||
subscription.include('ExtUserPtr');
|
|
||||||
subscription.greaterThanOrEqualTo('Next_billing_date', new Date());
|
|
||||||
const resSub = await subscription.first({ useMasterKey: true });
|
|
||||||
if (resSub) {
|
|
||||||
const _resSub = JSON.parse(JSON.stringify(resSub));
|
|
||||||
const allowedCredits = _resSub?.AllowedCredits || 0;
|
|
||||||
const addonCredits = _resSub?.AddonCredits || 0;
|
|
||||||
const totalcredits = allowedCredits + addonCredits;
|
|
||||||
if (requests?.length <= totalcredits) {
|
|
||||||
const response = await axios.post('batch', { requests: requests }, parseConfig);
|
|
||||||
// // Handle the batch query response
|
|
||||||
// console.log('Batch query response:', response.data);
|
|
||||||
if (response.data && response.data.length > 0) {
|
|
||||||
const updateDocuments = Documents.map((x, i) => ({
|
|
||||||
...x,
|
|
||||||
objectId: response.data[i]?.success?.objectId,
|
|
||||||
createdAt: response.data[i]?.success?.createdAt,
|
|
||||||
}));
|
|
||||||
deductcount(response.data.length, resExt.id, _resSub);
|
|
||||||
for (let i = 0; i < updateDocuments.length; i++) {
|
|
||||||
sendMail(updateDocuments[i], sessionToken);
|
|
||||||
}
|
|
||||||
return 'success';
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
throw new Parse.Error(
|
|
||||||
429,
|
|
||||||
'Quota reached, Please buy credits and try again later.'
|
|
||||||
);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
throw new Parse.Error(
|
|
||||||
Parse.Error.INVALID_QUERY,
|
|
||||||
'Please purchase or renew your subscription.'
|
|
||||||
);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if (requests?.length > 0) {
|
|
||||||
const newrequests = [requests?.[0]];
|
|
||||||
const response = await axios.post('batch', { requests: newrequests }, parseConfig);
|
|
||||||
// Handle the batch query response
|
|
||||||
// console.log('Batch query response:', response.data);
|
|
||||||
if (response.data && response.data.length > 0) {
|
|
||||||
const document = Documents?.[0];
|
|
||||||
const updateDocuments = {
|
|
||||||
...document,
|
|
||||||
objectId: response.data[0]?.success?.objectId,
|
|
||||||
createdAt: response.data[0]?.success?.createdAt,
|
|
||||||
};
|
|
||||||
deductcount(response.data.length, resExt.id);
|
|
||||||
sendMail(updateDocuments, sessionToken);
|
|
||||||
return 'success';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} catch (error) {
|
|
||||||
const code = error?.response?.data?.code || error?.response?.status || error?.code || 400;
|
|
||||||
const msg =
|
|
||||||
error?.response?.data?.error ||
|
|
||||||
error?.response?.data ||
|
|
||||||
error?.message ||
|
|
||||||
'Something went wrong.';
|
|
||||||
console.log('Error performing batch query:', code, msg);
|
|
||||||
throw new Parse.Error(code, msg);
|
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
throw new Parse.Error(Parse.Error.INVALID_SESSION_TOKEN, 'Invalid token.');
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
throw new Parse.Error(Parse.Error.OBJECT_NOT_FOUND, 'User not found.');
|
throw new Parse.Error(Parse.Error.INVALID_SESSION_TOKEN, 'User is not authenticated.');
|
||||||
}
|
}
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.log('err in createbatchdoc', err);
|
console.log('err in createbatchdoc', err);
|
||||||
const code = err?.code || 400;
|
const code = err?.code || 400;
|
||||||
const msg = err?.message || 'Something went wrong.';
|
const msg = err?.message || 'Something went wrong.';
|
||||||
new Parse.Error(code, msg);
|
throw new Parse.Error(code, msg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,10 +1,12 @@
|
|||||||
import axios from 'axios';
|
import axios from 'axios';
|
||||||
import { cloudServerUrl } from '../../Utils.js';
|
import { cloudServerUrl, parseJwt } from '../../Utils.js';
|
||||||
|
import jwt from 'jsonwebtoken';
|
||||||
|
|
||||||
export default async function getDocument(request) {
|
export default async function getDocument(request) {
|
||||||
const serverUrl = cloudServerUrl; //process.env.SERVER_URL;
|
const serverUrl = cloudServerUrl; //process.env.SERVER_URL;
|
||||||
const docId = request.params.docId;
|
const docId = request.params.docId;
|
||||||
|
const jwttoken = request?.headers?.jwttoken || '';
|
||||||
|
const sessiontoken = request?.headers?.sessiontoken || '';
|
||||||
try {
|
try {
|
||||||
if (docId) {
|
if (docId) {
|
||||||
try {
|
try {
|
||||||
@@ -23,15 +25,16 @@ export default async function getDocument(request) {
|
|||||||
const IsEnableOTP = res?.get('IsEnableOTP') || false;
|
const IsEnableOTP = res?.get('IsEnableOTP') || false;
|
||||||
const document = JSON.parse(JSON.stringify(res));
|
const document = JSON.parse(JSON.stringify(res));
|
||||||
delete document.ExtUserPtr.TenantId.FileAdapters;
|
delete document.ExtUserPtr.TenantId.FileAdapters;
|
||||||
|
delete document?.ExtUserPtr?.TenantId?.PfxFile;
|
||||||
if (!IsEnableOTP) {
|
if (!IsEnableOTP) {
|
||||||
return document;
|
return document;
|
||||||
} else {
|
} else {
|
||||||
if (request?.headers?.['sessiontoken']) {
|
if (sessiontoken) {
|
||||||
try {
|
try {
|
||||||
const userRes = await axios.get(serverUrl + '/users/me', {
|
const userRes = await axios.get(serverUrl + '/users/me', {
|
||||||
headers: {
|
headers: {
|
||||||
'X-Parse-Application-Id': process.env.APP_ID,
|
'X-Parse-Application-Id': process.env.APP_ID,
|
||||||
'X-Parse-Session-Token': request.headers['sessiontoken'],
|
'X-Parse-Session-Token': sessiontoken,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
const userId = userRes.data && userRes.data?.objectId;
|
const userId = userRes.data && userRes.data?.objectId;
|
||||||
@@ -45,6 +48,37 @@ export default async function getDocument(request) {
|
|||||||
console.log('err user in not authenticated', err);
|
console.log('err user in not authenticated', err);
|
||||||
return { error: "You don't have access of this document!" };
|
return { error: "You don't have access of this document!" };
|
||||||
}
|
}
|
||||||
|
} else if (jwttoken) {
|
||||||
|
try {
|
||||||
|
const jwtDecode = parseJwt(jwttoken);
|
||||||
|
if (jwtDecode?.user_email) {
|
||||||
|
const userCls = new Parse.Query(Parse.User);
|
||||||
|
userCls.equalTo('email', jwtDecode?.user_email);
|
||||||
|
const userRes = await userCls.first({ useMasterKey: true });
|
||||||
|
const userId = userRes?.id;
|
||||||
|
const tokenQuery = new Parse.Query('appToken');
|
||||||
|
tokenQuery.equalTo('userId', {
|
||||||
|
__type: 'Pointer',
|
||||||
|
className: '_User',
|
||||||
|
objectId: userId,
|
||||||
|
});
|
||||||
|
const appRes = await tokenQuery.first({ useMasterKey: true });
|
||||||
|
const decoded = jwt.verify(jwttoken, appRes?.get('token'));
|
||||||
|
if (decoded?.user_email) {
|
||||||
|
const acl = res.getACL();
|
||||||
|
if (userId && acl && acl.getReadAccess(userId)) {
|
||||||
|
return document;
|
||||||
|
} else {
|
||||||
|
return { error: "You don't have access of this document!" };
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
return { status: 'error', result: 'Invalid token!' };
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (err) {
|
||||||
|
console.log('err in jwt', err);
|
||||||
|
return { error: "You don't have access of this document!" };
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
return { error: "You don't have access of this document!" };
|
return { error: "You don't have access of this document!" };
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,25 @@
|
|||||||
|
export default async function getPfxFile(request) {
|
||||||
|
if (!request?.user) {
|
||||||
|
throw new Parse.Error(Parse.Error.INVALID_SESSION_TOKEN, 'User is not authenticated.');
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
const extUserCls = new Parse.Query('contracts_Users');
|
||||||
|
extUserCls.equalTo('UserId', request.user);
|
||||||
|
extUserCls.include('TenantId');
|
||||||
|
const extUser = await extUserCls.first({ useMasterKey: true });
|
||||||
|
if (extUser) {
|
||||||
|
const _extUser = JSON.parse(JSON.stringify(extUser));
|
||||||
|
const title = _extUser?.TenantId?.PfxFile?.title || '';
|
||||||
|
const pfxBase64 = _extUser?.TenantId?.PfxFile?.base64 || '';
|
||||||
|
const password = _extUser?.TenantId?.PfxFile?.password || '';
|
||||||
|
return { title: title, password: password, base64: pfxBase64 };
|
||||||
|
} else {
|
||||||
|
throw new Parse.Error(Parse.Error.OBJECT_NOT_FOUND, 'User not found.');
|
||||||
|
}
|
||||||
|
} catch (err) {
|
||||||
|
console.log('Err in add custom file adapter', err);
|
||||||
|
const code = err.code || 400;
|
||||||
|
const msg = err.message || 'Something went wrong.';
|
||||||
|
throw new Parse.Error(code, msg);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,65 @@
|
|||||||
|
import { parseJwt } from '../../Utils.js';
|
||||||
|
import jwt from 'jsonwebtoken';
|
||||||
|
|
||||||
|
export default async function getSigners(request) {
|
||||||
|
const jwttoken = request.headers.jwttoken || '';
|
||||||
|
const search = request.params.search || '';
|
||||||
|
const searchEmail = request.params.searchEmail || '';
|
||||||
|
try {
|
||||||
|
if (request.user) {
|
||||||
|
const contactbook = new Parse.Query('contracts_Contactbook');
|
||||||
|
contactbook.equalTo('CreatedBy', {
|
||||||
|
__type: 'Pointer',
|
||||||
|
className: '_User',
|
||||||
|
objectId: request?.user?.id,
|
||||||
|
});
|
||||||
|
if (search) {
|
||||||
|
contactbook.matches('Name', new RegExp(search, 'i'));
|
||||||
|
} else if (searchEmail) {
|
||||||
|
contactbook.matches('Email', new RegExp(searchEmail, 'i'));
|
||||||
|
}
|
||||||
|
contactbook.notEqualTo('IsDeleted', true);
|
||||||
|
const contactRes = await contactbook.find({ sessionToken: request.user.getSessionToken() });
|
||||||
|
const _contactRes = JSON.parse(JSON.stringify(contactRes));
|
||||||
|
return _contactRes;
|
||||||
|
} else if (jwttoken) {
|
||||||
|
const jwtDecode = parseJwt(jwttoken);
|
||||||
|
const userCls = new Parse.Query(Parse.User);
|
||||||
|
userCls.equalTo('email', jwtDecode?.user_email);
|
||||||
|
const userRes = await userCls.first({ useMasterKey: true });
|
||||||
|
const userId = userRes?.id;
|
||||||
|
const tokenQuery = new Parse.Query('appToken');
|
||||||
|
tokenQuery.equalTo('userId', {
|
||||||
|
__type: 'Pointer',
|
||||||
|
className: '_User',
|
||||||
|
objectId: userId,
|
||||||
|
});
|
||||||
|
const appRes = await tokenQuery.first({ useMasterKey: true });
|
||||||
|
const decoded = jwt.verify(jwttoken, appRes?.get('token'));
|
||||||
|
if (decoded?.user_email) {
|
||||||
|
const contactbook = new Parse.Query('contracts_Contactbook');
|
||||||
|
contactbook.equalTo('CreatedBy', {
|
||||||
|
__type: 'Pointer',
|
||||||
|
className: '_User',
|
||||||
|
objectId: userId,
|
||||||
|
});
|
||||||
|
if (search) {
|
||||||
|
contactbook.matches('Name', new RegExp(search, 'i'));
|
||||||
|
} else if (searchEmail) {
|
||||||
|
contactbook.matches('Email', new RegExp(searchEmail, 'i'));
|
||||||
|
}
|
||||||
|
contactbook.notEqualTo('IsDeleted', true);
|
||||||
|
const contactRes = await contactbook.find({ useMasterKey: true });
|
||||||
|
const _contactRes = JSON.parse(JSON.stringify(contactRes));
|
||||||
|
return _contactRes;
|
||||||
|
} else {
|
||||||
|
throw new Parse.Error(Parse.Error.INVALID_SESSION_TOKEN, 'Invalid token');
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
throw new Parse.Error(Parse.Error.INVALID_SESSION_TOKEN, 'Invalid session token');
|
||||||
|
}
|
||||||
|
} catch (err) {
|
||||||
|
console.log('err in get signers', err);
|
||||||
|
throw err;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,13 +1,57 @@
|
|||||||
import axios from 'axios';
|
import axios from 'axios';
|
||||||
import { cloudServerUrl } from '../../Utils.js';
|
import { cloudServerUrl, parseJwt } from '../../Utils.js';
|
||||||
|
import jwt from 'jsonwebtoken';
|
||||||
const serverUrl = cloudServerUrl; //process.env.SERVER_URL;
|
const serverUrl = cloudServerUrl; //process.env.SERVER_URL;
|
||||||
const appId = process.env.APP_ID;
|
const appId = process.env.APP_ID;
|
||||||
export default async function getSubscription(request) {
|
export default async function getSubscription(request) {
|
||||||
const extUserId = request.params.extUserId || '';
|
const extUserId = request.params.extUserId || '';
|
||||||
const contactId = request.params.contactId || '';
|
const contactId = request.params.contactId || '';
|
||||||
const ispublic = request.params.ispublic || false;
|
const ispublic = request.params.ispublic || false;
|
||||||
|
const jwttoken = request.headers?.jwttoken || '';
|
||||||
|
|
||||||
if (extUserId) {
|
if (jwttoken) {
|
||||||
|
const jwtDecode = parseJwt(jwttoken);
|
||||||
|
if (jwtDecode?.user_email) {
|
||||||
|
const verifyToken = jwttoken;
|
||||||
|
const userCls = new Parse.Query(Parse.User);
|
||||||
|
userCls.equalTo('email', jwtDecode?.user_email);
|
||||||
|
const userRes = await userCls.first({ useMasterKey: true });
|
||||||
|
const userId = userRes?.id;
|
||||||
|
const tokenQuery = new Parse.Query('appToken');
|
||||||
|
tokenQuery.equalTo('userId', {
|
||||||
|
__type: 'Pointer',
|
||||||
|
className: '_User',
|
||||||
|
objectId: userId,
|
||||||
|
});
|
||||||
|
const appRes = await tokenQuery.first({ useMasterKey: true });
|
||||||
|
const decoded = jwt.verify(verifyToken, appRes?.get('token'));
|
||||||
|
if (decoded?.user_email) {
|
||||||
|
const extCls = new Parse.Query('contracts_Users');
|
||||||
|
extCls.equalTo('Email', decoded?.user_email);
|
||||||
|
const exUser = await extCls.first({ useMasterKey: true });
|
||||||
|
if (exUser) {
|
||||||
|
const subscriptionCls = new Parse.Query('contracts_Subscriptions');
|
||||||
|
subscriptionCls.equalTo('TenantId', {
|
||||||
|
__type: 'Pointer',
|
||||||
|
className: 'partners_Tenant',
|
||||||
|
objectId: exUser.get('TenantId').id,
|
||||||
|
});
|
||||||
|
subscriptionCls.descending('createdAt');
|
||||||
|
const subcripitions = await subscriptionCls.first({ useMasterKey: true });
|
||||||
|
if (subcripitions) {
|
||||||
|
const _subcripitions = JSON.parse(JSON.stringify(subcripitions));
|
||||||
|
return { status: 'success', result: _subcripitions };
|
||||||
|
} else {
|
||||||
|
return { status: 'success', result: {} };
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
return { status: 'error', result: 'User not found!' };
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
return { status: 'error', result: 'Invalid token!' };
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else if (extUserId) {
|
||||||
try {
|
try {
|
||||||
let userId;
|
let userId;
|
||||||
//`ispublic` is used in public profile to get subscription details
|
//`ispublic` is used in public profile to get subscription details
|
||||||
|
|||||||
@@ -0,0 +1,83 @@
|
|||||||
|
import { parseJwt } from '../../Utils.js';
|
||||||
|
import jwt from 'jsonwebtoken';
|
||||||
|
|
||||||
|
async function getTenantByUserId(userId, contactId) {
|
||||||
|
try {
|
||||||
|
if (contactId) {
|
||||||
|
const contactquery = new Parse.Query('contracts_Contactbook');
|
||||||
|
contactquery.equalTo('objectId', contactId);
|
||||||
|
const contactuser = await contactquery.first({ useMasterKey: true });
|
||||||
|
if (contactuser) {
|
||||||
|
const tenantId = contactuser?.get('TenantId')?.id;
|
||||||
|
if (tenantId) {
|
||||||
|
const tenantCreditsQuery = new Parse.Query('partners_Tenant');
|
||||||
|
tenantCreditsQuery.equalTo('objectId', tenantId);
|
||||||
|
tenantCreditsQuery.exclude('FileAdapters,PfxFile,ContactNumber');
|
||||||
|
const res = await tenantCreditsQuery.first({ useMasterKey: true });
|
||||||
|
return res;
|
||||||
|
} else {
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
const query = new Parse.Query('contracts_Users');
|
||||||
|
query.equalTo('UserId', {
|
||||||
|
__type: 'Pointer',
|
||||||
|
className: '_User',
|
||||||
|
objectId: userId,
|
||||||
|
});
|
||||||
|
const extuser = await query.first({ useMasterKey: true });
|
||||||
|
if (extuser) {
|
||||||
|
const user = extuser?.get('CreatedBy')?.id || userId;
|
||||||
|
const tenantCreditsQuery = new Parse.Query('partners_Tenant');
|
||||||
|
tenantCreditsQuery.equalTo('UserId', {
|
||||||
|
__type: 'Pointer',
|
||||||
|
className: '_User',
|
||||||
|
objectId: user,
|
||||||
|
});
|
||||||
|
tenantCreditsQuery.exclude('FileAdapters,PfxFile');
|
||||||
|
const res = await tenantCreditsQuery.first({ useMasterKey: true });
|
||||||
|
return res;
|
||||||
|
} else {
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (err) {
|
||||||
|
console.log('err in getTenant ', err);
|
||||||
|
return 'user does not exist!';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
export default async function getTenant(request) {
|
||||||
|
const jwttoken = request.headers.jwttoken || '';
|
||||||
|
const userId = request.params.userId || '';
|
||||||
|
const contactId = request.params.contactId || '';
|
||||||
|
if (jwttoken) {
|
||||||
|
const jwtDecode = parseJwt(jwttoken);
|
||||||
|
if (jwtDecode?.user_email) {
|
||||||
|
const verifyToken = jwttoken;
|
||||||
|
const userCls = new Parse.Query(Parse.User);
|
||||||
|
userCls.equalTo('email', jwtDecode?.user_email);
|
||||||
|
const userRes = await userCls.first({ useMasterKey: true });
|
||||||
|
const apiUserId = userRes?.id;
|
||||||
|
const tokenQuery = new Parse.Query('appToken');
|
||||||
|
tokenQuery.equalTo('userId', {
|
||||||
|
__type: 'Pointer',
|
||||||
|
className: '_User',
|
||||||
|
objectId: apiUserId,
|
||||||
|
});
|
||||||
|
const appRes = await tokenQuery.first({ useMasterKey: true });
|
||||||
|
const decoded = jwt.verify(verifyToken, appRes?.get('token'));
|
||||||
|
if (decoded?.user_email) {
|
||||||
|
return await getTenantByUserId(apiUserId, contactId);
|
||||||
|
} else {
|
||||||
|
return { status: 'error', result: 'Invalid token!' };
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else if (userId || contactId) {
|
||||||
|
return await getTenantByUserId(userId, contactId);
|
||||||
|
} else {
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,5 +1,9 @@
|
|||||||
|
import { parseJwt } from '../../Utils.js';
|
||||||
|
import jwt from 'jsonwebtoken';
|
||||||
|
|
||||||
async function getUserDetails(request) {
|
async function getUserDetails(request) {
|
||||||
const reqEmail = request.params.email;
|
const reqEmail = request.params.email;
|
||||||
|
const jwttoken = request?.headers?.jwttoken || '';
|
||||||
if (reqEmail || request.user) {
|
if (reqEmail || request.user) {
|
||||||
try {
|
try {
|
||||||
const userId = request.params.userId;
|
const userId = request.params.userId;
|
||||||
@@ -16,6 +20,7 @@ async function getUserDetails(request) {
|
|||||||
userQuery.exclude('CreatedBy.authData');
|
userQuery.exclude('CreatedBy.authData');
|
||||||
userQuery.exclude('TenantId.FileAdapters');
|
userQuery.exclude('TenantId.FileAdapters');
|
||||||
userQuery.exclude('google_refresh_token');
|
userQuery.exclude('google_refresh_token');
|
||||||
|
userQuery.exclude('TenantId.PfxFile');
|
||||||
if (userId) {
|
if (userId) {
|
||||||
userQuery.equalTo('CreatedBy', { __type: 'Pointer', className: '_User', objectId: userId });
|
userQuery.equalTo('CreatedBy', { __type: 'Pointer', className: '_User', objectId: userId });
|
||||||
}
|
}
|
||||||
@@ -35,6 +40,48 @@ async function getUserDetails(request) {
|
|||||||
const msg = err?.message || 'Something went wrong.';
|
const msg = err?.message || 'Something went wrong.';
|
||||||
throw new Parse.Error(code, msg);
|
throw new Parse.Error(code, msg);
|
||||||
}
|
}
|
||||||
|
} else if (jwttoken) {
|
||||||
|
const jwtDecode = parseJwt(jwttoken);
|
||||||
|
if (jwtDecode?.user_email) {
|
||||||
|
const userCls = new Parse.Query(Parse.User);
|
||||||
|
userCls.equalTo('email', jwtDecode?.user_email);
|
||||||
|
const userRes = await userCls.first({ useMasterKey: true });
|
||||||
|
const userId = userRes?.id;
|
||||||
|
const tokenQuery = new Parse.Query('appToken');
|
||||||
|
tokenQuery.equalTo('userId', {
|
||||||
|
__type: 'Pointer',
|
||||||
|
className: '_User',
|
||||||
|
objectId: userId,
|
||||||
|
});
|
||||||
|
const appRes = await tokenQuery.first({ useMasterKey: true });
|
||||||
|
const decoded = jwt.verify(jwttoken, appRes?.get('token'));
|
||||||
|
if (decoded?.user_email) {
|
||||||
|
try {
|
||||||
|
const userQuery = new Parse.Query('contracts_Users');
|
||||||
|
userQuery.equalTo('Email', decoded?.user_email);
|
||||||
|
userQuery.include('TenantId');
|
||||||
|
userQuery.include('UserId');
|
||||||
|
userQuery.include('CreatedBy');
|
||||||
|
userQuery.exclude('CreatedBy.authData');
|
||||||
|
userQuery.exclude('TenantId.FileAdapters');
|
||||||
|
userQuery.exclude('google_refresh_token');
|
||||||
|
userQuery.exclude('TenantId.PfxFile');
|
||||||
|
const res = await userQuery.first({ useMasterKey: true });
|
||||||
|
if (res) {
|
||||||
|
return res;
|
||||||
|
} else {
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
} catch (err) {
|
||||||
|
console.log('Err ', err);
|
||||||
|
const code = err?.code || 400;
|
||||||
|
const msg = err?.message || 'Something went wrong.';
|
||||||
|
throw new Parse.Error(code, msg);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
return { status: 'error', result: 'Invalid token!' };
|
||||||
|
}
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
throw new Parse.Error(Parse.Error.INVALID_SESSION_TOKEN, 'User is not authenticated.');
|
throw new Parse.Error(Parse.Error.INVALID_SESSION_TOKEN, 'User is not authenticated.');
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,47 @@
|
|||||||
|
import { parseJwt } from '../../Utils.js';
|
||||||
|
import jwt from 'jsonwebtoken';
|
||||||
|
|
||||||
|
export default async function isUserInContactBook(request) {
|
||||||
|
try {
|
||||||
|
const jwttoken = request.headers.jwttoken;
|
||||||
|
if (jwttoken) {
|
||||||
|
const jwtDecode = parseJwt(jwttoken);
|
||||||
|
const userCls = new Parse.Query(Parse.User);
|
||||||
|
userCls.equalTo('email', jwtDecode?.user_email);
|
||||||
|
const userRes = await userCls.first({ useMasterKey: true });
|
||||||
|
const userId = userRes?.id;
|
||||||
|
const tokenQuery = new Parse.Query('appToken');
|
||||||
|
tokenQuery.equalTo('userId', {
|
||||||
|
__type: 'Pointer',
|
||||||
|
className: '_User',
|
||||||
|
objectId: userId,
|
||||||
|
});
|
||||||
|
const appRes = await tokenQuery.first({ useMasterKey: true });
|
||||||
|
const decoded = jwt.verify(jwttoken, appRes?.get('token'));
|
||||||
|
if (decoded?.user_email) {
|
||||||
|
const email = userRes?.get('email');
|
||||||
|
const userPtr = { __type: 'Pointer', className: '_User', objectId: userId };
|
||||||
|
const query = new Parse.Query('contracts_Contactbook');
|
||||||
|
query.equalTo('CreatedBy', userPtr);
|
||||||
|
query.notEqualTo('IsDeleted', true);
|
||||||
|
query.equalTo('Email', email);
|
||||||
|
const res = await query.first({ useMasterKey: true });
|
||||||
|
return res;
|
||||||
|
} else {
|
||||||
|
throw new Parse.Error(Parse.Error.INVALID_SESSION_TOKEN, 'Invalid token');
|
||||||
|
}
|
||||||
|
} else if (request.user) {
|
||||||
|
const email = request.user.get('email');
|
||||||
|
const userPtr = { __type: 'Pointer', className: '_User', objectId: request.user?.id };
|
||||||
|
const query = new Parse.Query('contracts_Contactbook');
|
||||||
|
query.equalTo('CreatedBy', userPtr);
|
||||||
|
query.notEqualTo('IsDeleted', true);
|
||||||
|
query.equalTo('Email', email);
|
||||||
|
const res = await query.first({ sessionToken: request.user.getSessionToken() });
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
} catch (err) {
|
||||||
|
console.log('err', err);
|
||||||
|
throw err;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -102,8 +102,16 @@ async function sendCompletedMail(obj) {
|
|||||||
const sender = obj.doc.ExtUserPtr;
|
const sender = obj.doc.ExtUserPtr;
|
||||||
const pdfName = doc.Name;
|
const pdfName = doc.Name;
|
||||||
const mailLogo = 'https://qikinnovation.ams3.digitaloceanspaces.com/logo.png';
|
const mailLogo = 'https://qikinnovation.ams3.digitaloceanspaces.com/logo.png';
|
||||||
const recipient =
|
let signersMail;
|
||||||
doc?.Signers?.length > 0 ? doc?.Signers?.map(x => x?.Email)?.join(',') : sender.Email;
|
if (doc?.Signers?.length > 0) {
|
||||||
|
const isOwnerExistsinSigners = doc?.Signers?.find(x => x.Email === sender.Email);
|
||||||
|
signersMail = isOwnerExistsinSigners
|
||||||
|
? doc?.Signers?.map(x => x?.Email)?.join(',')
|
||||||
|
: [...doc?.Signers?.map(x => x?.Email), sender.Email]?.join(',');
|
||||||
|
} else {
|
||||||
|
signersMail = sender.Email;
|
||||||
|
}
|
||||||
|
const recipient = signersMail;
|
||||||
let subject = `Document "${pdfName}" has been signed by all parties`;
|
let subject = `Document "${pdfName}" has been signed by all parties`;
|
||||||
let body =
|
let body =
|
||||||
"<html><head><meta http-equiv='Content-Type' content='text/html; charset=UTF-8' /></head><body> <div style='background-color:#f5f5f5;padding:20px'> <div style='box-shadow: rgba(0, 0, 0, 0.1) 0px 4px 12px;background-color:white;'> <div><img src=" +
|
"<html><head><meta http-equiv='Content-Type' content='text/html; charset=UTF-8' /></head><body> <div style='background-color:#f5f5f5;padding:20px'> <div style='box-shadow: rgba(0, 0, 0, 0.1) 0px 4px 12px;background-color:white;'> <div><img src=" +
|
||||||
@@ -245,7 +253,11 @@ async function sendDoctoWebhook(doc, Url, event, signUser, certificateUrl) {
|
|||||||
async function sendMailsaveCertifcate(doc, P12Buffer, isCustomMail, mailProvider, adapterConfig) {
|
async function sendMailsaveCertifcate(doc, P12Buffer, isCustomMail, mailProvider, adapterConfig) {
|
||||||
const certificate = await GenerateCertificate(doc);
|
const certificate = await GenerateCertificate(doc);
|
||||||
const certificatePdf = await PDFDocument.load(certificate);
|
const certificatePdf = await PDFDocument.load(certificate);
|
||||||
const p12 = new P12Signer(P12Buffer, { passphrase: process.env.PASS_PHRASE || null });
|
let passphrase = process.env.PASS_PHRASE;
|
||||||
|
if (doc?.ExtUserPtr?.TenantId?.PfxFile?.password) {
|
||||||
|
passphrase = doc?.ExtUserPtr?.TenantId?.PfxFile?.password;
|
||||||
|
}
|
||||||
|
const p12 = new P12Signer(P12Buffer, { passphrase: passphrase || null });
|
||||||
// `pdflibAddPlaceholder` is used to add code of only digitial sign in certificate
|
// `pdflibAddPlaceholder` is used to add code of only digitial sign in certificate
|
||||||
pdflibAddPlaceholder({
|
pdflibAddPlaceholder({
|
||||||
pdfDoc: certificatePdf,
|
pdfDoc: certificatePdf,
|
||||||
@@ -312,13 +324,16 @@ async function PDF(req) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
const _resDoc = resDoc?.toJSON();
|
const _resDoc = resDoc?.toJSON();
|
||||||
// `FileAdapter` && `ActiveFileAdapter` is used to save file in user's fileAdapter
|
// `fileAdapterId` is used check document uploaded in custom file adapter and get customFileAdapter id
|
||||||
const ActiveFileAdapter = _resDoc?.ExtUserPtr?.TenantId?.ActiveFileAdapter;
|
const fileAdapterId = _resDoc?.FileAdapterId || '';
|
||||||
const FileAdapter =
|
|
||||||
_resDoc?.ExtUserPtr?.TenantId?.FileAdapters?.find(x => x.id === ActiveFileAdapter) || {};
|
|
||||||
let adapterConfig = {};
|
let adapterConfig = {};
|
||||||
if (FileAdapter && ActiveFileAdapter) {
|
if (fileAdapterId) {
|
||||||
adapterConfig = { ActiveFileAdapter: ActiveFileAdapter, ...FileAdapter };
|
// `FileAdapter` is used to credintials of file adapter
|
||||||
|
const FileAdapter =
|
||||||
|
_resDoc?.ExtUserPtr?.TenantId?.FileAdapters?.find(x => x.id === fileAdapterId) || {};
|
||||||
|
if (FileAdapter) {
|
||||||
|
adapterConfig = FileAdapter;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
let signUser;
|
let signUser;
|
||||||
let className;
|
let className;
|
||||||
@@ -341,10 +356,15 @@ async function PDF(req) {
|
|||||||
// `PdfBuffer` used to create buffer from pdf file
|
// `PdfBuffer` used to create buffer from pdf file
|
||||||
let PdfBuffer = Buffer.from(req.params.pdfFile, 'base64');
|
let PdfBuffer = Buffer.from(req.params.pdfFile, 'base64');
|
||||||
// `P12Buffer` used to create buffer from p12 certificate
|
// `P12Buffer` used to create buffer from p12 certificate
|
||||||
const pfxFile = process.env.PFX_BASE64;
|
let pfxFile = process.env.PFX_BASE64;
|
||||||
|
let passphrase = process.env.PASS_PHRASE;
|
||||||
|
if (_resDoc?.ExtUserPtr?.TenantId?.PfxFile?.base64) {
|
||||||
|
pfxFile = _resDoc?.ExtUserPtr?.TenantId?.PfxFile?.base64;
|
||||||
|
passphrase = _resDoc?.ExtUserPtr?.TenantId?.PfxFile?.password;
|
||||||
|
}
|
||||||
// const P12Buffer = fs.readFileSync();
|
// const P12Buffer = fs.readFileSync();
|
||||||
const P12Buffer = Buffer.from(pfxFile, 'base64');
|
const P12Buffer = Buffer.from(pfxFile, 'base64');
|
||||||
const p12Cert = new P12Signer(P12Buffer, { passphrase: process.env.PASS_PHRASE || null });
|
const p12Cert = new P12Signer(P12Buffer, { passphrase: passphrase || null });
|
||||||
const UserPtr = { __type: 'Pointer', className: className, objectId: signUser.objectId };
|
const UserPtr = { __type: 'Pointer', className: className, objectId: signUser.objectId };
|
||||||
const obj = { UserPtr: UserPtr, SignedUrl: '', Activity: 'Signed', ipAddress: userIP };
|
const obj = { UserPtr: UserPtr, SignedUrl: '', Activity: 'Signed', ipAddress: userIP };
|
||||||
let updateAuditTrail;
|
let updateAuditTrail;
|
||||||
@@ -364,7 +384,8 @@ async function PDF(req) {
|
|||||||
isCompleted = true;
|
isCompleted = true;
|
||||||
}
|
}
|
||||||
const randomNumber = Math.floor(Math.random() * 5000);
|
const randomNumber = Math.floor(Math.random() * 5000);
|
||||||
const name = `exported_file_${randomNumber}.pdf`;
|
const docName = _resDoc?.Name?.replace(/[^a-zA-Z0-9._-]/g, '_')?.toLowerCase();
|
||||||
|
const name = `signed_${docName}_${randomNumber}.pdf`;
|
||||||
const filePath = `./exports/${name}`;
|
const filePath = `./exports/${name}`;
|
||||||
let pdfSize = PdfBuffer.length;
|
let pdfSize = PdfBuffer.length;
|
||||||
if (isCompleted) {
|
if (isCompleted) {
|
||||||
|
|||||||
@@ -0,0 +1,131 @@
|
|||||||
|
import uploadFileToS3 from './uploadFiletoS3.js';
|
||||||
|
import { parseJwt } from '../../Utils.js';
|
||||||
|
import jwt from 'jsonwebtoken';
|
||||||
|
export default async function saveFile(request) {
|
||||||
|
const jwttoken = request.headers.jwttoken || '';
|
||||||
|
|
||||||
|
if (!request.params.fileBase64) {
|
||||||
|
throw new Parse.Error(Parse.Error.INVALID_QUERY, 'Please provide file.');
|
||||||
|
}
|
||||||
|
const fileBase64 = request.params.fileBase64;
|
||||||
|
const id = request.params.id;
|
||||||
|
try {
|
||||||
|
if (request.user) {
|
||||||
|
const extCls = new Parse.Query('contracts_Users');
|
||||||
|
extCls.equalTo('UserId', request.user);
|
||||||
|
extCls.include('TenantId');
|
||||||
|
const resExt = await extCls.first({ useMasterKey: true });
|
||||||
|
if (resExt) {
|
||||||
|
const _resExt = JSON.parse(JSON.stringify(resExt));
|
||||||
|
const fileAdapters = _resExt?.TenantId.FileAdapters || [];
|
||||||
|
const fileAdapter = fileAdapters?.find(x => x.id === id) || {};
|
||||||
|
if (fileAdapter?.accessKeyId) {
|
||||||
|
const adapterConfig = {
|
||||||
|
id: id,
|
||||||
|
fileAdapter: fileAdapter?.fileAdapter,
|
||||||
|
bucketName: fileAdapter?.bucketName,
|
||||||
|
region: fileAdapter?.region,
|
||||||
|
endpoint: fileAdapter?.endpoint,
|
||||||
|
accessKeyId: fileAdapter?.accessKeyId,
|
||||||
|
secretAccessKey: fileAdapter?.secretAccessKey,
|
||||||
|
baseUrl: fileAdapter?.baseUrl,
|
||||||
|
};
|
||||||
|
const buffer = Buffer.from(fileBase64, 'base64');
|
||||||
|
const fileName = request.params.fileName;
|
||||||
|
const ext = request.params.fileName?.split('.')?.pop();
|
||||||
|
let mimeType;
|
||||||
|
if (ext === 'pdf') {
|
||||||
|
mimeType = 'application/pdf';
|
||||||
|
} else if (ext === 'png' || ext === 'jpeg' || ext === 'jpg') {
|
||||||
|
mimeType = `image/${ext}`;
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
const presignedUrl = await uploadFileToS3(buffer, fileName, mimeType, adapterConfig);
|
||||||
|
return { url: presignedUrl };
|
||||||
|
} catch (err) {
|
||||||
|
console.error('Error generate presigned url:', err);
|
||||||
|
const msg = 'Fileadapter credentials are invalid.';
|
||||||
|
throw new Parse.Error(400, msg);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
const fileName = request.params.fileName;
|
||||||
|
const pdfFile = new Parse.File(fileName, { base64: fileBase64 });
|
||||||
|
// Save the Parse File if needed
|
||||||
|
const pdfData = await pdfFile.save({ useMasterKey: true });
|
||||||
|
const presignedUrl = pdfData.url();
|
||||||
|
return { url: presignedUrl };
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
throw new Parse.Error(Parse.Error.OBJECT_NOT_FOUND, 'User not found.');
|
||||||
|
}
|
||||||
|
} else if (jwttoken) {
|
||||||
|
const jwtDecode = parseJwt(jwttoken);
|
||||||
|
const userCls = new Parse.Query(Parse.User);
|
||||||
|
userCls.equalTo('email', jwtDecode?.user_email);
|
||||||
|
const userRes = await userCls.first({ useMasterKey: true });
|
||||||
|
const userId = userRes?.id;
|
||||||
|
const tokenQuery = new Parse.Query('appToken');
|
||||||
|
tokenQuery.equalTo('userId', {
|
||||||
|
__type: 'Pointer',
|
||||||
|
className: '_User',
|
||||||
|
objectId: userId,
|
||||||
|
});
|
||||||
|
const appRes = await tokenQuery.first({ useMasterKey: true });
|
||||||
|
const decoded = jwt.verify(jwttoken, appRes?.get('token'));
|
||||||
|
if (decoded?.user_email) {
|
||||||
|
const extCls = new Parse.Query('contracts_Users');
|
||||||
|
extCls.equalTo('Email', decoded?.user_email);
|
||||||
|
extCls.include('TenantId');
|
||||||
|
const resExt = await extCls.first({ useMasterKey: true });
|
||||||
|
if (resExt) {
|
||||||
|
const _resExt = JSON.parse(JSON.stringify(resExt));
|
||||||
|
const fileAdapters = _resExt?.TenantId.FileAdapters || [];
|
||||||
|
const fileAdapter = fileAdapters?.find(x => x.id === id) || {};
|
||||||
|
if (fileAdapter?.accessKeyId) {
|
||||||
|
const adapterConfig = {
|
||||||
|
id: id,
|
||||||
|
fileAdapter: fileAdapter?.fileAdapter,
|
||||||
|
bucketName: fileAdapter?.bucketName,
|
||||||
|
region: fileAdapter?.region,
|
||||||
|
endpoint: fileAdapter?.endpoint,
|
||||||
|
accessKeyId: fileAdapter?.accessKeyId,
|
||||||
|
secretAccessKey: fileAdapter?.secretAccessKey,
|
||||||
|
baseUrl: fileAdapter?.baseUrl,
|
||||||
|
};
|
||||||
|
const buffer = Buffer.from(fileBase64, 'base64');
|
||||||
|
const fileName = request.params.fileName;
|
||||||
|
const ext = request.params.fileName?.split('.')?.pop();
|
||||||
|
let mimeType;
|
||||||
|
if (ext === 'pdf') {
|
||||||
|
mimeType = 'application/pdf';
|
||||||
|
} else if (ext === 'png' || ext === 'jpeg' || ext === 'jpg') {
|
||||||
|
mimeType = `image/${ext}`;
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
const presignedUrl = await uploadFileToS3(buffer, fileName, mimeType, adapterConfig);
|
||||||
|
return { url: presignedUrl };
|
||||||
|
} catch (err) {
|
||||||
|
console.error('Error generate presigned url:', err);
|
||||||
|
const msg = 'Fileadapter credentials are invalid.';
|
||||||
|
throw new Parse.Error(400, msg);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
const fileName = request.params.fileName;
|
||||||
|
const pdfFile = new Parse.File(fileName, { base64: fileBase64 });
|
||||||
|
// Save the Parse File if needed
|
||||||
|
const pdfData = await pdfFile.save({ useMasterKey: true });
|
||||||
|
const presignedUrl = pdfData.url();
|
||||||
|
return { url: presignedUrl };
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
throw new Parse.Error(Parse.Error.OBJECT_NOT_FOUND, 'User not found.');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
throw new Parse.Error(Parse.Error.INVALID_SESSION_TOKEN, 'User is not authenticated.');
|
||||||
|
}
|
||||||
|
} catch (err) {
|
||||||
|
console.log('err in savetoS3', err);
|
||||||
|
throw err;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,114 @@
|
|||||||
|
import { parseJwt } from '../../Utils.js';
|
||||||
|
import jwt from 'jsonwebtoken';
|
||||||
|
|
||||||
|
async function updateTemplate(template, isJwt = false) {
|
||||||
|
try {
|
||||||
|
if (template?.Id) {
|
||||||
|
const updateTemplate = new Parse.Object('contracts_Template');
|
||||||
|
updateTemplate.id = template.Id;
|
||||||
|
if (template?.URL) {
|
||||||
|
updateTemplate.set('URL', template.URL);
|
||||||
|
}
|
||||||
|
if (template?.Name) {
|
||||||
|
updateTemplate.set('Name', template.Name);
|
||||||
|
}
|
||||||
|
if (template?.Note) {
|
||||||
|
updateTemplate.set('Note', template.Note);
|
||||||
|
}
|
||||||
|
if (template?.Description) {
|
||||||
|
updateTemplate.set('Description', template.Description);
|
||||||
|
}
|
||||||
|
if (template?.SendinOrder) {
|
||||||
|
updateTemplate.set('SendinOrder', template.SendinOrder);
|
||||||
|
}
|
||||||
|
if (template?.AutomaticReminders) {
|
||||||
|
updateTemplate.set('AutomaticReminders', template.AutomaticReminders);
|
||||||
|
}
|
||||||
|
if (template?.RemindOnceInEvery) {
|
||||||
|
updateTemplate.set('RemindOnceInEvery', template.RemindOnceInEvery);
|
||||||
|
}
|
||||||
|
if (template?.NextReminderDate) {
|
||||||
|
updateTemplate.set('NextReminderDate', new Date(template.NextReminderDate));
|
||||||
|
}
|
||||||
|
if (template?.IsEnableOTP) {
|
||||||
|
updateTemplate.set('IsEnableOTP', template.IsEnableOTP);
|
||||||
|
}
|
||||||
|
if (template?.IsTourEnabled) {
|
||||||
|
updateTemplate.set('IsTourEnabled', template.IsTourEnabled);
|
||||||
|
}
|
||||||
|
const isPublic = template?.IsPublic !== undefined ? template?.IsPublic : false;
|
||||||
|
if (template?.IsPublic !== undefined) {
|
||||||
|
updateTemplate.set('IsPublic', isPublic);
|
||||||
|
}
|
||||||
|
updateTemplate.set('Placeholders', template.Placeholders);
|
||||||
|
updateTemplate.set('Signers', template.Signers);
|
||||||
|
if (template?.SignatureType?.length > 0) {
|
||||||
|
updateTemplate.set('SignatureType', template.SignatureType);
|
||||||
|
}
|
||||||
|
|
||||||
|
let updateTemplateRes;
|
||||||
|
if (isJwt) {
|
||||||
|
updateTemplateRes = await updateTemplate.save(null, { useMasterKey: true });
|
||||||
|
} else {
|
||||||
|
updateTemplateRes = await updateTemplate.save();
|
||||||
|
}
|
||||||
|
return updateTemplateRes;
|
||||||
|
} else {
|
||||||
|
throw new Parse.Error(Parse.Error.INVALID_QUERY, 'Please provide Id.');
|
||||||
|
}
|
||||||
|
} catch (err) {
|
||||||
|
console.log('err in update template', err);
|
||||||
|
throw err;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
export default async function saveTemplate(request) {
|
||||||
|
const jwttoken = request.headers.jwttoken || '';
|
||||||
|
const template = {
|
||||||
|
Id: request.params?.templateId,
|
||||||
|
URL: request.params?.URL || '',
|
||||||
|
Name: request.params?.Name,
|
||||||
|
Note: request.params?.Note,
|
||||||
|
Description: request.params?.Description,
|
||||||
|
Placeholders: request.params?.Placeholders,
|
||||||
|
Signers: request.params?.Signers,
|
||||||
|
SendMail: request.params?.SendMail || false,
|
||||||
|
SendinOrder: request.params?.SendinOrder || true,
|
||||||
|
AutomaticReminders: request.params?.AutomaticReminders,
|
||||||
|
RemindOnceInEvery: parseInt(request.params.RemindOnceInEvery) || 15,
|
||||||
|
NextReminderDate: request.params?.NextReminderDate,
|
||||||
|
IsEnableOTP: request.params?.IsEnableOTP === true ? true : false,
|
||||||
|
IsTourEnabled: request.params?.IsTourEnabled === true ? true : false,
|
||||||
|
IsPublic: request.params?.IsPublic,
|
||||||
|
SignatureType: request.params?.SignatureType || [],
|
||||||
|
};
|
||||||
|
|
||||||
|
try {
|
||||||
|
if (request.user) {
|
||||||
|
return await updateTemplate(template);
|
||||||
|
} else if (jwttoken) {
|
||||||
|
const jwtDecode = parseJwt(jwttoken);
|
||||||
|
const userCls = new Parse.Query(Parse.User);
|
||||||
|
userCls.equalTo('email', jwtDecode?.user_email);
|
||||||
|
const userRes = await userCls.first({ useMasterKey: true });
|
||||||
|
const userId = userRes?.id;
|
||||||
|
const tokenQuery = new Parse.Query('appToken');
|
||||||
|
tokenQuery.equalTo('userId', {
|
||||||
|
__type: 'Pointer',
|
||||||
|
className: '_User',
|
||||||
|
objectId: userId,
|
||||||
|
});
|
||||||
|
const appRes = await tokenQuery.first({ useMasterKey: true });
|
||||||
|
const decoded = jwt.verify(jwttoken, appRes?.get('token'));
|
||||||
|
if (decoded?.user_email) {
|
||||||
|
return await updateTemplate(template, true);
|
||||||
|
} else {
|
||||||
|
throw new Parse.Error(Parse.Error.INVALID_SESSION_TOKEN, 'Invalid token');
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
throw new Parse.Error(Parse.Error.INVALID_SESSION_TOKEN, 'Invalid session token');
|
||||||
|
}
|
||||||
|
} catch (err) {
|
||||||
|
console.log('err in get signers', err);
|
||||||
|
throw err;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,180 @@
|
|||||||
|
import { parseJwt } from '../../Utils.js';
|
||||||
|
import jwt from 'jsonwebtoken';
|
||||||
|
|
||||||
|
export default async function savecontact(request) {
|
||||||
|
const name = request.params.name;
|
||||||
|
const phone = request.params.phone;
|
||||||
|
const email = request.params.email;
|
||||||
|
const tenantId = request.params.tenantId;
|
||||||
|
const jwttoken = request.headers.jwttoken;
|
||||||
|
|
||||||
|
if (request.user) {
|
||||||
|
const currentUser = request?.user;
|
||||||
|
const currentUserPtr = { __type: 'Pointer', className: '_User', objectId: currentUser?.id };
|
||||||
|
const query = new Parse.Query('contracts_Contactbook');
|
||||||
|
query.equalTo('CreatedBy', currentUserPtr);
|
||||||
|
query.notEqualTo('IsDeleted', true);
|
||||||
|
query.equalTo('Email', email);
|
||||||
|
const res = await query.first({ sessionToken: request.user.getSessionToken() });
|
||||||
|
if (!res) {
|
||||||
|
const contactQuery = new Parse.Object('contracts_Contactbook');
|
||||||
|
contactQuery.set('Name', name);
|
||||||
|
if (phone) {
|
||||||
|
contactQuery.set('Phone', phone);
|
||||||
|
}
|
||||||
|
contactQuery.set('Email', email);
|
||||||
|
contactQuery.set('UserRole', 'contracts_Guest');
|
||||||
|
contactQuery.set('IsDeleted', false);
|
||||||
|
if (tenantId) {
|
||||||
|
contactQuery.set('TenantId', {
|
||||||
|
__type: 'Pointer',
|
||||||
|
className: 'partners_Tenant',
|
||||||
|
objectId: tenantId,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
const _users = Parse.Object.extend('User');
|
||||||
|
const _user = new _users();
|
||||||
|
_user.set('name', name);
|
||||||
|
_user.set('username', email);
|
||||||
|
_user.set('email', email);
|
||||||
|
_user.set('password', email);
|
||||||
|
if (phone) {
|
||||||
|
_user.set('phone', phone);
|
||||||
|
}
|
||||||
|
|
||||||
|
const user = await _user.save();
|
||||||
|
if (user) {
|
||||||
|
contactQuery.set('CreatedBy', currentUserPtr);
|
||||||
|
contactQuery.set('UserId', user);
|
||||||
|
const acl = new Parse.ACL();
|
||||||
|
acl.setReadAccess(user.id, true);
|
||||||
|
acl.setWriteAccess(user.id, true);
|
||||||
|
acl.setReadAccess(currentUser.id, true);
|
||||||
|
acl.setWriteAccess(currentUser.id, true);
|
||||||
|
contactQuery.setACL(acl);
|
||||||
|
|
||||||
|
const res = await contactQuery.save();
|
||||||
|
const parseData = JSON.parse(JSON.stringify(res));
|
||||||
|
return parseData;
|
||||||
|
}
|
||||||
|
} catch (err) {
|
||||||
|
console.log('err ', err);
|
||||||
|
if (err.code === 202) {
|
||||||
|
const params = { email: email };
|
||||||
|
const userRes = await Parse.Cloud.run('getUserId', params);
|
||||||
|
contactQuery.set('CreatedBy', currentUserPtr);
|
||||||
|
contactQuery.set('UserId', {
|
||||||
|
__type: 'Pointer',
|
||||||
|
className: '_User',
|
||||||
|
objectId: userRes.id,
|
||||||
|
});
|
||||||
|
const acl = new Parse.ACL();
|
||||||
|
acl.setReadAccess(userRes.id, true);
|
||||||
|
acl.setWriteAccess(userRes.id, true);
|
||||||
|
acl.setReadAccess(currentUser.id, true);
|
||||||
|
acl.setWriteAccess(currentUser.id, true);
|
||||||
|
contactQuery.setACL(acl);
|
||||||
|
const res = await contactQuery.save();
|
||||||
|
const parseData = JSON.parse(JSON.stringify(res));
|
||||||
|
return parseData;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
throw new Parse.Error(Parse.Error.DUPLICATE_VALUE, 'Contact already exists.');
|
||||||
|
}
|
||||||
|
} else if (jwttoken) {
|
||||||
|
const jwtDecode = parseJwt(jwttoken);
|
||||||
|
const userCls = new Parse.Query(Parse.User);
|
||||||
|
userCls.equalTo('email', jwtDecode?.user_email);
|
||||||
|
const userRes = await userCls.first({ useMasterKey: true });
|
||||||
|
const userId = userRes?.id;
|
||||||
|
const tokenQuery = new Parse.Query('appToken');
|
||||||
|
tokenQuery.equalTo('userId', {
|
||||||
|
__type: 'Pointer',
|
||||||
|
className: '_User',
|
||||||
|
objectId: userId,
|
||||||
|
});
|
||||||
|
const appRes = await tokenQuery.first({ useMasterKey: true });
|
||||||
|
const decoded = jwt.verify(jwttoken, appRes?.get('token'));
|
||||||
|
const currentUser = userRes;
|
||||||
|
const currentUserPtr = { __type: 'Pointer', className: '_User', objectId: userId };
|
||||||
|
if (decoded?.user_email) {
|
||||||
|
const query = new Parse.Query('contracts_Contactbook');
|
||||||
|
query.equalTo('CreatedBy', currentUserPtr);
|
||||||
|
query.notEqualTo('IsDeleted', true);
|
||||||
|
query.equalTo('Email', email);
|
||||||
|
const res = await query.first({ useMasterKey: true });
|
||||||
|
if (!res) {
|
||||||
|
const contactQuery = new Parse.Object('contracts_Contactbook');
|
||||||
|
contactQuery.set('Name', name);
|
||||||
|
if (phone) {
|
||||||
|
contactQuery.set('Phone', phone);
|
||||||
|
}
|
||||||
|
contactQuery.set('Email', email);
|
||||||
|
contactQuery.set('UserRole', 'contracts_Guest');
|
||||||
|
contactQuery.set('IsDeleted', false);
|
||||||
|
if (tenantId) {
|
||||||
|
contactQuery.set('TenantId', {
|
||||||
|
__type: 'Pointer',
|
||||||
|
className: 'partners_Tenant',
|
||||||
|
objectId: tenantId,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
const _users = Parse.Object.extend('User');
|
||||||
|
const _user = new _users();
|
||||||
|
_user.set('name', name);
|
||||||
|
_user.set('username', email);
|
||||||
|
_user.set('email', email);
|
||||||
|
_user.set('password', email);
|
||||||
|
if (phone) {
|
||||||
|
_user.set('phone', phone);
|
||||||
|
}
|
||||||
|
|
||||||
|
const user = await _user.save();
|
||||||
|
if (user) {
|
||||||
|
contactQuery.set('CreatedBy', currentUserPtr);
|
||||||
|
contactQuery.set('UserId', user);
|
||||||
|
const acl = new Parse.ACL();
|
||||||
|
acl.setReadAccess(user.id, true);
|
||||||
|
acl.setWriteAccess(user.id, true);
|
||||||
|
acl.setReadAccess(currentUser.id, true);
|
||||||
|
acl.setWriteAccess(currentUser.id, true);
|
||||||
|
contactQuery.setACL(acl);
|
||||||
|
|
||||||
|
const res = await contactQuery.save();
|
||||||
|
const parseData = JSON.parse(JSON.stringify(res));
|
||||||
|
return parseData;
|
||||||
|
}
|
||||||
|
} catch (err) {
|
||||||
|
console.log('err ', err);
|
||||||
|
if (err.code === 202) {
|
||||||
|
const params = { email: email };
|
||||||
|
const userRes = await Parse.Cloud.run('getUserId', params);
|
||||||
|
contactQuery.set('CreatedBy', currentUserPtr);
|
||||||
|
contactQuery.set('UserId', {
|
||||||
|
__type: 'Pointer',
|
||||||
|
className: '_User',
|
||||||
|
objectId: userRes.id,
|
||||||
|
});
|
||||||
|
const acl = new Parse.ACL();
|
||||||
|
acl.setReadAccess(userRes.id, true);
|
||||||
|
acl.setWriteAccess(userRes.id, true);
|
||||||
|
acl.setReadAccess(currentUser.id, true);
|
||||||
|
acl.setWriteAccess(currentUser.id, true);
|
||||||
|
contactQuery.setACL(acl);
|
||||||
|
const res = await contactQuery.save();
|
||||||
|
const parseData = JSON.parse(JSON.stringify(res));
|
||||||
|
return parseData;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
throw new Parse.Error(Parse.Error.DUPLICATE_VALUE, 'Contact already exists.');
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
throw new Parse.Error(Parse.Error.INVALID_SESSION_TOKEN, 'Invalid token.');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -18,7 +18,7 @@ async function sendMailProvider(req, plan, monthchange) {
|
|||||||
port: process.env.SMTP_PORT || 465,
|
port: process.env.SMTP_PORT || 465,
|
||||||
secure: smtpsecure,
|
secure: smtpsecure,
|
||||||
auth: {
|
auth: {
|
||||||
user: process.env.SMTP_USER_EMAIL,
|
user: process.env.SMTP_USERNAME ? process.env.SMTP_USERNAME : process.env.SMTP_USER_EMAIL,
|
||||||
pass: process.env.SMTP_PASS,
|
pass: process.env.SMTP_PASS,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
@@ -65,7 +65,7 @@ async function sendMailProvider(req, plan, monthchange) {
|
|||||||
const pdfName = req.params.pdfName && `${req.params.pdfName}.pdf`;
|
const pdfName = req.params.pdfName && `${req.params.pdfName}.pdf`;
|
||||||
const file = {
|
const file = {
|
||||||
filename: pdfName || 'exported.pdf',
|
filename: pdfName || 'exported.pdf',
|
||||||
content: smtpenable ? PdfBuffer : undefined, //fs.readFileSync('./exports/exported_file_1223.pdf'),
|
content: smtpenable ? PdfBuffer : undefined,
|
||||||
data: smtpenable ? undefined : PdfBuffer,
|
data: smtpenable ? undefined : PdfBuffer,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,73 @@
|
|||||||
|
import { parseJwt } from '../../Utils.js';
|
||||||
|
import jwt from 'jsonwebtoken';
|
||||||
|
|
||||||
|
async function updateTemplate(template, isJwt = false) {
|
||||||
|
try {
|
||||||
|
if (template?.Id) {
|
||||||
|
const updateTemplate = new Parse.Object('contracts_Template');
|
||||||
|
updateTemplate.id = template.Id;
|
||||||
|
|
||||||
|
const isPublic = template?.IsPublic !== undefined ? template?.IsPublic : false;
|
||||||
|
if (template?.IsPublic !== undefined) {
|
||||||
|
updateTemplate.set('IsPublic', isPublic);
|
||||||
|
updateTemplate.set('PublicRole', template.PublicRole);
|
||||||
|
}
|
||||||
|
|
||||||
|
let updateTemplateRes;
|
||||||
|
if (isJwt) {
|
||||||
|
updateTemplateRes = await updateTemplate.save(null, { useMasterKey: true });
|
||||||
|
} else {
|
||||||
|
updateTemplateRes = await updateTemplate.save();
|
||||||
|
}
|
||||||
|
return updateTemplateRes;
|
||||||
|
} else {
|
||||||
|
throw new Parse.Error(Parse.Error.INVALID_QUERY, 'Please provide Id.');
|
||||||
|
}
|
||||||
|
} catch (err) {
|
||||||
|
console.log('err in update template', err);
|
||||||
|
throw err;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
export default async function updateToPublicTemplate(request) {
|
||||||
|
const jwttoken = request.headers.jwttoken || '';
|
||||||
|
const Role = request.params.Role;
|
||||||
|
if (!Role) {
|
||||||
|
throw new Parse.Error(Parse.Error.INVALID_QUERY, 'Please provide public role.');
|
||||||
|
}
|
||||||
|
const PublicRole = [Role];
|
||||||
|
const template = {
|
||||||
|
Id: request.params.templateId,
|
||||||
|
IsPublic: request.params?.IsPublic,
|
||||||
|
PublicRole: PublicRole,
|
||||||
|
};
|
||||||
|
|
||||||
|
try {
|
||||||
|
if (request.user) {
|
||||||
|
return await updateTemplate(template);
|
||||||
|
} else if (jwttoken) {
|
||||||
|
const jwtDecode = parseJwt(jwttoken);
|
||||||
|
const userCls = new Parse.Query(Parse.User);
|
||||||
|
userCls.equalTo('email', jwtDecode?.user_email);
|
||||||
|
const userRes = await userCls.first({ useMasterKey: true });
|
||||||
|
const userId = userRes?.id;
|
||||||
|
const tokenQuery = new Parse.Query('appToken');
|
||||||
|
tokenQuery.equalTo('userId', {
|
||||||
|
__type: 'Pointer',
|
||||||
|
className: '_User',
|
||||||
|
objectId: userId,
|
||||||
|
});
|
||||||
|
const appRes = await tokenQuery.first({ useMasterKey: true });
|
||||||
|
const decoded = jwt.verify(jwttoken, appRes?.get('token'));
|
||||||
|
if (decoded?.user_email) {
|
||||||
|
return await updateTemplate(template, true);
|
||||||
|
} else {
|
||||||
|
throw new Parse.Error(Parse.Error.INVALID_SESSION_TOKEN, 'Invalid token');
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
throw new Parse.Error(Parse.Error.INVALID_SESSION_TOKEN, 'Invalid session token');
|
||||||
|
}
|
||||||
|
} catch (err) {
|
||||||
|
console.log('err in get signers', err);
|
||||||
|
throw err;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,58 @@
|
|||||||
|
import { parseJwt } from '../../Utils.js';
|
||||||
|
import jwt from 'jsonwebtoken';
|
||||||
|
|
||||||
|
export default async function updateTourStatus(request) {
|
||||||
|
const tourstatus = request.params.TourStatus;
|
||||||
|
const extUserId = request.params.ExtUserId;
|
||||||
|
const jwttoken = request?.headers?.jwttoken || '';
|
||||||
|
if (request.user) {
|
||||||
|
try {
|
||||||
|
const updateUser = new Parse.Object('contracts_Users');
|
||||||
|
updateUser.id = extUserId;
|
||||||
|
updateUser.set('TourStatus', tourstatus);
|
||||||
|
const res = await updateUser.save();
|
||||||
|
return res;
|
||||||
|
} catch (err) {
|
||||||
|
console.log('Err ', err);
|
||||||
|
const code = err?.code || 400;
|
||||||
|
const msg = err?.message || 'Something went wrong.';
|
||||||
|
throw new Parse.Error(code, msg);
|
||||||
|
}
|
||||||
|
} else if (jwttoken) {
|
||||||
|
const jwtDecode = parseJwt(jwttoken);
|
||||||
|
if (jwtDecode?.user_email) {
|
||||||
|
const userCls = new Parse.Query(Parse.User);
|
||||||
|
userCls.equalTo('email', jwtDecode?.user_email);
|
||||||
|
const userRes = await userCls.first({ useMasterKey: true });
|
||||||
|
const userId = userRes?.id;
|
||||||
|
const tokenQuery = new Parse.Query('appToken');
|
||||||
|
tokenQuery.equalTo('userId', {
|
||||||
|
__type: 'Pointer',
|
||||||
|
className: '_User',
|
||||||
|
objectId: userId,
|
||||||
|
});
|
||||||
|
const appRes = await tokenQuery.first({ useMasterKey: true });
|
||||||
|
const decoded = jwt.verify(jwttoken, appRes?.get('token'));
|
||||||
|
if (decoded?.user_email) {
|
||||||
|
try {
|
||||||
|
const updateUser = new Parse.Object('contracts_Users');
|
||||||
|
updateUser.id = extUserId;
|
||||||
|
updateUser.set('TourStatus', tourstatus);
|
||||||
|
const res = await updateUser.save(null, { useMasterKey: true });
|
||||||
|
return res;
|
||||||
|
} catch (err) {
|
||||||
|
console.log('Err ', err);
|
||||||
|
const code = err?.code || 400;
|
||||||
|
const msg = err?.message || 'Something went wrong.';
|
||||||
|
throw new Parse.Error(code, msg);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
return { status: 'error', result: 'Invalid token!' };
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
return { status: 'error', result: 'Invalid token!' };
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
throw new Parse.Error(Parse.Error.INVALID_SESSION_TOKEN, 'User is not authenticated.');
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,52 @@
|
|||||||
|
export default async function updateSignatureType(request) {
|
||||||
|
if (!request?.user) {
|
||||||
|
throw new Parse.Error(Parse.Error.INVALID_SESSION_TOKEN, 'User is not authenticated.');
|
||||||
|
}
|
||||||
|
const SignatureType = request.params.SignatureType || [];
|
||||||
|
if (SignatureType.length > 0) {
|
||||||
|
const enabledSignTypes = SignatureType?.filter(x => x.enabled);
|
||||||
|
const isDefaultSignTypeOnly =
|
||||||
|
enabledSignTypes?.length === 1 && enabledSignTypes[0]?.name === 'default';
|
||||||
|
|
||||||
|
if (enabledSignTypes.length === 0) {
|
||||||
|
throw new Parse.Error(
|
||||||
|
Parse.Error.INVALID_QUERY,
|
||||||
|
'At least one signature type should be enabled.'
|
||||||
|
);
|
||||||
|
} else if (isDefaultSignTypeOnly) {
|
||||||
|
throw new Parse.Error(
|
||||||
|
Parse.Error.INVALID_QUERY,
|
||||||
|
'At least one signature type other than the default should be enabled.'
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
try {
|
||||||
|
const orgQuery = new Parse.Query('contracts_Users');
|
||||||
|
orgQuery.equalTo('UserId', {
|
||||||
|
__type: 'Pointer',
|
||||||
|
className: '_User',
|
||||||
|
objectId: request.user.id,
|
||||||
|
});
|
||||||
|
const resUser = await orgQuery.first({ useMasterKey: true });
|
||||||
|
if (resUser) {
|
||||||
|
const newOrg = new Parse.Object('contracts_Users');
|
||||||
|
newOrg.id = resUser.id;
|
||||||
|
newOrg.set('SignatureType', SignatureType);
|
||||||
|
const updateUserRes = await newOrg.save(null, { useMasterKey: true });
|
||||||
|
if (updateUserRes) {
|
||||||
|
const _updateUserRes = JSON.parse(JSON.stringify(updateUserRes));
|
||||||
|
return _updateUserRes;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
throw new Parse.Error(Parse.Error.OPERATION_FORBIDDEN, 'Premission denied.');
|
||||||
|
}
|
||||||
|
} catch (err) {
|
||||||
|
console.log('err in addorganization', err);
|
||||||
|
const code = err?.code || 400;
|
||||||
|
const msg = err?.message || 'Something went wrong.';
|
||||||
|
throw new Parse.Error(code, msg);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
throw new Parse.Error(Parse.Error.INVALID_QUERY, 'Please provide signature types.');
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,43 @@
|
|||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param {Parse} Parse
|
||||||
|
*/
|
||||||
|
exports.up = async Parse => {
|
||||||
|
const docSchema = new Parse.Schema('contracts_Document');
|
||||||
|
docSchema.addArray('SignatureType');
|
||||||
|
await docSchema.update();
|
||||||
|
|
||||||
|
const templateSchema = new Parse.Schema('contracts_Template');
|
||||||
|
templateSchema.addArray('SignatureType');
|
||||||
|
await templateSchema.update();
|
||||||
|
|
||||||
|
const extUserSchema = new Parse.Schema('contracts_Users');
|
||||||
|
extUserSchema.addArray('SignatureType');
|
||||||
|
await extUserSchema.update();
|
||||||
|
|
||||||
|
const tenantSchema = new Parse.Schema('partners_Tenant');
|
||||||
|
tenantSchema.addArray('SignatureType');
|
||||||
|
return tenantSchema.update();
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param {Parse} Parse
|
||||||
|
*/
|
||||||
|
exports.down = async Parse => {
|
||||||
|
const docSchema = new Parse.Schema('contracts_Document');
|
||||||
|
docSchema.deleteField('SignatureType');
|
||||||
|
await docSchema.update();
|
||||||
|
|
||||||
|
const templateSchema = new Parse.Schema('contracts_Template');
|
||||||
|
docSchema.deleteField('SignatureType');
|
||||||
|
await templateSchema.update();
|
||||||
|
|
||||||
|
const extUserSchema = new Parse.Schema('contracts_Users');
|
||||||
|
docSchema.deleteField('SignatureType');
|
||||||
|
await extUserSchema.update();
|
||||||
|
|
||||||
|
const tenantSchema = new Parse.Schema('partners_Tenant');
|
||||||
|
docSchema.deleteField('SignatureType');
|
||||||
|
return tenantSchema.update();
|
||||||
|
};
|
||||||
@@ -62,7 +62,7 @@ if (smtpenable) {
|
|||||||
port: process.env.SMTP_PORT || 465,
|
port: process.env.SMTP_PORT || 465,
|
||||||
secure: smtpsecure,
|
secure: smtpsecure,
|
||||||
auth: {
|
auth: {
|
||||||
user: process.env.SMTP_USER_EMAIL,
|
user: process.env.SMTP_USERNAME ? process.env.SMTP_USERNAME : process.env.SMTP_USER_EMAIL,
|
||||||
pass: process.env.SMTP_PASS,
|
pass: process.env.SMTP_PASS,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|||||||
Generated
+724
-539
File diff suppressed because it is too large
Load Diff
@@ -18,10 +18,10 @@
|
|||||||
"watch": "nodemon index.js"
|
"watch": "nodemon index.js"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@aws-sdk/client-s3": "^3.665.0",
|
"@aws-sdk/client-s3": "^3.685.0",
|
||||||
"@aws-sdk/s3-request-presigner": "^3.665.0",
|
"@aws-sdk/s3-request-presigner": "^3.688.0",
|
||||||
"@parse/fs-files-adapter": "^3.0.0",
|
"@parse/fs-files-adapter": "^3.0.0",
|
||||||
"@parse/s3-files-adapter": "^2.2.0",
|
"@parse/s3-files-adapter": "^3.0.0",
|
||||||
"@pdf-lib/fontkit": "^1.1.1",
|
"@pdf-lib/fontkit": "^1.1.1",
|
||||||
"@signpdf/placeholder-pdf-lib": "^3.2.4",
|
"@signpdf/placeholder-pdf-lib": "^3.2.4",
|
||||||
"@signpdf/signer-p12": "^3.2.4",
|
"@signpdf/signer-p12": "^3.2.4",
|
||||||
@@ -30,30 +30,30 @@
|
|||||||
"axios": "^1.7.7",
|
"axios": "^1.7.7",
|
||||||
"cors": "^2.8.5",
|
"cors": "^2.8.5",
|
||||||
"dotenv": "^16.4.5",
|
"dotenv": "^16.4.5",
|
||||||
"express": "^4.21.0",
|
"express": "^4.21.1",
|
||||||
"form-data": "^4.0.0",
|
"form-data": "^4.0.1",
|
||||||
"generate-api-key": "^1.0.2",
|
"generate-api-key": "^1.0.2",
|
||||||
"googleapis": "^144.0.0",
|
"googleapis": "^144.0.0",
|
||||||
"mailgun.js": "^10.2.3",
|
"mailgun.js": "^10.2.3",
|
||||||
"mongoose": "^8.7.0",
|
"mongoose": "^8.8.0",
|
||||||
"multer": "^1.4.5-lts.1",
|
"multer": "^1.4.5-lts.1",
|
||||||
"multer-s3": "^3.0.1",
|
"multer-s3": "^3.0.1",
|
||||||
"node-forge": "^1.3.1",
|
"node-forge": "^1.3.1",
|
||||||
"nodemailer": "^6.9.15",
|
"nodemailer": "^6.9.16",
|
||||||
"parse": "^5.3.0",
|
"parse": "^5.3.0",
|
||||||
"parse-dbtool": "^1.2.0",
|
"parse-dbtool": "^1.2.0",
|
||||||
"parse-server": "^7.3.0",
|
"parse-server": "^7.3.0",
|
||||||
"parse-server-api-mail-adapter": "^4.0.0",
|
"parse-server-api-mail-adapter": "^4.1.0",
|
||||||
"pdf-lib": "^1.17.1",
|
"pdf-lib": "^1.17.1",
|
||||||
"posthog-node": "^4.2.0",
|
"posthog-node": "^4.2.1",
|
||||||
"ws": "^8.18.0"
|
"ws": "^8.18.0"
|
||||||
},
|
},
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@babel/eslint-parser": "^7.25.7",
|
"@babel/eslint-parser": "^7.25.9",
|
||||||
"eslint": "^9.12.0",
|
"eslint": "^9.14.0",
|
||||||
"jasmine": "^5.3.1",
|
"jasmine": "^5.4.0",
|
||||||
"mongodb-runner": "^5.7.0",
|
"mongodb-runner": "^5.7.1",
|
||||||
"nodemon": "^3.1.7",
|
"nodemon": "^3.1.7",
|
||||||
"nyc": "^17.1.0",
|
"nyc": "^17.1.0",
|
||||||
"prettier": "^3.3.3"
|
"prettier": "^3.3.3"
|
||||||
|
|||||||
Reference in New Issue
Block a user