change title of request signtuares form, change response of document and template response, change subject of mail

This commit is contained in:
prafull-opensignlabs
2024-02-16 16:27:20 +05:30
parent 97983c423f
commit edda20940b
12 changed files with 147 additions and 60 deletions
+2 -2
View File
@@ -8,9 +8,9 @@ export const formJson = {
Cls: documentCls
},
//json form for request signature
//json form for request signatures
"8mZzFxbG1z": {
title: "Request Signature",
title: "Request Signatures",
msgVar: "Document",
redirectRoute: "placeHolderSign",
Cls: documentCls,
+2 -2
View File
@@ -157,7 +157,7 @@ const Forms = (props) => {
object.set("Name", formData?.Name);
object.set("Description", formData?.Description);
object.set("Note", formData?.Note);
if (props.title === "Request Signature") {
if (props.title === "Request Signatures") {
object.set(
"TimeToCompleteDays",
parseInt(formData?.TimeToCompleteDays)
@@ -352,7 +352,7 @@ const Forms = (props) => {
</div>
<SelectFolder onSuccess={handleFolder} folderCls={props.Cls} />
{props.title === "Request Signature" && (
{props.title === "Request Signatures" && (
<div className="text-xs mt-2">
<label className="block">
Time To Complete (Days)
@@ -9,7 +9,7 @@ import getDocument from './routes/getDocument.js';
import getContact from './routes/getContact.js';
import deleteContact from './routes/deleteContact.js';
import getContactList from './routes/getContactList.js';
import createDocument from './routes/createDocument.js';
import draftDocument from './routes/draftDocument.js';
import createTemplate from './routes/createTemplate.js';
import getTemplate from './routes/getTemplate.js';
import deletedTemplate from './routes/deleteTemplate.js';
@@ -56,7 +56,7 @@ app.post('/createdocumentwithbinary', upload.array('file', 1), createDocumentwit
app.post('/createdocument', createDocumentwithCoordinate);
// create Document with base64 without placeholder
app.post('/draftdocument', createDocument);
app.post('/draftdocument', draftDocument);
// create Document with templateId
app.post('/createdocument/:template_id', createDocumentWithTemplate);
@@ -201,10 +201,12 @@ export default async function createDocumentWithTemplate(request, response) {
if (send_email === false) {
console.log("don't send mail");
} else {
for (let i = 0; i < contact.length; i++) {
if (sendInOrder) {
contact.splice(1);
}
let contactMail = contact;
if (sendInOrder) {
contactMail = contact.slice();
contactMail.splice(1);
}
for (let i = 0; i < contactMail.length; i++) {
try {
const imgPng = 'https://qikinnovation.ams3.digitaloceanspaces.com/logo.png';
let url = `${process.env.SERVER_URL}/functions/sendmailv3/`;
@@ -214,10 +216,10 @@ export default async function createDocumentWithTemplate(request, response) {
'X-Parse-Master-Key': process.env.MASTER_KEY,
};
const objectId = contact[i].contactPtr.objectId;
const objectId = contactMail[i].contactPtr.objectId;
const hostUrl = baseUrl.origin + '/loadmf/signmicroapp';
let signPdf = `${hostUrl}/login/${res.id}/${contact[i].email}/${objectId}/${serverParams}`;
let signPdf = `${hostUrl}/login/${res.id}/${contactMail[i].email}/${objectId}/${serverParams}`;
const openSignUrl = 'https://www.opensignlabs.com/contact-us';
const orgName = template.ExtUserPtr.Company ? template.ExtUserPtr.Company : '';
const themeBGcolor = '#47a3ad';
@@ -250,9 +252,9 @@ export default async function createDocumentWithTemplate(request, response) {
sender_name: template.ExtUserPtr.Name,
sender_mail: template.ExtUserPtr.Email,
sender_phone: template.ExtUserPtr.Phone,
receiver_name: contact[i].name,
receiver_email: contact[i].email,
receiver_phone: contact[i].phone,
receiver_name: contactMail[i].name,
receiver_email: contactMail[i].email,
receiver_phone: contactMail[i].phone,
expiry_date: localExpireDate,
company_name: orgName,
signing_url: signPdf,
@@ -278,7 +280,7 @@ export default async function createDocumentWithTemplate(request, response) {
const subject = replaceVar.subject;
const html = replaceVar.body;
let params = {
recipient: contact[i].email,
recipient: contactMail[i].email,
subject: subject,
from: sender,
html: html,
@@ -252,10 +252,12 @@ export default async function createDocumentwithCoordinate(request, response) {
if (send_email === false) {
console.log("don't send mail");
} else {
let contactMail = contact;
if (sendInOrder) {
contact.splice(1);
contactMail = contact.slice();
contactMail.splice(1);
}
for (let i = 0; i < contact.length; i++) {
for (let i = 0; i < contactMail.length; i++) {
try {
const imgPng = 'https://qikinnovation.ams3.digitaloceanspaces.com/logo.png';
let url = `${process.env.SERVER_URL}/functions/sendmailv3/`;
@@ -265,10 +267,10 @@ export default async function createDocumentwithCoordinate(request, response) {
'X-Parse-Master-Key': process.env.MASTER_KEY,
};
const objectId = contact[i].contactPtr.objectId;
const objectId = contactMail[i].contactPtr.objectId;
const hostUrl = baseUrl.origin + '/loadmf/signmicroapp';
let signPdf = `${hostUrl}/login/${res.id}/${contact[i].email}/${objectId}/${serverParams}`;
let signPdf = `${hostUrl}/login/${res.id}/${contactMail[i].email}/${objectId}/${serverParams}`;
const openSignUrl = 'https://www.opensignlabs.com/contact-us';
const orgName = parseExtUser.Company ? parseExtUser.Company : '';
const themeBGcolor = '#47a3ad';
@@ -300,9 +302,9 @@ export default async function createDocumentwithCoordinate(request, response) {
sender_name: parseExtUser.Name,
sender_mail: parseExtUser.Email,
sender_phone: parseExtUser.Phone,
receiver_name: contact[i].name,
receiver_email: contact[i].email,
receiver_phone: contact[i].phone,
receiver_name: contactMail[i].name,
receiver_email: contactMail[i].email,
receiver_phone: contactMail[i].phone,
expiry_date: localExpireDate,
company_name: orgName,
signing_url: signPdf,
@@ -328,7 +330,7 @@ export default async function createDocumentwithCoordinate(request, response) {
const html = replaceVar.body;
let params = {
recipient: contact[i].email,
recipient: contactMail[i].email,
subject: subject,
from: sender,
html: html,
@@ -123,7 +123,7 @@ export default async function createTemplate(request, response) {
}
return response.json({
objectId: res.id,
url: baseUrl.p + '/load/signmicroapp/template/' + res.id,
url: baseUrl.origin + '/load/signmicroapp/template/' + res.id,
});
} else {
return response.status(405).json({ error: 'Invalid API Token!' });
@@ -2,7 +2,7 @@ import axios from 'axios';
import { customAPIurl } from '../../../../Utils.js';
// const randomId = () => Math.floor(1000 + Math.random() * 9000);
export default async function createDocument(request, response) {
export default async function draftDocument(request, response) {
const name = request.body.title;
const note = request.body.note;
const description = request.body.description;
@@ -23,6 +23,7 @@ export default async function getDocument(request, response) {
Document.include('Signers');
Document.include('Folder');
Document.include('ExtUserPtr');
Document.include('Placeholders.signerPtr');
const res = await Document.first({ useMasterKey: true });
if (res) {
const document = JSON.parse(JSON.stringify(res));
@@ -41,8 +42,25 @@ export default async function getDocument(request, response) {
file: document?.SignedUrl || document.URL,
owner: document?.ExtUserPtr?.Name,
signers:
document?.Placeholders?.map(y => ({
role: y.Role,
name: y?.signerPtr?.Name || '',
email: y?.signerPtr?.Email || '',
phone: y?.signerPtr?.Phone || '',
widgets: y.placeHolder?.flatMap(x =>
x?.pos.map(w => ({
type: w?.type ? w.type : w.isStamp ? 'stamp' : 'signature',
x: w.xPosition,
y: w.yPosition,
w: w?.Width || 150,
h: w?.Height || 60,
page: x?.pageNumber,
}))
),
})) ||
document?.Signers?.map(y => ({ name: y?.Name, email: y?.Email, phone: y?.Phone })) ||
[],
sendInOrder: document?.SendinOrder || false,
createdAt: document.createdAt,
updatedAt: document.updatedAt,
});
@@ -61,38 +61,70 @@ export default async function getDocumentList(request, response) {
'X-Parse-Application-Id': appId,
'X-Parse-Master-Key': process.env.MASTER_KEY,
};
const url = `${serverUrl}/classes/${clsName}?where=${strParams}&keys=${strKeys}&order=${orderBy}&skip=${skip}&limit=${limit}&include=AuditTrail.UserPtr`;
const res = await axios.get(url, { headers: headers });
if (res.data && res.data.results.length > 0) {
const url = `${serverUrl}/classes/${clsName}?where=${strParams}&keys=${strKeys},Placeholders&order=${orderBy}&skip=${skip}&limit=${limit}&include=AuditTrail.UserPtr,Placeholders.signerPtr`;
try {
const res = await axios.get(url, { headers: headers });
if (res.data && res.data.results.length > 0) {
if (request.posthog) {
request.posthog?.capture({
distinctId: parseUser.userId.email,
event: 'api_get_document_list_by_status',
properties: { response_code: 200, doc_type: docType },
});
}
const updateRes = res.data.results.map(x => ({
objectId: x.objectId,
title: x.Name,
note: x.Note || '',
folder: { objectId: x?.Folder?.objectId, name: x?.Folder?.Name } || '',
file: x?.SignedUrl || x.URL,
owner: x?.ExtUserPtr?.Name,
signers:
x?.Placeholders?.map(y => ({
role: y.Role,
name: y?.signerPtr?.Name || '',
email: y?.signerPtr?.Email || '',
phone: y?.signerPtr?.Phone || '',
widgets: y.placeHolder?.flatMap(x =>
x?.pos.map(w => ({
type: w?.type ? w.type : w.isStamp ? 'stamp' : 'signature',
x: w.xPosition,
y: w.yPosition,
w: w?.Width || 150,
h: w?.Height || 60,
page: x?.pageNumber,
}))
),
})) ||
x?.Signers?.map(y => ({ name: y?.Name, email: y?.Email, phone: y?.Phone })) ||
[],
sendInOrder: x?.SendinOrder || false,
createdAt: x.createdAt,
updatedAt: x.updatedAt,
}));
return response.json({ result: updateRes });
} else {
return response.json({ result: [] });
}
} catch (err) {
console.log('err in getdocument list', err);
if (request.posthog) {
request.posthog?.capture({
distinctId: parseUser.userId.email,
event: 'api_get_document_list_by_status',
properties: { response_code: 200 },
properties: { response_code: 400, doc_type: docType },
});
}
const updateRes = res.data.results.map(x => ({
objectId: x.objectId,
title: x.Name,
note: x.Note || '',
folder: { objectId: x?.Folder?.objectId, name: x?.Folder?.Name } || '',
file: x?.SignedUrl || x.URL,
owner: x?.ExtUserPtr?.Name,
signers:
x?.Signers?.map(y => ({ name: y?.Name, email: y?.Email, phone: y?.Phone })) || [],
createdAt: x.createdAt,
updatedAt: x.updatedAt,
}));
return response.json({ result: updateRes });
} else {
return response.json({ result: [] });
return response
.status(400)
.json({ error: 'Something went wrong, please try again later!' });
}
} else {
if (request.posthog) {
request.posthog?.capture({
distinctId: parseUser.userId.email,
event: 'api_get_document_list_by_status',
properties: { response_code: 404 },
properties: { response_code: 404, doc_type: docType },
});
}
return response.status(404).json({ error: 'Report not available!' });
@@ -24,6 +24,7 @@ export default async function getTemplate(request, response) {
Template.include('Signers');
Template.include('Folder');
Template.include('ExtUserPtr');
Template.include('Placeholders.signerPtr');
const res = await Template.first({ useMasterKey: true });
if (res) {
const template = JSON.parse(JSON.stringify(res));
@@ -43,8 +44,23 @@ export default async function getTemplate(request, response) {
file: template?.SignedUrl || template?.URL,
owner: template?.ExtUserPtr?.Name,
signers:
template?.Signers?.map(y => ({ name: y?.Name, email: y?.Email, phone: y?.Phone })) ||
[],
template?.Placeholders?.map(y => ({
role: y.Role,
name: y?.signerPtr?.Name || '',
email: y?.signerPtr?.Email || '',
phone: y?.signerPtr?.Phone || '',
widgets: y.placeHolder?.flatMap(x =>
x?.pos.map(w => ({
type: w?.type ? w.type : w.isStamp ? 'stamp' : 'signature',
x: w.xPosition,
y: w.yPosition,
w: w?.Width || 150,
h: w?.Height || 60,
page: x?.pageNumber,
}))
),
})) || [],
sendInOrder: template?.SendinOrder || false,
createdAt: template.createdAt,
updatedAt: template.updatedAt,
});
@@ -42,6 +42,7 @@ export default async function getTemplatetList(request, response) {
'Signers.Name',
'Signers.Email',
'Signers.Phone',
'Placeholders',
];
const orderBy = '-updatedAt';
const strParams = JSON.stringify(params);
@@ -51,7 +52,7 @@ export default async function getTemplatetList(request, response) {
'X-Parse-Application-Id': appId,
'X-Parse-Master-Key': process.env.MASTER_KEY,
};
const url = `${serverUrl}/classes/${clsName}?where=${strParams}&keys=${strKeys}&order=${orderBy}&skip=${skip}&limit=${limit}&include=AuditTrail.UserPtr`;
const url = `${serverUrl}/classes/${clsName}?where=${strParams}&keys=${strKeys}&order=${orderBy}&skip=${skip}&limit=${limit}&include=AuditTrail.UserPtr,Placeholders.signerPtr`;
const res = await axios.get(url, { headers: headers });
if (res.data && res.data.results.length > 0) {
if (request.posthog) {
@@ -61,17 +62,33 @@ export default async function getTemplatetList(request, response) {
properties: { response_code: 200 },
});
}
const updateRes = res.data.results.map(x => ({
objectId: x.objectId,
title: x.Name,
note: x.Note || '',
folder: { objectId: x?.Folder?.objectId, name: x?.Folder?.Name } || '',
file: x?.SignedUrl || x.URL,
owner: x?.ExtUserPtr?.Name,
const updateRes = res.data.results.map(template => ({
objectId: template.objectId,
title: template.Name,
note: template.Note || '',
folder: { objectId: template?.Folder?.objectId, name: template?.Folder?.Name } || '',
file: template?.SignedUrl || template.URL,
owner: template?.ExtUserPtr?.Name,
signers:
x?.Signers?.map(y => ({ name: y?.Name, email: y?.Email, phone: y?.Phone })) || [],
createdAt: x.createdAt,
updatedAt: x.updatedAt,
template?.Placeholders?.map(y => ({
role: y.Role,
name: y?.signerPtr?.Name || '',
email: y?.signerPtr?.Email || '',
phone: y?.signerPtr?.Phone || '',
widgets: y.placeHolder?.flatMap(x =>
x?.pos.map(w => ({
type: w?.type ? w.type : w.isStamp ? 'stamp' : 'signature',
x: w.xPosition,
y: w.yPosition,
w: w?.Width || 150,
h: w?.Height || 60,
page: x?.pageNumber,
}))
),
})) || [],
sendInOrder: template?.SendinOrder || false,
createdAt: template.createdAt,
updatedAt: template.updatedAt,
}));
return response.json({ result: updateRes });
@@ -1 +1 @@
Email Address Verification
OpenSign™ Email Address Verification