diff --git a/apps/OpenSign/.gitignore b/apps/OpenSign/.gitignore index cc964cb27..b96e769c8 100644 --- a/apps/OpenSign/.gitignore +++ b/apps/OpenSign/.gitignore @@ -10,6 +10,7 @@ # production /build +/mfbuild # misc .env diff --git a/apps/OpenSign/src/components/LoginFacebook.js b/apps/OpenSign/src/components/LoginFacebook.js index 442fcb3e7..1aeef2c73 100644 --- a/apps/OpenSign/src/components/LoginFacebook.js +++ b/apps/OpenSign/src/components/LoginFacebook.js @@ -209,6 +209,13 @@ const LoginFacebook = ({ />
+ -
diff --git a/apps/OpenSign/src/components/LoginGoogle.js b/apps/OpenSign/src/components/LoginGoogle.js index 7e00b8e8c..1038b21bb 100644 --- a/apps/OpenSign/src/components/LoginGoogle.js +++ b/apps/OpenSign/src/components/LoginGoogle.js @@ -263,17 +263,17 @@ const GoogleSignInBtn = ({
setUserDetails({ @@ -285,6 +285,13 @@ const GoogleSignInBtn = ({ />
+ -
diff --git a/apps/OpenSign/src/json/plansArr.json b/apps/OpenSign/src/json/plansArr.json index 57439a344..ed75ffcb9 100644 --- a/apps/OpenSign/src/json/plansArr.json +++ b/apps/OpenSign/src/json/plansArr.json @@ -26,7 +26,7 @@ "planName": "THANKS PLAN", "currency": "$", "price": "29.99", - "subtitle": "Use code 'FREEBETA' to get this for free(First 100 users)", + "subtitle": "Use code 'FREEBETA' to get this for free(First 1000 users)", "btnText": "Subscribe", "url": "https://subscriptions.zoho.in/subscribe/ef798486e6a0a11ea65f2bae8f2af901dbadf3175d495584fd25b9af5d2f2b9e/thanks", "benefits": [ diff --git a/apps/OpenSign/src/routes/Pgsignup.js b/apps/OpenSign/src/routes/Pgsignup.js index 75a34c253..79f033a6c 100644 --- a/apps/OpenSign/src/routes/Pgsignup.js +++ b/apps/OpenSign/src/routes/Pgsignup.js @@ -151,6 +151,7 @@ const PgSignUp = (props) => { if (res) { const params = { userDetails: { + jobTitle: zohoRes.data.result.jobTitle, company: zohoRes.data.result.company, name: zohoRes.data.result.name, email: zohoRes.data.result.email, @@ -438,10 +439,10 @@ const PgSignUp = (props) => { ) : (
-

Choose Password

+

Choose Password


{ /> { @@ -28,7 +28,12 @@ const PlanSubscriptions = () => { : ""; const phone = userDetails && userDetails.phone ? "&mobile=" + userDetails.phone : ""; - const details = "?shipping_country_code=US&" + name + email + company + phone; + const details = + "?shipping_country_code=US&billing_country_code=US&billing_state_code=CA&" + + name + + email + + company + + phone; useEffect(() => { if (localStorage.getItem("accesstoken")) { setIsLoader(false); @@ -41,7 +46,7 @@ const PlanSubscriptions = () => { return ( <> - + <Title title={"Subscriptions"} /> {isLoader ? ( <div style={{ @@ -131,15 +136,13 @@ const PlanSubscriptions = () => { <p>{item.subtitle}</p> </div> </div> - <div className="bg-[#002862] w-full text-white py-2 rounded"> - <NavLink - to={item.url + details} - className="rounded uppercase hover:no-underline hover:text-white" - target="_self" - > - {item.btnText} - </NavLink> - </div> + <NavLink + to={item.url + details} + className="bg-[#002862] w-full text-white py-2 rounded uppercase hover:no-underline hover:text-white" + target="_self" + > + {item.btnText} + </NavLink> </div> <hr className="w-full bg-gray-300 p-[.5px]" /> <ul className="mx-1 p-3 text-left break-words text-sm list-none"> diff --git a/apps/OpenSign/src/routes/Report.js b/apps/OpenSign/src/routes/Report.js index efec224ac..44ecb74ff 100644 --- a/apps/OpenSign/src/routes/Report.js +++ b/apps/OpenSign/src/routes/Report.js @@ -47,30 +47,24 @@ const Report = () => { if (json) { setActions(json.actions); setReportName(json.reportName); - const { className, params, keys, orderBy } = json; Parse.serverURL = localStorage.getItem("BaseUrl12"); Parse.initialize(localStorage.getItem("AppID12")); const currentUser = Parse.User.current().id; - const serverURL = - localStorage.getItem("BaseUrl12") + "classes/" + className; - const strParams = JSON.stringify(params); - const strKeys = keys.join(); const headers = { "Content-Type": "application/json", "X-Parse-Application-Id": localStorage.getItem("AppID12"), - "X-Parse-Session-Token": localStorage.getItem("accesstoken") + sessiontoken: localStorage.getItem("accesstoken") }; try { - const url = `${serverURL}?where=${strParams}&keys=${strKeys}&order=${orderBy}&skip=${skipUserRecord}&limit=${limit}&include=AuditTrail.UserPtr`; - const res = await axios.get(url, { + const params = { reportId: id, skip: skipUserRecord, limit: limit }; + const url = `${localStorage.getItem("BaseUrl12")}/functions/getReport`; + const res = await axios.post(url, params, { headers: headers, signal: abortController.signal // is used to cancel fetch query }); if (id === "4Hhwbp482K") { - const listData = res.data?.results.filter( - (x) => x.Signers.length > 0 - ); + const listData = res.data?.result.filter((x) => x.Signers.length > 0); let arr = []; for (const obj of listData) { const isSigner = obj.Signers.some( @@ -101,7 +95,7 @@ const Report = () => { prevRecord.length > 0 ? [...prevRecord, ...arr] : arr ); } else { - if (res.data.results.length === 10) { + if (res.data.result.length === 10) { setIsMoreDocs(true); console.log("here"); } else { @@ -110,8 +104,8 @@ const Report = () => { setIsNextRecord(false); setList((prevRecord) => prevRecord.length > 0 - ? [...prevRecord, ...res.data.results] - : res.data.results + ? [...prevRecord, ...res.data.result] + : res.data.result ); } setIsLoader(false); diff --git a/apps/OpenSign/src/routes/Signup.js b/apps/OpenSign/src/routes/Signup.js index 3ae28e34c..8c7332a16 100644 --- a/apps/OpenSign/src/routes/Signup.js +++ b/apps/OpenSign/src/routes/Signup.js @@ -52,50 +52,27 @@ const Signup = (props) => { res .then(async (r) => { if (r) { - let roleurl = `${parseBaseUrl}functions/AddUserToRole`; - const headers = { - "Content-Type": "application/json", - "X-Parse-Application-Id": parseAppId, - sessionToken: - r.getSessionToken() || localStorage.getItem("accesstoken") - }; - let body = { - appName: props.appInfo.appname, - roleName: props.appInfo.defaultRole, - userId: r.id - }; - await axios.post(roleurl, body, { headers: headers }); - let roleData = props.appInfo.settings; if (roleData && roleData.length > 0) { - roleData.forEach((rld) => { - if (rld.role === props.appInfo.defaultRole) { - const extCls = Parse.Object.extend(rld.extended_class); - const newObj = new extCls(); - newObj.set("UserId", { - __type: "Pointer", - className: "_User", - objectId: r.id - }); - newObj.set("UserRole", props.appInfo.defaultRole); - newObj.set("Email", email); - newObj.set("Name", name); - newObj.set("Phone", phone); - newObj.set("Company", company); - newObj.set("JobTitle", jobTitle); - newObj - .save() - .then((ex) => { - if (ex) { - handleNavigation(r.getSessionToken()); - } - }) - .catch((err) => { - alert(err.message); - setState({ loading: false }); - }); + const params = { + userDetails: { + jobTitle: jobTitle, + company: company, + name: name, + email: email, + phone: phone, + role: props.appInfo.defaultRole } - }); + }; + try { + const usersignup = await Parse.Cloud.run("usersignup", params); + if (usersignup) { + handleNavigation(r.getSessionToken()); + } + } catch (err) { + alert(err.message); + setState({ loading: false }); + } } } }) diff --git a/apps/OpenSign/src/routes/UserProfile.js b/apps/OpenSign/src/routes/UserProfile.js index ae86ca1ba..f252f3644 100644 --- a/apps/OpenSign/src/routes/UserProfile.js +++ b/apps/OpenSign/src/routes/UserProfile.js @@ -214,26 +214,11 @@ function UserProfile() { </li> </ul> <div className="flex justify-center pb-4"> - <button - type="button" - onClick={() => { - if (editmode) { - setEditMode(false); - } else { - navigate("/changepassword"); - } - }} - className={`rounded shadow text-white bg-[#3598dc] mr-4 ${ - editmode ? "px-4 py-2 " : "p-2" - }`} - > - {editmode ? "Cancel" : "Change Password"} - </button> {editmode ? ( <button type="button" onClick={handleSubmit} - className="rounded bg-white border-[1px] border-[#15b4e9] text-[#15b4e9] px-4 py-2" + className="rounded bg-white border-[1px] border-[#15b4e9] text-[#15b4e9] px-4 py-2 mr-4" > Save </button> @@ -243,11 +228,26 @@ function UserProfile() { onClick={() => { setEditMode(true); }} - className="rounded shadow text-white bg-[#e7505a] px-4 py-2" + className="rounded shadow text-white bg-[#e7505a] px-4 py-2 mr-4" > Edit </button> )} + <button + type="button" + onClick={() => { + if (editmode) { + setEditMode(false); + } else { + navigate("/changepassword"); + } + }} + className={`rounded shadow text-white bg-[#3598dc] ${ + editmode ? "px-4 py-2 " : "p-2" + }`} + > + {editmode ? "Cancel" : "Change Password"} + </button> </div> </div> )} diff --git a/apps/OpenSign/src/styles/pgsignup.css b/apps/OpenSign/src/styles/pgsignup.css index fab477b35..102a878de 100644 --- a/apps/OpenSign/src/styles/pgsignup.css +++ b/apps/OpenSign/src/styles/pgsignup.css @@ -1,12 +1,14 @@ /* Full-width input fields */ .inputt { width: 100%; - padding: 15px; - margin: 5px 0 22px 0; + padding: 8px; + margin-bottom: 10px; + /* margin: 5px 0 14px 0; */ display: inline-block; border: none; background: #f1f1f1; color: black; + font-size: 12px; } /* Add a background color when the inputs get focus */ @@ -18,11 +20,12 @@ .confirmInputt { width: 100%; - padding: 15px; - margin: 5px 0 1px 0; + padding: 8px; + /* margin: 5px 0 14px 0; */ display: inline-block; background: #f1f1f1; color: black; + font-size: 12px; } .inputt::placeholder, @@ -42,11 +45,10 @@ .signupbtn { background-color: #15b4e9; color: white; - padding: 14px 20px; + padding: 12px 12px; margin: 8px 0; border: none; cursor: pointer; - width: 100%; opacity: 0.9; float: left; width: 50%; @@ -87,7 +89,7 @@ margin: 5% auto 15% auto; /* 5% from the top, 15% from the bottom and centered */ border: 1px solid #888; - width: 80%; + width: 50%; /* Could be more or less, depending on screen size */ } @@ -111,8 +113,26 @@ } /* Change styles for cancel button and signup button on extra small screens */ -@media screen and (max-width: 300px) { +@media screen and (max-width: 768px) { + + /* pgsignup Content/Box */ + .pgsignup-content { + background-color: #fefefe; + margin: 5% auto 15% auto; + /* 5% from the top, 15% from the bottom and centered */ + border: 1px solid #888; + width: 90%; + /* Could be more or less, depending on screen size */ + } + .signupbtn { width: 100%; + font-size: 16px; } -} + + /* Style the horizontal ruler */ + .hrt { + border: 1px solid #f1f1f1; + margin-bottom: 16px; + } +} \ No newline at end of file diff --git a/apps/OpenSignServer/cloud/main.js b/apps/OpenSignServer/cloud/main.js index 2facd600c..e42ee38e5 100644 --- a/apps/OpenSignServer/cloud/main.js +++ b/apps/OpenSignServer/cloud/main.js @@ -14,6 +14,9 @@ import SendMailv1 from './parsefunction/SendMailv1.js'; import AuthLoginAsMail from './parsefunction/AuthLoginAsMail.js'; import getUserId from './parsefunction/getUserId.js'; import getUserDetails from './parsefunction/getUserDetails.js'; +import getDocument from './parsefunction/getDocument.js'; +import getDrive from './parsefunction/getDrive.js'; +import getReport from './parsefunction/getReport.js'; Parse.Cloud.define('AddUserToRole', addUserToGroups); Parse.Cloud.define('UserGroups', getUserGroups); @@ -31,3 +34,6 @@ Parse.Cloud.define('sendmail', SendMailv1); Parse.Cloud.define('AuthLoginAsMail', AuthLoginAsMail); Parse.Cloud.define('getUserId', getUserId); Parse.Cloud.define('getUserDetails', getUserDetails); +Parse.Cloud.define('getDocument', getDocument); +Parse.Cloud.define('getDrive', getDrive) +Parse.Cloud.define('getReport', getReport) \ No newline at end of file diff --git a/apps/OpenSignServer/cloud/parsefunction/ZohoDetails.js b/apps/OpenSignServer/cloud/parsefunction/ZohoDetails.js index f2249e53b..0d9051b09 100644 --- a/apps/OpenSignServer/cloud/parsefunction/ZohoDetails.js +++ b/apps/OpenSignServer/cloud/parsefunction/ZohoDetails.js @@ -46,6 +46,10 @@ export default async function ZohoDetails(request) { (userData.data.data.subscription.customer && userData.data.data.subscription.customer.company_name) || ''; + const jobTitle = + (userData.data.data.subscription.customer && + userData.data.data.subscription.customer.cd_job_title) || + ''; const resData = { phone: userData.data.data.subscription.contactpersons[0].mobile, name: first_name + ' ' + last_name, @@ -55,6 +59,7 @@ export default async function ZohoDetails(request) { plan: userData.data.data.subscription.plan, customer_id: userData.data.data.subscription.customer_id, subscription_id: userData.data.data.subscription.subscription_id, + jobTitle: jobTitle, }; return resData; } diff --git a/apps/OpenSignServer/cloud/parsefunction/getDocument.js b/apps/OpenSignServer/cloud/parsefunction/getDocument.js new file mode 100644 index 000000000..9e4d71ff3 --- /dev/null +++ b/apps/OpenSignServer/cloud/parsefunction/getDocument.js @@ -0,0 +1,50 @@ +import axios from 'axios'; + +export default async function getDocument(request) { + const serverUrl = process.env.SERVER_URL; + const docId = request.params.docId; + + try { + const userRes = await axios.get(serverUrl + '/users/me', { + headers: { + 'X-Parse-Application-Id': process.env.APP_ID, + 'X-Parse-Session-Token': request.headers['sessiontoken'], + }, + }); + const userId = userRes.data && userRes.data.objectId; + if (docId && userId) { + try { + const query = new Parse.Query('contracts_Document'); + query.equalTo('objectId', docId); + query.include('ExtUserPtr'); + query.include('CreatedBy'); + query.include('Signers'); + query.include('AuditTrail.UserPtr'); + query.include('Placeholders'); + const res = await query.first({ useMasterKey: true }); + if (res) { + const acl = res.getACL(); + if (acl && acl.getReadAccess(userId)) { + return res; + } else { + return { error: "You don't have access of this document!" }; + } + } else { + return { error: "You don't have access of this document!" }; + } + } catch (err) { + console.log('err', err); + return err; + } + } else { + return { error: 'Please pass required parameters!' }; + } + } catch (err) { + console.log('err'); + if (err.code == 209) { + return { error: 'Invalid session token' }; + } else { + return { error: "You don't have access of this document!" }; + } + } +} diff --git a/apps/OpenSignServer/cloud/parsefunction/getDrive.js b/apps/OpenSignServer/cloud/parsefunction/getDrive.js new file mode 100644 index 000000000..5c0d31a8e --- /dev/null +++ b/apps/OpenSignServer/cloud/parsefunction/getDrive.js @@ -0,0 +1,51 @@ +import axios from 'axios'; +export default async function getDrive(request) { + const serverUrl = process.env.SERVER_URL; + const appId = process.env.APP_ID; + + const classUrl = serverUrl + '/classes/contracts_Document'; + const docId = request.params.docId; + try { + const userRes = await axios.get(serverUrl + '/users/me', { + headers: { + 'X-Parse-Application-Id': appId, + 'X-Parse-Session-Token': request.headers['sessiontoken'], + }, + }); + const userId = userRes.data && userRes.data.objectId; + if (userId) { + let url; + if (docId) { + url = `${classUrl}?where={"Folder":{"__type":"Pointer","className":"contracts_Document","objectId":"${docId}"},"$or":[{"CreatedBy":{"$exists":false}},{"CreatedBy":{"__type":"Pointer","className":"_User","objectId":"${userId}"}}]}&include=ExtUserPtr,Signers,Folder`; + } else { + url = `${classUrl}?where={"Folder":{"$exists":false},"$or":[{"CreatedBy":{"$exists":false}},{"CreatedBy":{"__type":"Pointer","className":"_User","objectId":"${userId}"}}]}&include=ExtUserPtr,Signers`; + } + try { + const res = await axios.get(url, { + headers: { + 'X-Parse-Application-Id': appId, + 'X-Parse-Master-key': process.env.MASTER_KEY, + }, + }); + // console.log('res.data.results ', res.data.results); + if (res.data && res.data.results) { + return res.data.results; + } else { + return []; + } + } catch (err) { + console.log('err', err); + return { error: "You don't have access to drive" }; + } + } else { + return { error: 'Please provide required parameter!' }; + } + } catch (err) { + console.log('err', err); + if (err.code == 209) { + return { error: 'Invalid session token' }; + } else { + return { error: "You don't have access!" }; + } + } +} diff --git a/apps/OpenSignServer/cloud/parsefunction/getReport.js b/apps/OpenSignServer/cloud/parsefunction/getReport.js new file mode 100644 index 000000000..1f2c6f1f1 --- /dev/null +++ b/apps/OpenSignServer/cloud/parsefunction/getReport.js @@ -0,0 +1,51 @@ +import reportJson from './reportsJson.js'; +import axios from 'axios' + +export default async function getReport(request) { + const reportId = request.params.reportId; + const limit = request.params.limit; + const skip = request.params.skip; + + const serverUrl = process.env.SERVER_URL; + const appId = process.env.APP_ID; + + try { + const userRes = await axios.get(serverUrl + '/users/me', { + headers: { + 'X-Parse-Application-Id': appId, + 'X-Parse-Session-Token': request.headers['sessiontoken'], + }, + }); + const userId = userRes.data && userRes.data.objectId; + if (userId) { + const json = reportId && reportJson(reportId, userId); + if (json) { + const { params, keys } = json; + const orderBy = '-updatedAt'; + const strParams = JSON.stringify(params); + const strKeys = keys.join(); + const headers = { + 'Content-Type': 'application/json', + 'X-Parse-Application-Id': appId, + 'X-Parse-Master-Key': process.env.MASTER_KEY, + }; + const url = `${serverUrl}/classes/contracts_Document?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) { + return res.data.results; + } else { + return []; + } + } else { + return { error: 'Report is not available!' }; + } + } + } catch (err) { + console.log('err', err); + if (err.code == 209) { + return { error: 'Invalid session token' }; + } else { + return { error: "You don't have access!" }; + } + } +} diff --git a/apps/OpenSignServer/cloud/parsefunction/pdf/PDF.min.js b/apps/OpenSignServer/cloud/parsefunction/pdf/PDF.min.js index 6e0bb6658..ba3f1ab97 100644 --- a/apps/OpenSignServer/cloud/parsefunction/pdf/PDF.min.js +++ b/apps/OpenSignServer/cloud/parsefunction/pdf/PDF.min.js @@ -105,7 +105,7 @@ async function PDF(s, r) { headers: { 'Content-Type': 'application/json', 'X-Parse-Application-Id': APPID, - 'X-Parse-Session-Token': s.headers.sessiontoken, + 'X-Parse-Master-Key': masterKEY, }, }), d = await axios.get(serverUrl + '/users/me', { diff --git a/apps/OpenSignServer/cloud/parsefunction/reportsJson.js b/apps/OpenSignServer/cloud/parsefunction/reportsJson.js new file mode 100644 index 000000000..83c295d74 --- /dev/null +++ b/apps/OpenSignServer/cloud/parsefunction/reportsJson.js @@ -0,0 +1,204 @@ +export default function reportJson(id, userId) { + const currentUserId = userId; + + switch (id) { + // draft documents report + case 'ByHuevtCFY': + return { + reportName: 'Draft Documents', + params: { + Type: null, + $or: [ + { Signers: null, SignedUrl: null }, + { Signers: { $exists: true }, Placeholders: null }, + ], + CreatedBy: { + __type: 'Pointer', + className: '_User', + objectId: currentUserId, + }, + }, + keys: ['Name', 'Note', 'Folder.Name', 'URL', 'ExtUserPtr.Name', 'Signers.Name'], + }; + // Need your sign report + case '4Hhwbp482K': + return { + reportName: 'Need your sign', + params: { + Type: { $ne: 'Folder' }, + IsCompleted: { $ne: true }, + IsDeclined: { $ne: true }, + ExpiryDate: { + $gt: { __type: 'Date', iso: new Date().toISOString() }, + }, + Placeholders: { $ne: null }, + }, + keys: [ + 'Name', + 'Note', + 'Folder.Name', + 'URL', + 'ExtUserPtr.Name', + 'Signers.Name', + 'Signers.UserId', + 'AuditTrail', + ], + }; + // In progess report + case '1MwEuxLEkF': + return { + reportName: 'In-progress documents', + params: { + Type: { $ne: 'Folder' }, + Signers: { $ne: null }, + Placeholders: { $ne: null }, + IsCompleted: { $ne: true }, + IsDeclined: { $ne: true }, + CreatedBy: { + __type: 'Pointer', + className: '_User', + objectId: currentUserId, + }, + ExpiryDate: { + $gt: { __type: 'Date', iso: new Date().toISOString() }, + }, + }, + keys: ['Name', 'Note', 'Folder.Name', 'URL', 'ExtUserPtr.Name', 'Signers.Name'], + }; + // completed documents report + case 'kQUoW4hUXz': + return { + reportName: 'Completed Documents', + params: { + Type: null, + IsCompleted: true, + CreatedBy: { + __type: 'Pointer', + className: '_User', + objectId: currentUserId, + }, + IsDeclined: { $ne: true }, + }, + keys: [ + 'Name', + 'Note', + 'Folder.Name', + 'URL', + 'ExtUserPtr.Name', + 'Signers.Name', + 'TimeToCompleteDays', + ], + }; + + // declined documents report + case 'UPr2Fm5WY3': + return { + reportName: 'Declined Documents', + params: { + Type: null, + IsDeclined: true, + CreatedBy: { + __type: 'Pointer', + className: '_User', + objectId: currentUserId, + }, + }, + + keys: ['Name', 'Note', 'Folder.Name', 'URL', 'ExtUserPtr.Name', 'Signers.Name'], + }; + // Expired Documents report + case 'zNqBHXHsYH': + return { + reportName: 'Expired Documents', + params: { + IsCompleted: { $ne: true }, + IsDeclined: { $ne: true }, + Type: { $ne: 'Folder' }, + $and: [ + { + $or: [ + { Signers: { $ne: null }, SignedUrl: { $ne: null } }, + { Placeholders: { $ne: null } }, + ], + }, + { + ExpiryDate: { + $lt: { __type: 'Date', iso: new Date().toISOString() }, + }, + }, + ], + CreatedBy: { + __type: 'Pointer', + className: '_User', + objectId: currentUserId, + }, + }, + keys: ['Name', 'Note', 'Folder.Name', 'URL', 'ExtUserPtr.Name', 'Signers.Name'], + }; + // Recently sent for signatures report show on dashboard + case 'd9k3UfYHBc': + return { + reportName: 'Recently sent for signatures', + params: { + Type: { $ne: 'Folder' }, + Signers: { $ne: null }, + Placeholders: { $ne: null }, + IsCompleted: { $ne: true }, + IsDeclined: { $ne: true }, + CreatedBy: { + __type: 'Pointer', + className: '_User', + objectId: currentUserId, + }, + ExpiryDate: { + $gt: { __type: 'Date', iso: new Date().toISOString() }, + }, + }, + keys: ['Name', 'Note', 'Folder.Name', 'URL', 'ExtUserPtr.Name', 'Signers.Name'], + }; + // Recent signature requests report show on dashboard + case '5Go51Q7T8r': + return { + reportName: 'Recent signature requests', + params: { + Type: { $ne: 'Folder' }, + IsCompleted: { $ne: true }, + IsDeclined: { $ne: true }, + ExpiryDate: { + $gt: { __type: 'Date', iso: new Date().toISOString() }, + }, + Placeholders: { $ne: null }, + }, + keys: [ + 'Name', + 'Note', + 'Folder.Name', + 'URL', + 'ExtUserPtr.Name', + 'Signers.Name', + 'Signers.UserId', + 'AuditTrail', + ], + }; + // Drafts report show on dashboard + case 'kC5mfynCi4': + return { + reportName: 'Drafts', + params: { + Type: null, + $or: [ + { Signers: null, SignedUrl: null }, + { Signers: { $exists: true }, Placeholders: null }, + ], + CreatedBy: { + __type: 'Pointer', + className: '_User', + objectId: currentUserId, + }, + }, + keys: ['Name', 'Note', 'Folder.Name', 'URL', 'ExtUserPtr.Name', 'Signers.Name'], + }; + default: + return null; + } +} diff --git a/apps/OpenSignServer/cloud/parsefunction/sendMail.js b/apps/OpenSignServer/cloud/parsefunction/sendMail.js index fb964e28f..c607c2822 100644 --- a/apps/OpenSignServer/cloud/parsefunction/sendMail.js +++ b/apps/OpenSignServer/cloud/parsefunction/sendMail.js @@ -55,29 +55,27 @@ async function sendmail(req) { const file = { filename: pdfName || 'exported.pdf', content: process.env.SMTP_ENABLE ? PdfBuffer : undefined, //fs.readFileSync('./exports/exported_file_1223.pdf'), - data: process.env.SMTP_ENABLE ? undefined : PdfBuffer, + data: process.env.SMTP_ENABLE ? undefined : PdfBuffer, }; // const html = "<html><head><meta http-equiv='Content-Type' content='text/html; charset=UTF-8' /></head><body style='text-align: center;'> <p style='font-weight: bolder; font-size: large;'>Hello!</p> <p>This is a html checking mail</p><p><button style='background-color: lightskyblue; cursor: pointer; border-radius: 5px; padding: 10px; border-style: solid; border-width: 2px; text-decoration: none; font-weight: bolder; color:blue'>Verify email</button></p></body></html>" const from = req.params.from || ''; + const mailsender = process.env.SMTP_ENABLE + ? process.env.SMTP_USER_EMAIL + : process.env.MAILGUN_SENDER; const messageParams = { - from: - from + ' <' + process.env.SMTP_ENABLE - ? process.env.SMTP_USER_EMAIL - : process.env.MAILGUN_SENDER + '>', + from: from + ' <' + mailsender + '>', to: req.params.recipient, subject: req.params.subject, text: req.params.text || 'mail', html: req.params.html || '', - attachments: process.env.SMTP_ENABLE ? [file] : undefined, - attachment: process.env.SMTP_ENABLE ? undefined : file, + attachments: process.env.SMTP_ENABLE ? [file] : undefined, + attachment: process.env.SMTP_ENABLE ? undefined : file, }; - if (transporterSMTP) { const res = await transporterSMTP.sendMail(messageParams); - console.log('Res ', res); if (!res.err) { return { @@ -96,11 +94,12 @@ async function sendmail(req) { } } else { const from = req.params.from || ''; + const mailsender = process.env.SMTP_ENABLE + ? process.env.SMTP_USER_EMAIL + : process.env.MAILGUN_SENDER; + const messageParams = { - from: - from + ' <' + process.env.SMTP_ENABLE - ? process.env.SMTP_USER_EMAIL - : process.env.MAILGUN_SENDER + '>', + from: from + ' <' + mailsender + '>', to: req.params.recipient, subject: req.params.subject, text: req.params.text || 'mail', @@ -109,7 +108,6 @@ async function sendmail(req) { if (transporterSMTP) { const res = await transporterSMTP.sendMail(messageParams); - console.log('Res ', res); if (!res.err) { return { diff --git a/microfrontends/SignDocuments/src/Component/Certificate/Certificate.js b/microfrontends/SignDocuments/src/Component/Certificate/Certificate.js index 37eee4fc3..f0ae76b05 100644 --- a/microfrontends/SignDocuments/src/Component/Certificate/Certificate.js +++ b/microfrontends/SignDocuments/src/Component/Certificate/Certificate.js @@ -246,6 +246,12 @@ function Certificate({ pdfData }) { {pdfData[0].ExtUserPtr.Name} </Text> </Text> + <Text style={styles.textStyle}> + Email :   + <Text style={styles.textStyle2}> + {pdfData[0].ExtUserPtr.Email} + </Text> + </Text> <Text style={styles.textStyle}> Accessed from :   <Text style={styles.textStyle2}> diff --git a/microfrontends/SignDocuments/src/Component/DraftDocument.js b/microfrontends/SignDocuments/src/Component/DraftDocument.js index 79806a94e..95ab370b9 100644 --- a/microfrontends/SignDocuments/src/Component/DraftDocument.js +++ b/microfrontends/SignDocuments/src/Component/DraftDocument.js @@ -1,61 +1,47 @@ import React, { useEffect, useState } from "react"; -import axios from "axios"; import { useNavigate } from "react-router-dom"; import Loader from "./component/loader"; -import { getHostUrl } from "../utils/Utils"; +import { contractDocument, getHostUrl } from "../utils/Utils"; function DraftDocument() { const navigate = useNavigate(); const [pdfDetails, setPdfDetails] = useState([]); const [isLoading, setIsLoading] = useState({ isLoad: true, - message: "This might take some time", + message: "This might take some time" }); const rowLevel = localStorage.getItem("rowlevel") && JSON.parse(localStorage.getItem("rowlevel")); - const signObjId = + const docId = rowLevel && rowLevel?.id ? rowLevel.id : rowLevel?.objectId && rowLevel.objectId; + useEffect(() => { - if (signObjId) { + if (docId) { getDocumentDetails(); } }, []); //get document details const getDocumentDetails = async () => { - await axios - .get( - `${localStorage.getItem("baseUrl")}classes/${localStorage.getItem( - "_appName" - )}_Document?where={"objectId":"${signObjId}"}&include=ExtUserPtr,Signers`, - { - headers: { - "Content-Type": "application/json", - "X-Parse-Application-Id": localStorage.getItem("parseAppId"), - "X-Parse-Session-Token": localStorage.getItem("accesstoken"), - }, - } - ) - .then((Listdata) => { - const json = Listdata.data; - const res = json.results; - - if (res[0] && res.length > 0) { - setPdfDetails(res); - const loadObj = { - isLoad: false, - }; - setIsLoading(loadObj); - } else { - alert("No data found!"); - } - }) - .catch((err) => { - console.log("axois err ", err); - }); + //getting document details + const documentData = await contractDocument(docId); + if (documentData && documentData.length > 0) { + setPdfDetails(documentData); + const loadObj = { + isLoad: false + }; + setIsLoading(loadObj); + } else if ( + documentData === "Error: Something went wrong!" || + (documentData.result && documentData.result.error) + ) { + alert("Error: Something went wrong!"); + } else { + alert("No data found!"); + } }; //check document type and render on signyour self and placeholder route @@ -63,24 +49,25 @@ function DraftDocument() { const data = pdfDetails[0]; const checkSignerExist = pdfDetails[0] && pdfDetails[0].Signers && pdfDetails[0].Signers; - const isPlaceholder = + const isPlaceholder = pdfDetails[0].Placeholders && pdfDetails[0].Placeholders; const isDecline = data.IsDeclined && data.IsDeclined; const signUrl = data.SignedUrl && data.SignedUrl; - const expireDate = pdfDetails[0] && pdfDetails[0].ExpiryDate.iso && pdfDetails[0].ExpiryDate.iso; + const expireDate = + pdfDetails[0] && + pdfDetails[0].ExpiryDate.iso && + pdfDetails[0].ExpiryDate.iso; const expireUpdateDate = new Date(expireDate).getTime(); const currDate = new Date().getTime(); const hostUrl = getHostUrl(); //checking document is completed and signer exist then navigate to pdfRequestFiles file if (data.IsCompleted && checkSignerExist) { - navigate(`${hostUrl}pdfRequestFiles`); + navigate(`${hostUrl}pdfRequestFiles`); } //checking document is completed and signer does not exist then navigate to recipientSignPdf file else if (data.IsCompleted && !checkSignerExist) { - navigate( - `${hostUrl}signaturePdf` - ); + navigate(`${hostUrl}signaturePdf`); } //checking document is declined by someone then navigate to pdfRequestFiles file else if (isDecline) { diff --git a/microfrontends/SignDocuments/src/Component/LegaDrive/LegaDrive.js b/microfrontends/SignDocuments/src/Component/LegaDrive/LegaDrive.js index cd004168a..db0c94425 100644 --- a/microfrontends/SignDocuments/src/Component/LegaDrive/LegaDrive.js +++ b/microfrontends/SignDocuments/src/Component/LegaDrive/LegaDrive.js @@ -6,6 +6,7 @@ import PdfFileComponent from "./FolderDrive/legaDriveComponent"; import Modal from "react-bootstrap/Modal"; import ModalHeader from "react-bootstrap/esm/ModalHeader"; import { themeColor, iconColor } from "../../utils/ThemeColor/backColor"; +import { getDrive } from "../../utils/Utils"; function PdfFile() { const scrollRef = useRef(null); @@ -15,29 +16,18 @@ function PdfFile() { const [pdfData, setPdfData] = useState([]); const [isFolder, setIsFolder] = useState(false); const [newFolderName, setNewFolderName] = useState(); - // const [parentFolderName, setParentFolderName] = useState(); - // const [parentFolder, setParentFolder] = useState([]); const [error, setError] = useState(); const [folderLoader, setIsFolderLoader] = useState(false); const [isShowSort, setIsShowSort] = useState(false); const [isLoading, setIsLoading] = useState({ isLoad: true, - message: "This might take some time", + message: "This might take some time" }); const [docId, setDocId] = useState(); const [handleError, setHandleError] = useState(); const [folderName, setFolderName] = useState([]); - const senderUser = - localStorage.getItem( - `Parse/${localStorage.getItem("parseAppId")}/currentUser` - ) && - localStorage.getItem( - `Parse/${localStorage.getItem("parseAppId")}/currentUser` - ); - const jsonSender = JSON.parse(senderUser); - useEffect(() => { if (docId) { getPdfFolderDocumentList(); @@ -50,104 +40,59 @@ function PdfFile() { const getPdfDocumentList = async () => { const load = { isLoad: true, - message: "This might take some time", + message: "This might take some time" }; setIsLoading(load); - //?where={"Type":"Folder" }&include=ExtUserPtr,Signers - //?where={"$or":[{"Type":{"$exists":true}},{"Folder":{"$exists":false}}]}&include=ExtUserPtr,Signers - // "CreatedBy":{"__type":"Pointer","className":"_User","objectId":"${jsonSender.objectId}"} - // where={"Folder":{"$exists":false} }&include=ExtUserPtr,Signers`, - await axios - .get( - `${localStorage.getItem("baseUrl")}classes/${localStorage.getItem( - "_appName" - )}_Document?where={"Folder":{"$exists":false},"$or":[{"CreatedBy":{"$exists":false}},{"CreatedBy":{"__type":"Pointer","className":"_User","objectId":"${ - jsonSender.objectId - }"}}]}&include=ExtUserPtr,Signers`, - { - headers: { - "Content-Type": "application/json", - "X-Parse-Application-Id": localStorage.getItem("parseAppId"), - "X-Parse-Session-Token": localStorage.getItem("accesstoken"), - }, - } - ) - .then((Listdata) => { - const json = Listdata.data; - const res = json.results; - // console.log("result", res); - if (res[0] && res.length > 0) { - setPdfData(res); - } + const driveDetails = await getDrive(); - const data = [ - { - name: "OpenSignDrive™", - objectId: "", - }, - ]; - setFolderName(data); - const loadObj = { - isLoad: false, - }; - setIsLoading(loadObj); - }) - .catch((err) => { - const loadObj = { - isLoad: false, - }; - setHandleError("Error: Something went wrong!"); - setIsLoading(loadObj); - }); + if (driveDetails) { + if (driveDetails.length > 0) { + setPdfData(driveDetails); + } + const data = [ + { + name: "OpenSignDrive™", + objectId: "" + } + ]; + setFolderName(data); + const loadObj = { + isLoad: false + }; + setIsLoading(loadObj); + } else if (driveDetails === "Error: Something went wrong!") { + const loadObj = { + isLoad: false + }; + setHandleError("Error: Something went wrong!"); + setIsLoading(loadObj); + } }; //function for get parent folder document list const getPdfFolderDocumentList = async () => { const load = { isLoad: true, - message: "This might take some time", + message: "This might take some time" }; setIsLoading(load); - //{"$inQuery":{"where":{"objectId":"${docId}"},"className":"${appName}_Document"}} - //"CreatedBy":{"__type":"Pointer","className":"_User","objectId":"${jsonSender.objectId}"} - await axios - .get( - `${localStorage.getItem("baseUrl")}classes/${localStorage.getItem( - "_appName" - )}_Document?where={"Folder":{"__type":"Pointer","className":"${localStorage.getItem( - "_appName" - )}_Document","objectId":"${docId}"},"$or":[{"CreatedBy":{"$exists":false}},{"CreatedBy":{"__type":"Pointer","className":"_User","objectId":"${ - jsonSender.objectId - }"}}]}&include=ExtUserPtr,Signers,Folder`, - { - headers: { - "Content-Type": "application/json", - "X-Parse-Application-Id": localStorage.getItem("parseAppId"), - "X-Parse-Session-Token": localStorage.getItem("accesstoken"), - }, - } - ) - .then((Listdata) => { - const json = Listdata.data; - const res = json.results; - - if (res[0] && res.length > 0) { - setPdfData(res); - } else { - setPdfData([]); - } - - const loadObj = { - isLoad: false, - }; - setIsLoading(loadObj); - }) - .catch((err) => { - const loadObj = { - isLoad: false, - }; - setHandleError("Error: Something went wrong!"); - setIsLoading(loadObj); - }); + const driveDetails = await getDrive(docId); + if (driveDetails) { + if (driveDetails.length > 0) { + setPdfData(driveDetails); + } else { + setPdfData([]); + } + const loadObj = { + isLoad: false + }; + setIsLoading(loadObj); + } else if (driveDetails === "Error: Something went wrong!") { + const loadObj = { + isLoad: false + }; + setHandleError("Error: Something went wrong!"); + setIsLoading(loadObj); + } }; //function for get all pdf document list @@ -158,7 +103,7 @@ function PdfFile() { const handleRoute = (data) => { let loadObj = { isLoad: true, - message: "This might take some time", + message: "This might take some time" }; if (data.name === "LegaDrive™") { setIsLoading(loadObj); @@ -167,7 +112,7 @@ function PdfFile() { } else { setTimeout(() => { const loadObj = { - isLoad: false, + isLoad: false }; setIsLoading(loadObj); }, 1000); @@ -176,12 +121,11 @@ function PdfFile() { setIsLoading(loadObj); setTimeout(() => { const loadObj = { - isLoad: false, + isLoad: false }; setIsLoading(loadObj); }, 1000); } else { - // console.log("go here1",data.objectId) const findIndex = folderName.findIndex( (fold) => fold.objectId === data.objectId ); @@ -216,13 +160,13 @@ function PdfFile() { Folder: { __type: "Pointer", className: `${localStorage.getItem("_appName")}_Document`, - objectId: isParentId, - }, + objectId: isParentId + } }; } else { data = { Name: newFolderName, - Type: "Folder", + Type: "Folder" }; } @@ -237,8 +181,8 @@ function PdfFile() { headers: { "Content-Type": "application/json", "X-Parse-Application-Id": localStorage.getItem("parseAppId"), - "X-Parse-Session-Token": localStorage.getItem("accesstoken"), - }, + "X-Parse-Session-Token": localStorage.getItem("accesstoken") + } } ) @@ -388,7 +332,7 @@ function PdfFile() { display: "flex", flexDirection: "column", justifyContent: "center", - alignItems: "center", + alignItems: "center" }} > <img @@ -406,7 +350,7 @@ function PdfFile() { style={{ margin: "10px 0px 10px 0px", fontSize: "15px", - fontWeight: "400", + fontWeight: "400" }} > Name* @@ -428,7 +372,7 @@ function PdfFile() { display: "flex", alignItems: "flex-end", justifyContent: "flex-end", - alignContent: "flex-end", + alignContent: "flex-end" }} > <button @@ -437,7 +381,7 @@ function PdfFile() { borderRadius: "0px", border: "1.5px solid #e3e2e1", fontWeight: "600", - color: "black", + color: "black" }} className="finishBtn" onClick={() => setIsFolder(false)} @@ -448,7 +392,7 @@ function PdfFile() { <button onClick={() => handleAddFolder()} style={{ - background: themeColor(), + background: themeColor() }} type="button" className="finishBtn" @@ -469,7 +413,7 @@ function PdfFile() { alignItems: "center", height: "100vh", width: "100%", - flexDirection: "column", + flexDirection: "column" }} > <img @@ -488,7 +432,7 @@ function PdfFile() { justifyContent: "center", alignItems: "center", height: "100vh", - width: "100%", + width: "100%" }} > <span style={{ fontSize: "20px", color: "gray" }}> @@ -502,7 +446,7 @@ function PdfFile() { onMouseEnter={(e) => handleMouseEnter(e)} ref={scrollRef} style={{ - width: "100%", + width: "100%" }} className="folderPath" > @@ -514,7 +458,7 @@ function PdfFile() { style={{ color: "#a64b4e", fontWeight: "400", - cursor: "pointer", + cursor: "pointer" }} > {data.name} @@ -523,7 +467,7 @@ function PdfFile() { color: "#a64b4e", fontWeight: "200", cursor: "pointer", - margin: "0 4px", + margin: "0 4px" }} > > @@ -545,13 +489,13 @@ function PdfFile() { style={{ marginRight: "5px", fontSize: "14px", - color: `${iconColor()}`, + color: `${iconColor()}` }} ></i> <span style={{ fontSize: "15px", - color: `${iconColor()}`, + color: `${iconColor()}` }} > {selectedSort} @@ -694,7 +638,7 @@ function PdfFile() { justifyContent: "center", alignItems: "center", height: "50vh", - width: "100%", + width: "100%" }} > <span style={{ fontWeight: "bold" }}>No Data Found!</span> diff --git a/microfrontends/SignDocuments/src/Component/PdfRequestFiles.js b/microfrontends/SignDocuments/src/Component/PdfRequestFiles.js index d741162d5..9adca6778 100644 --- a/microfrontends/SignDocuments/src/Component/PdfRequestFiles.js +++ b/microfrontends/SignDocuments/src/Component/PdfRequestFiles.js @@ -11,7 +11,11 @@ import { HTML5Backend } from "react-dnd-html5-backend"; import { useParams } from "react-router-dom"; import SignPad from "./component/signPad"; import RenderAllPdfPage from "./component/renderAllPdfPage"; -import { getBase64FromIMG, getBase64FromUrl } from "../utils/Utils"; +import { + contractDocument, + getBase64FromIMG, + getBase64FromUrl +} from "../utils/Utils"; import Loader from "./component/loader"; import HandleError from "./component/HandleError"; import Nodata from "./component/Nodata"; @@ -106,152 +110,135 @@ function PdfRequestFiles() { //function for get document details for perticular signer with signer'object id const getDocumentDetails = async () => { - await axios - .get( - `${localStorage.getItem("baseUrl")}classes/${localStorage.getItem( - "_appName" - )}_Document?where={"objectId":"${documentId}"}&include=ExtUserPtr,Signers,UserPtr`, - { - headers: { - "Content-Type": "application/json", - "X-Parse-Application-Id": localStorage.getItem("parseAppId"), - "X-Parse-Session-Token": localStorage.getItem("accesstoken") - } - } - ) - .then((Listdata) => { - const json = Listdata.data; - const res = json.results; + //getting document details + const documentData = await contractDocument(documentId); + if (documentData && documentData.length > 0) { + const isCompleted = + documentData[0].IsCompleted && documentData[0].IsCompleted; + const expireDate = documentData[0].ExpiryDate.iso; + const declined = documentData[0].IsDeclined && documentData[0].IsDeclined; + const expireUpdateDate = new Date(expireDate).getTime(); + const currDate = new Date().getTime(); + const getSigners = documentData[0].Signers; + const getCurrentSigner = + getSigners && + getSigners.filter( + (data) => data.UserId.objectId === jsonSender.objectId + ); - if (res[0] && res.length > 0) { - const isCompleted = res[0].IsCompleted && res[0].IsCompleted; - const expireDate = res[0].ExpiryDate.iso; - const declined = res[0].IsDeclined && res[0].IsDeclined; - const expireUpdateDate = new Date(expireDate).getTime(); - const currDate = new Date().getTime(); - const getSigners = res[0].Signers; - const getCurrentSigner = - getSigners && - getSigners.filter( - (data) => data.UserId.objectId === jsonSender.objectId - ); - - const currUserId = getCurrentSigner[0] - ? getCurrentSigner[0].objectId - : ""; - setSignerObjectId(currUserId); - if (res[0].SignedUrl) { - setPdfUrl(res[0].SignedUrl); - } else { - setPdfUrl(res[0].URL); - } - if (isCompleted) { - setIsSigned(true); - const data = { - isCertificate: true, - isModal: true - }; - setAlreadySign(true); - setIsCompleted(data); - } else if (declined) { - const currentDecline = { - currnt: "another", - isDeclined: true - }; - setIsDecline(currentDecline); - } else if (currDate > expireUpdateDate) { - setIsExpired(true); - } - - if (res.length > 0) { - const checkDocIdExist = - json.results[0].AuditTrail && - json.results[0].AuditTrail.length > 0 && - json.results[0].AuditTrail.filter( - (data) => data.Activity === "Signed" - ); - - const checkAlreadySign = - json.results[0].AuditTrail && - json.results[0].AuditTrail.length > 0 && - json.results[0].AuditTrail.filter( - (data) => - data.UserPtr.objectId === currUserId && - data.Activity === "Signed" - ); - if ( - checkAlreadySign && - checkAlreadySign[0] && - checkAlreadySign.length > 0 - ) { - setAlreadySign(true); - } - - let signers = []; - let unSignedSigner = []; - - //check document is signed or not - if (checkDocIdExist && checkDocIdExist.length > 0) { - setIsDocId(true); - const signerRes = res[0].Signers; - //comparison auditTrail user details with signers user details - for (let i = 0; i < signerRes.length; i++) { - const signerId = signerRes[i].objectId; - - let isSigned = false; - for (let j = 0; j < checkDocIdExist.length; j++) { - const signedExist = - checkDocIdExist[j] && checkDocIdExist[j].UserPtr.objectId; - //checking signerObjId and auditTrail User objId - // if match then add signed data in signer array and break loop - - if (signerId === signedExist) { - signers.push({ ...signerRes[i], ...signerRes[i] }); - isSigned = true; - break; - } - // if does not match then add unsigned data in unSignedSigner array - } - if (!isSigned) { - unSignedSigner.push({ ...signerRes[i], ...signerRes[i] }); - } - } - setSignedSigners(signers); - setUnSignedSigners(unSignedSigner); - - setSignerPos(res[0].Placeholders); - } else { - let unsigned = []; - for (let i = 0; i < res.length; i++) { - unsigned.push(res[i].Signers); - } - setUnSignedSigners(unsigned[0]); - setSignerPos(res[0].Placeholders); - } - - setPdfDetails(res); - - setIsUiLoading(false); - } else { - alert("No data found!"); - } - } else { - setNoData(true); - const loadObj = { - isLoad: false - }; - setIsLoading(loadObj); - setIsUiLoading(false); - } - }) - .catch((err) => { - console.log("err", err); - const loadObj = { - isLoad: false + const currUserId = getCurrentSigner[0] + ? getCurrentSigner[0].objectId + : ""; + setSignerObjectId(currUserId); + if (documentData[0].SignedUrl) { + setPdfUrl(documentData[0].SignedUrl); + } else { + setPdfUrl(documentData[0].URL); + } + if (isCompleted) { + setIsSigned(true); + const data = { + isCertificate: true, + isModal: true }; - setHandleError("Error: Something went wrong!"); - setIsLoading(loadObj); - }); + setAlreadySign(true); + setIsCompleted(data); + } else if (declined) { + const currentDecline = { + currnt: "another", + isDeclined: true + }; + setIsDecline(currentDecline); + } else if (currDate > expireUpdateDate) { + setIsExpired(true); + } + + if (documentData.length > 0) { + const checkDocIdExist = + documentData[0].AuditTrail && + documentData[0].AuditTrail.length > 0 && + documentData[0].AuditTrail.filter( + (data) => data.Activity === "Signed" + ); + + const checkAlreadySign = + documentData[0].AuditTrail && + documentData[0].AuditTrail.length > 0 && + documentData[0].AuditTrail.filter( + (data) => + data.UserPtr.objectId === currUserId && data.Activity === "Signed" + ); + if ( + checkAlreadySign && + checkAlreadySign[0] && + checkAlreadySign.length > 0 + ) { + setAlreadySign(true); + } + + let signers = []; + let unSignedSigner = []; + + //check document is signed or not + if (checkDocIdExist && checkDocIdExist.length > 0) { + setIsDocId(true); + const signerRes = documentData[0].Signers; + //comparison auditTrail user details with signers user details + for (let i = 0; i < signerRes.length; i++) { + const signerId = signerRes[i].objectId; + + let isSigned = false; + for (let j = 0; j < checkDocIdExist.length; j++) { + const signedExist = + checkDocIdExist[j] && checkDocIdExist[j].UserPtr.objectId; + //checking signerObjId and auditTrail User objId + // if match then add signed data in signer array and break loop + + if (signerId === signedExist) { + signers.push({ ...signerRes[i], ...signerRes[i] }); + isSigned = true; + break; + } + // if does not match then add unsigned data in unSignedSigner array + } + if (!isSigned) { + unSignedSigner.push({ ...signerRes[i], ...signerRes[i] }); + } + } + setSignedSigners(signers); + setUnSignedSigners(unSignedSigner); + + setSignerPos(documentData[0].Placeholders); + } else { + let unsigned = []; + for (let i = 0; i < documentData.length; i++) { + unsigned.push(documentData[i].Signers); + } + setUnSignedSigners(unsigned[0]); + setSignerPos(documentData[0].Placeholders); + } + setPdfDetails(documentData); + setIsUiLoading(false); + } else { + alert("No data found!"); + } + } else if ( + documentData === "Error: Something went wrong!" || + (documentData.result && documentData.result.error) + ) { + const loadObj = { + isLoad: false + }; + setHandleError("Error: Something went wrong!"); + setIsLoading(loadObj); + } else { + setNoData(true); + const loadObj = { + isLoad: false + }; + setIsLoading(loadObj); + setIsUiLoading(false); + } await axios .get( `${localStorage.getItem("baseUrl")}classes/${localStorage.getItem( @@ -293,7 +280,6 @@ function PdfRequestFiles() { const checkUser = signerPos.filter( (data) => data.signerObjId === signerObjectId ); - if (checkUser && checkUser.length > 0) { let checkSignUrl = []; const checkSign = checkUser[0].placeHolder.filter( @@ -596,12 +582,12 @@ function PdfRequestFiles() { if (isMobile) { //if pos.isMobile false -- placeholder saved from desktop view then handle position in mobile view divided by scale if (pos.isMobile) { - const y = pos.yPosition * (pos.scale / scale); + const y = pos.yBottom * (pos.scale / scale); yPosition = pos.isDrag ? y * scale - height : pos.firstYPos - ? y * scale - height + pos.firstYPos - : y * scale - height; + ? y * scale - height + pos.firstYPos + : y * scale - height; return yPosition; } else { const y = pos.yBottom / scale; @@ -609,8 +595,8 @@ function PdfRequestFiles() { yPosition = pos.isDrag ? y * scale - height : pos.firstYPos - ? y * scale - height + pos.firstYPos - : y * scale - height; + ? y * scale - height + pos.firstYPos + : y * scale - height; return yPosition; } } else { @@ -621,15 +607,15 @@ function PdfRequestFiles() { yPosition = pos.isDrag ? y - height : pos.firstYPos - ? y - height + pos.firstYPos - : y - height; + ? y - height + pos.firstYPos + : y - height; return yPosition; } else { yPosition = pos.isDrag ? pos.yBottom - height : pos.firstYPos - ? pos.yBottom - height + pos.firstYPos - : pos.yBottom - height; + ? pos.yBottom - height + pos.firstYPos + : pos.yBottom - height; return yPosition; } } diff --git a/microfrontends/SignDocuments/src/Component/SignYourselfPdf.js b/microfrontends/SignDocuments/src/Component/SignYourselfPdf.js index 6591667bc..2b5eebdc8 100644 --- a/microfrontends/SignDocuments/src/Component/SignYourselfPdf.js +++ b/microfrontends/SignDocuments/src/Component/SignYourselfPdf.js @@ -15,7 +15,7 @@ import EmailComponent from "./component/emailComponent"; import FieldsComponent from "./component/fieldsComponent"; import Modal from "react-bootstrap/Modal"; import ModalHeader from "react-bootstrap/esm/ModalHeader"; -import { getBase64FromIMG } from "../utils/Utils"; +import { contractDocument, getBase64FromIMG } from "../utils/Utils"; import { useParams } from "react-router-dom"; import Tour from "reactour"; import { onSaveImage, onSaveSign } from "../utils/Utils"; @@ -173,55 +173,42 @@ function SignYourSelf() { //function for get document details for perticular signer with signer'object id const getDocumentDetails = async () => { - await axios - .get( - `${localStorage.getItem("baseUrl")}classes/${localStorage.getItem( - "_appName" - )}_Document?where={"objectId":"${documentId}"}&include=ExtUserPtr,Signers`, - { - headers: { - "Content-Type": "application/json", - "X-Parse-Application-Id": localStorage.getItem("parseAppId"), - "X-Parse-Session-Token": localStorage.getItem("accesstoken") - } - } - ) - .then((Listdata) => { - const json = Listdata.data; - const res = json.results; + //getting document details + const documentData = await contractDocument(documentId); - if (res[0] && res.length > 0) { - setPdfDetails(res); - const isCompleted = res[0].IsCompleted && res[0].IsCompleted; - if (isCompleted) { - const docStatus = { - isCompleted: isCompleted - }; - - setDocumentStatus(docStatus); - const alreadySign = { - status: true, - mssg: "You have successfully signed the document!" - }; - setShowAlreadySignDoc(alreadySign); - setPdfUrl(res[0].SignedUrl); - } - } else { - setNoData(true); - - const loadObj = { - isLoad: false - }; - setIsLoading(loadObj); - } - }) - .catch((err) => { - const loadObj = { - isLoad: false + if (documentData && documentData.length > 0) { + setPdfDetails(documentData); + const isCompleted = + documentData[0].IsCompleted && documentData[0].IsCompleted; + if (isCompleted) { + const docStatus = { + isCompleted: isCompleted }; - setHandleError("Error: Something went wrong!"); - setIsLoading(loadObj); - }); + + setDocumentStatus(docStatus); + const alreadySign = { + status: true, + mssg: "You have successfully signed the document!" + }; + setShowAlreadySignDoc(alreadySign); + setPdfUrl(documentData[0].SignedUrl); + } + } else if ( + documentData === "Error: Something went wrong!" || + (documentData.result && documentData.result.error) + ) { + const loadObj = { + isLoad: false + }; + setHandleError("Error: Something went wrong!"); + setIsLoading(loadObj); + } else { + setNoData(true); + const loadObj = { + isLoad: false + }; + setIsLoading(loadObj); + } await axios .get( `${localStorage.getItem("baseUrl")}classes/${localStorage.getItem( @@ -252,13 +239,10 @@ function SignYourSelf() { setHandleError("Error: Something went wrong!"); setIsLoading(loadObj); }); - const contractUsersRes = await contractUsers(jsonSender.objectId); - if ( - contractUsersRes !== "Error: Something went wrong!" && - contractUsersRes && - contractUsersRes[0] - ) { + const contractUsersRes = await contractUsers(jsonSender.email); + + if (contractUsersRes[0] && contractUsersRes.length > 0) { setContractName("_Users"); setSignerUserId(contractUsersRes[0].objectId); const tourstatuss = @@ -285,14 +269,12 @@ function SignYourSelf() { setIsLoading(loadObj); } else if (contractUsersRes.length === 0) { const contractContactBook = await contactBook(jsonSender.objectId); - if (contractContactBook && contractContactBook[0]) { + if (contractContactBook && contractContactBook.length > 0) { setContractName("_Contactbook"); - setSignerUserId(contractContactBook[0].objectId); const tourstatuss = contractContactBook[0].TourStatus && contractContactBook[0].TourStatus; - if (tourstatuss && tourstatuss.length > 0) { setTourStatus(tourstatuss); const checkTourRecipients = tourstatuss.filter( @@ -302,6 +284,8 @@ function SignYourSelf() { setCheckTourStatus(checkTourRecipients[0].signyourself); } } + } else { + setNoData(true); } const loadObj = { isLoad: false diff --git a/microfrontends/SignDocuments/src/Component/component/renderPdf.js b/microfrontends/SignDocuments/src/Component/component/renderPdf.js index 07cade06e..58e3670cd 100644 --- a/microfrontends/SignDocuments/src/Component/component/renderPdf.js +++ b/microfrontends/SignDocuments/src/Component/component/renderPdf.js @@ -606,7 +606,7 @@ function RenderPdf({ > {" "} <div - onTouchStart={(e) => { + onTouchEnd ={(e) => { if (!isDragging) { setTimeout(() => { e.stopPropagation(); @@ -640,6 +640,7 @@ function RenderPdf({ alt="signimg" onClick={(e) => { setSignKey(pos.key); + console.log("Drag 2"); setIsSignPad(true); setIsStamp(pos.isStamp); }} @@ -692,11 +693,10 @@ function RenderPdf({ }} > <div - onTouchStart={(e) => { + onTouchEnd ={(e) => { if (!isDragging) { setTimeout(() => { setIsSignPad(true); - setSignKey(pos.key); setIsStamp(pos.isStamp); }, 500); diff --git a/microfrontends/SignDocuments/src/Component/placeHolderSign.js b/microfrontends/SignDocuments/src/Component/placeHolderSign.js index 93be3b571..a9464269a 100644 --- a/microfrontends/SignDocuments/src/Component/placeHolderSign.js +++ b/microfrontends/SignDocuments/src/Component/placeHolderSign.js @@ -17,7 +17,12 @@ import HandleError from "./component/HandleError"; import Nodata from "./component/Nodata"; import SignerListPlace from "./component/signerListPlace"; import Header from "./component/header"; -import { contactBook, contractUsers, getHostUrl } from "../utils/Utils"; +import { + contactBook, + contractDocument, + contractUsers, + getHostUrl +} from "../utils/Utils"; import RenderPdf from "./component/renderPdf"; import ModalComponent from "./component/modalComponent"; import { useNavigate } from "react-router-dom"; @@ -169,56 +174,40 @@ function PlaceHolderSign() { //function for get document details const getDocumentDetails = async () => { - await axios - .get( - `${localStorage.getItem("baseUrl")}classes/${localStorage.getItem( - "_appName" - )}_Document?where={"objectId":"${documentId}"}&include=ExtUserPtr,Signers`, - { - headers: { - "Content-Type": "application/json", - "X-Parse-Application-Id": localStorage.getItem("parseAppId"), - "X-Parse-Session-Token": localStorage.getItem("accesstoken") - } - } - ) - .then((Listdata) => { - const json = Listdata.data; - const res = json.results; + //getting document details + const documentData = await contractDocument(documentId); + if (documentData && documentData.length > 0) { + setPdfDetails(documentData); - if (res[0] && res.length > 0) { - setPdfDetails(res); + const currEmail = documentData[0].ExtUserPtr.Email; + const filterCurrEmail = documentData[0].Signers.filter( + (data) => data.Email === currEmail + ); - const currEmail = res[0].ExtUserPtr.Email; - const filterCurrEmail = res[0].Signers.filter( - (data) => data.Email === currEmail - ); + setCurrentEmail(filterCurrEmail); + setSignersData(documentData[0]); - setCurrentEmail(filterCurrEmail); - setSignersData(res[0]); - - setSignerObjId(res[0].Signers[0].objectId); - setContractName(res[0].Signers[0].className); - setIsSelectId(0); - } else { - setNoData(true); - const loadObj = { - isLoad: false - }; - setIsLoading(loadObj); - } - }) - .catch((err) => { - console.log("axois err ", err); - const loadObj = { - isLoad: false - }; - setHandleError("Error: Something went wrong!"); - setIsLoading(loadObj); - }); - - const res = await contractUsers(jsonSender.objectId); + setSignerObjId(documentData[0].Signers[0].objectId); + setContractName(documentData[0].Signers[0].className); + setIsSelectId(0); + } else if ( + documentData === "Error: Something went wrong!" || + (documentData.result && documentData.result.error) + ) { + const loadObj = { + isLoad: false + }; + setHandleError("Error: Something went wrong!"); + setIsLoading(loadObj); + } else { + setNoData(true); + const loadObj = { + isLoad: false + }; + setIsLoading(loadObj); + } + const res = await contractUsers(jsonSender.email); if (res[0] && res.length) { setSignerUserId(res[0].objectId); const tourstatus = res[0].TourStatus && res[0].TourStatus; diff --git a/microfrontends/SignDocuments/src/Component/recipientSignPdf.js b/microfrontends/SignDocuments/src/Component/recipientSignPdf.js index 77b3de40e..0b9a106c9 100644 --- a/microfrontends/SignDocuments/src/Component/recipientSignPdf.js +++ b/microfrontends/SignDocuments/src/Component/recipientSignPdf.js @@ -14,7 +14,9 @@ import DefaultSignature from "./component/defaultSignature"; import { getBase64FromUrl, getBase64FromIMG, - contactBookName + contractUsers, + contactBook, + contractDocument } from "../utils/Utils"; import Tour from "reactour"; import Signedby from "./component/signedby"; @@ -74,6 +76,15 @@ function EmbedPdfImage() { return object.pageNumber === pageNumber; }); const divRef = useRef(null); + const senderUser = localStorage.getItem( + `Parse/${localStorage.getItem("parseAppId")}/currentUser` + ) + ? localStorage.getItem( + `Parse/${localStorage.getItem("parseAppId")}/currentUser` + ) + : `${localStorage.getItem("UserInformation")}` && + `${localStorage.getItem("UserInformation")}`; + const jsonSender = JSON.parse(senderUser); //check isGuestSigner is present in local if yes than handle login flow header in mobile view const isGuestSigner = localStorage.getItem("isGuestSigner"); useEffect(() => { @@ -96,33 +107,26 @@ function EmbedPdfImage() { //function for get document details for perticular signer with signer'object id const getDocumentDetails = async () => { let currUserId, userObjectId; - const json = await contactBookName(contactBookId, "_Contactbook"); - if (json !== "Error: Something went wrong!" && json && json.results[0]) { + //getting contracts_contactBook details + const json = await contactBook(contactBookId); + if (json && json.length > 0) { setContractName("_Contactbook"); - if (json.results[0]) { - userObjectId = json.results[0].UserId.objectId; - setUserObjectID(userObjectId); - currUserId = json.results[0].objectId; - setSignerUserId(currUserId); - const tourstatus = - json.results[0].TourStatus && json.results[0].TourStatus; + userObjectId = json[0].UserId.objectId; + setUserObjectID(userObjectId); + currUserId = json[0].objectId; - if (tourstatus && tourstatus.length > 0) { - setTourStatus(tourstatus); - const checkTourRecipients = tourstatus.filter( - (data) => data.recipientssign - ); - if (checkTourRecipients && checkTourRecipients.length > 0) { - setCheckTourStatus(checkTourRecipients[0].recipientssign); - } + setSignerUserId(currUserId); + const tourstatus = json[0].TourStatus && json[0].TourStatus; + + if (tourstatus && tourstatus.length > 0) { + setTourStatus(tourstatus); + const checkTourRecipients = tourstatus.filter( + (data) => data.recipientssign + ); + if (checkTourRecipients && checkTourRecipients.length > 0) { + setCheckTourStatus(checkTourRecipients[0].recipientssign); } - } else { - setNoData(true); - const loadObj = { - isLoad: false - }; - setIsLoading(loadObj); } } else if (json === "Error: Something went wrong!") { const loadObj = { @@ -131,18 +135,16 @@ function EmbedPdfImage() { setHandleError("Error: Something went wrong!"); setIsLoading(loadObj); } else { - const json = await contactBookName(contactBookId, "_Users"); - - if (json !== "Error: Something went wrong!" && json && json.results[0]) { + const json = await contractUsers(jsonSender.email); + if (json && json.length > 0) { setContractName("_Users"); - if (json.results[0]) { - userObjectId = json.results[0].UserId.objectId; + if (json[0]) { + userObjectId = json[0].UserId.objectId; setUserObjectID(userObjectId); - currUserId = json.results[0].objectId; + currUserId = json[0].objectId; setSignerUserId(currUserId); - const tourstatus = - json.results[0].TourStatus && json.results[0].TourStatus; + const tourstatus = json[0].TourStatus && json[0].TourStatus; if (tourstatus && tourstatus.length > 0) { setTourStatus(tourstatus); @@ -166,171 +168,170 @@ function EmbedPdfImage() { }; setHandleError("Error: Something went wrong!"); setIsLoading(loadObj); - } - } + } else { + setNoData(true); - await axios - .get( - `${localStorage.getItem("baseUrl")}classes/${localStorage.getItem( - "_appName" - )}_Document?where={"objectId":"${docId}"}&include=ExtUserPtr,Signers,AuditTrail - ,`, - { - headers: { - "Content-Type": "application/json", - "X-Parse-Application-Id": localStorage.getItem("parseAppId"), - "X-Parse-Session-Token": localStorage.getItem("accesstoken") - } - } - ) - .then((Listdata) => { - const json = Listdata.data; - const res = json.results; - if (res[0] && res.length > 0) { - const declined = res[0].IsDeclined && res[0].IsDeclined; - const isCompleted = res[0].IsCompleted && res[0].IsCompleted; - const expireDate = res[0].ExpiryDate.iso; - - const expireUpdateDate = new Date(expireDate).getTime(); - const currDate = new Date().getTime(); - if (isCompleted) { - //checking document is completed (signed by all requested signers) than isCompleted true - //then show alert with completed message - const alreadySign = { - status: true, - mssg: "This document has been successfully signed!" - }; - setIsAlreadySign(alreadySign); - setPdfUrl(res[0].SignedUrl); - setSignedPdfData(json.results); - setCompletePdfData(res); - } else if (declined) { - const currentDecline = { - currnt: "another", - isDeclined: true - }; - setIsDecline(currentDecline); - - setSignedPdfData(json.results); - } else if (currDate > expireUpdateDate) { - setIsExpired(true); - const checkDocIdExist = - json.results[0].AuditTrail && - json.results[0].AuditTrail.length > 0 && - json.results[0].AuditTrail.filter( - (data) => data.Activity === "Signed" - ); - - //if signed by someone than go to in if condition - // and second signer could not be add documentId - //for that setIsDocId true - if (checkDocIdExist && checkDocIdExist.length > 0) { - setIsDocId(true); - const currUser = - json.results[0].Placeholders && - json.results[0].Placeholders.filter( - (data) => data.signerObjId === currUserId - ); - - setSignedPdfData(json.results); - - setXyPostion(currUser[0].placeHolder); - - const key = currUser[0].placeHolder[0].pos[0].key; - setSignKey(key); - } - //for show current requested signer's placeholder - else { - const currUser = - json.results[0].Placeholders && - json.results[0].Placeholders.filter( - (data) => data.signerObjId === currUserId - ); - - setSignedPdfData(json.results); - - setXyPostion(currUser[0].placeHolder); - - const key = currUser[0].placeHolder[0].pos[0].key; - setSignKey(key); - } - } else { - //checking document has signed by someone or not - - const checkDocIdExist = - json.results[0].AuditTrail && - json.results[0].AuditTrail.length > 0 && - json.results[0].AuditTrail.filter( - (data) => data.Activity === "Signed" - ); - - //if signed by someone than go to in if condition - // and second signer could not be add documentId - //for that setIsDocId true - - if (checkDocIdExist && checkDocIdExist.length > 0) { - setIsDocId(true); - - //condition for checking document signed by current requested user or not - const checkAlreadyBySigner = json.results[0].AuditTrail.filter( - (data) => - data.UserPtr.objectId === currUserId && - data.Activity === "Signed" - ); - - // if checkAlreadyBySigner has some data that current user already sign this document - // then show alert with message - if (checkAlreadyBySigner && checkAlreadyBySigner.length > 0) { - const alreadySign = { - status: true, - mssg: "You have successfully signed the document!" - }; - setIsAlreadySign(alreadySign); - setPdfUrl(res[0].SignedUrl); - setSignedPdfData(json.results); - } - //else show placeholder of current requested signer - else { - const currUser = - json.results[0].Placeholders && - json.results[0].Placeholders.filter( - (data) => data.signerObjId === currUserId - ); - - setSignedPdfData(json.results); - - setXyPostion(currUser[0].placeHolder); - - const key = currUser[0].placeHolder[0].pos[0].key; - setSignKey(key); - } - } - //for show current requested signer's placeholder - else { - const currUser = - json.results[0].Placeholders && - json.results[0].Placeholders.filter( - (data) => data.signerObjId === currUserId - ); - - setSignedPdfData(json.results); - - setXyPostion(currUser[0].placeHolder); - - const key = currUser[0].placeHolder[0].pos[0].key; - setSignKey(key); - } - } - } - }) - .catch((err) => { const loadObj = { isLoad: false }; - setHandleError("Error: Something went wrong!"); setIsLoading(loadObj); - console.log("err", err); - }); + } + } + + //getting document details + const documentData = await contractDocument(docId); + if (documentData && documentData.length > 0) { + const declined = documentData[0].IsDeclined && documentData[0].IsDeclined; + const isCompleted = + documentData[0].IsCompleted && documentData[0].IsCompleted; + const expireDate = documentData[0].ExpiryDate.iso; + + const expireUpdateDate = new Date(expireDate).getTime(); + const currDate = new Date().getTime(); + if (isCompleted) { + //checking document is completed (signed by all requested signers) than isCompleted true + //then show alert with completed message + const alreadySign = { + status: true, + mssg: "This document has been successfully signed!" + }; + setIsAlreadySign(alreadySign); + setPdfUrl(documentData[0].SignedUrl); + setSignedPdfData(documentData); + setCompletePdfData(documentData); + } else if (declined) { + const currentDecline = { + currnt: "another", + isDeclined: true + }; + setIsDecline(currentDecline); + + setSignedPdfData(documentData); + } else if (currDate > expireUpdateDate) { + setIsExpired(true); + const checkDocIdExist = + documentData[0].AuditTrail && + documentData[0].AuditTrail.length > 0 && + documentData[0].AuditTrail.filter( + (data) => data.Activity === "Signed" + ); + + //if signed by someone than go to in if condition + // and second signer could not be add documentId + //for that setIsDocId true + if (checkDocIdExist && checkDocIdExist.length > 0) { + setIsDocId(true); + const currUser = + documentData.Placeholders && + documentData.Placeholders.filter( + (data) => data.signerObjId === currUserId + ); + + setSignedPdfData(documentData); + + setXyPostion(currUser[0].placeHolder); + + const key = currUser[0].placeHolder[0].pos[0].key; + setSignKey(key); + } + //for show current requested signer's placeholder + else { + const currUser = + documentData[0].Placeholders && + documentData[0].Placeholders.filter( + (data) => data.signerObjId === currUserId + ); + + setSignedPdfData(documentData); + + setXyPostion(currUser[0].placeHolder); + + const key = currUser[0].placeHolder[0].pos[0].key; + setSignKey(key); + } + } else { + //checking document has signed by someone or not + + const checkDocIdExist = + documentData[0].AuditTrail && + documentData[0].AuditTrail.length > 0 && + documentData[0].AuditTrail.filter( + (data) => data.Activity === "Signed" + ); + + //if signed by someone than go to in if condition + // and second signer could not be add documentId + //for that setIsDocId true + + if (checkDocIdExist && checkDocIdExist.length > 0) { + setIsDocId(true); + + //condition for checking document signed by current requested user or not + const checkAlreadyBySigner = documentData[0].AuditTrail.filter( + (data) => + data.UserPtr.objectId === currUserId && data.Activity === "Signed" + ); + + // if checkAlreadyBySigner has some data that current user already sign this document + // then show alert with message + if (checkAlreadyBySigner && checkAlreadyBySigner.length > 0) { + const alreadySign = { + status: true, + mssg: "You have successfully signed the document!" + }; + setIsAlreadySign(alreadySign); + setPdfUrl(documentData[0].SignedUrl); + setSignedPdfData(documentData); + } + //else show placeholder of current requested signer + else { + const currUser = + documentData[0].Placeholders && + documentData[0].Placeholders.filter( + (data) => data.signerObjId === currUserId + ); + + setSignedPdfData(documentData); + + setXyPostion(currUser[0].placeHolder); + + const key = currUser[0].placeHolder[0].pos[0].key; + setSignKey(key); + } + } + //for show current requested signer's placeholder + else { + const currUser = + documentData[0].Placeholders && + documentData[0].Placeholders.filter( + (data) => data.signerObjId === currUserId + ); + + setSignedPdfData(documentData); + + setXyPostion(currUser[0].placeHolder); + + const key = currUser[0].placeHolder[0].pos[0].key; + setSignKey(key); + } + } + } else if ( + documentData === "Error: Something went wrong!" || + (documentData.result && documentData.result.error) + ) { + const loadObj = { + isLoad: false + }; + setHandleError("Error: Something went wrong!"); + setIsLoading(loadObj); + } else { + setNoData(true); + + const loadObj = { + isLoad: false + }; + setIsLoading(loadObj); + } await axios .get( `${localStorage.getItem("baseUrl")}classes/${localStorage.getItem( @@ -662,8 +663,8 @@ function EmbedPdfImage() { yPosition = pos.isDrag ? y * scale - height : pos.firstYPos - ? y * scale - height + pos.firstYPos - : y * scale - height; + ? y * scale - height + pos.firstYPos + : y * scale - height; return yPosition; } else { const y = pos.yBottom / scale; @@ -671,8 +672,8 @@ function EmbedPdfImage() { yPosition = pos.isDrag ? y * scale - height : pos.firstYPos - ? y * scale - height + pos.firstYPos - : y * scale - height; + ? y * scale - height + pos.firstYPos + : y * scale - height; return yPosition; } } else { @@ -683,15 +684,15 @@ function EmbedPdfImage() { yPosition = pos.isDrag ? y - height : pos.firstYPos - ? y - height + pos.firstYPos - : y - height; + ? y - height + pos.firstYPos + : y - height; return yPosition; } else { yPosition = pos.isDrag ? pos.yBottom - height : pos.firstYPos - ? pos.yBottom - height + pos.firstYPos - : pos.yBottom - height; + ? pos.yBottom - height + pos.firstYPos + : pos.yBottom - height; return yPosition; } } @@ -1083,7 +1084,7 @@ function EmbedPdfImage() { isShowHeader={true} currentSigner={true} decline={true} - alreadySign={pdfUrl ? true :false} + alreadySign={pdfUrl ? true : false} /> <RenderPdf @@ -1128,9 +1129,7 @@ function EmbedPdfImage() { )} </div> )} - </DndProvider> ); } - -export default EmbedPdfImage; \ No newline at end of file +export default EmbedPdfImage; diff --git a/microfrontends/SignDocuments/src/utils/Utils.js b/microfrontends/SignDocuments/src/utils/Utils.js index 0b915423d..9274d9235 100644 --- a/microfrontends/SignDocuments/src/utils/Utils.js +++ b/microfrontends/SignDocuments/src/utils/Utils.js @@ -57,7 +57,6 @@ export function onSaveImage(xyPostion, index, signKey, imgWH, image) { (data, ind) => data.key === signKey && data.Width && data.Height && data.SignUrl ); - if (updateFilter.length > 0) { let newWidth, newHeight; @@ -139,7 +138,7 @@ export function onSaveImage(xyPostion, index, signKey, imgWH, image) { ...url, Width: getPosData[0].Width ? getPosData[0].Width : newWidth, Height: getPosData[0].Height ? getPosData[0].Height : newHeight, - SignUrl: image.src, + SignUrl: image.src, ImageType: image.imgType }; } @@ -153,7 +152,6 @@ export function onSaveImage(xyPostion, index, signKey, imgWH, image) { return obj; }); return newUpdateUrl; - // setXyPostion(newUpdateUrl); } } @@ -183,34 +181,99 @@ export function onSaveSign(xyPostion, index, signKey, signatureImg) { return newUpdateUrl; } -//function for getting contract_User details -export const contractUsers = async (objectId) => { - const result = await axios - .get( - `${localStorage.getItem("baseUrl")}classes/${localStorage.getItem( - "_appName" - )}_Users?where={"UserId": {"__type": "Pointer","className": "_User", "objectId":"${objectId}"}}`, - { - headers: { - "Content-Type": "application/json", - "X-Parse-Application-Id": localStorage.getItem("parseAppId"), - "X-Parse-Session-Token": localStorage.getItem("accesstoken") - } +//function for getting document details from contract_Documents class +export const contractDocument = async (documentId) => { + const data = { + docId: documentId + }; + const documentDeatils = await axios + .post(`${localStorage.getItem("baseUrl")}functions/getDocument`, data, { + headers: { + "Content-Type": "application/json", + "X-Parse-Application-Id": localStorage.getItem("parseAppId"), + sessionToken: localStorage.getItem("accesstoken") } - ) + }) .then((Listdata) => { const json = Listdata.data; - const res = json.results; - return res; + let data = []; + if (json && json.result.error) { + return json; + } else if (json && json.result) { + data.push(json.result); + return data; + } else { + return []; + } }) .catch((err) => { return "Error: Something went wrong!"; }); - return result; + return documentDeatils; }; -//function for getting contrscts_contactbook details +//function for getting document details for getDrive +export const getDrive = async (documentId) => { + const data = { + docId: documentId && documentId + }; + const driveDeatils = await axios + .post(`${localStorage.getItem("baseUrl")}functions/getDrive`, data, { + headers: { + "Content-Type": "application/json", + "X-Parse-Application-Id": localStorage.getItem("parseAppId"), + sessiontoken: localStorage.getItem("accesstoken") + } + }) + .then((Listdata) => { + const json = Listdata.data; + + if (json && json.result.error) { + return json; + } else if (json && json.result) { + const data = json.result; + return data; + } else { + return []; + } + }) + .catch((err) => { + return "Error: Something went wrong!"; + }); + + return driveDeatils; +}; +//function for getting contract_User details +export const contractUsers = async (email) => { + const data = { + email: email + }; + const userDetails = await axios + .post(`${localStorage.getItem("baseUrl")}functions/getUserDetails`, data, { + headers: { + "Content-Type": "application/json", + "X-Parse-Application-Id": localStorage.getItem("parseAppId"), + sessionToken: localStorage.getItem("accesstoken") + } + }) + .then((Listdata) => { + const json = Listdata.data; + let data = []; + + if (json && json.result) { + data.push(json.result); + return data; + } + }) + .catch((err) => { + return "Error: Something went wrong!"; + }); + + return userDetails; +}; + +//function for getting contracts_contactbook details export const contactBook = async (objectId) => { const result = await axios .get( @@ -236,27 +299,3 @@ export const contactBook = async (objectId) => { }); return result; }; - -export const contactBookName = async (objectId, className) => { - const result = await axios - .get( - `${localStorage.getItem("baseUrl")}classes/${localStorage.getItem( - "_appName" - )}${className}?where={"objectId":"${objectId}"}`, - { - headers: { - "Content-Type": "application/json", - "X-Parse-Application-Id": localStorage.getItem("parseAppId"), - "X-Parse-Session-Token": localStorage.getItem("accesstoken") - } - } - ) - .then((Listdata) => { - const json = Listdata.data; - return json; - }) - .catch((err) => { - return "Error: Something went wrong!"; - }); - return result; -};