Skip to content

Commit 9952afc

Browse files
feat: draft template api
1 parent 86ebd49 commit 9952afc

32 files changed

+3391
-557
lines changed

apps/OpenSign/src/App.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ const GenerateToken = lazy(() => import("./pages/GenerateToken"));
3535
const Webhook = lazy(() => import("./pages/Webhook"));
3636
const AddAdmin = lazy(() => import("./pages/AddAdmin"));
3737
const UpdateExistUserAdmin = lazy(() => import("./pages/UpdateExistUserAdmin"));
38+
const DraftTemplate = lazy(() => import("./pages/DraftTemplate"));
3839

3940
pdfjs.GlobalWorkerOptions.workerSrc = `//unpkg.com/pdfjs-dist@${pdfjs.version}/legacy/build/pdf.worker.min.mjs`;
4041
const AppLoader = () => {
@@ -200,6 +201,10 @@ function App() {
200201
<Route path="/users" element={<UserList />} />
201202
</Route>
202203
<Route path="/sso" element={<SSOVerify />} />
204+
<Route
205+
path="/drafttemplate/:jwttoken"
206+
element={<DraftTemplate />}
207+
/>
203208
<Route path="*" element={<PageNotFound />} />
204209
</Routes>
205210
</BrowserRouter>

apps/OpenSign/src/components/BulkSendUi.js

Lines changed: 26 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,21 @@ const BulkSendUi = (props) => {
6969
if (subscription?.plan === "freeplan") {
7070
setIsFreePlan(true);
7171
}
72-
const resCredits = await Parse.Cloud.run("allowedcredits");
72+
const token = props.jwttoken
73+
? { jwttoken: props.jwttoken }
74+
: { "X-Parse-Session-Token": localStorage.getItem("accesstoken") };
75+
const axiosres = await axios.post(
76+
`${localStorage.getItem("baseUrl")}functions/allowedcredits`,
77+
{},
78+
{
79+
headers: {
80+
"Content-Type": "application/json",
81+
"X-Parse-Application-Id": localStorage.getItem("parseAppId"),
82+
...token
83+
}
84+
}
85+
);
86+
const resCredits = axiosres.data && axiosres.data.result;
7387
if (resCredits) {
7488
const allowedcredits = resCredits?.allowedcredits || 0;
7589
const addoncredits = resCredits?.addoncredits || 0;
@@ -81,7 +95,7 @@ const BulkSendUi = (props) => {
8195
}
8296
setAmount((obj) => ({ ...obj, totalcredits: totalcredits }));
8397
}
84-
const getPlaceholder = props.item?.Placeholders;
98+
const getPlaceholder = props?.Placeholders;
8599
const checkIsSignatureExistt = getPlaceholder?.every((placeholderObj) =>
86100
placeholderObj?.placeHolder?.some((holder) =>
87101
holder?.pos?.some((posItem) => posItem?.type === "signature")
@@ -97,7 +111,7 @@ const BulkSendUi = (props) => {
97111
} else {
98112
setIsBulkAvailable(true);
99113
setAdmin((obj) => ({ ...obj, isAdmin: true }));
100-
const getPlaceholder = props.item?.Placeholders;
114+
const getPlaceholder = props?.Placeholders;
101115
const checkIsSignatureExistt = getPlaceholder?.every((placeholderObj) =>
102116
placeholderObj?.placeHolder?.some((holder) =>
103117
holder?.pos?.some((posItem) => posItem?.type === "signature")
@@ -194,7 +208,7 @@ const BulkSendUi = (props) => {
194208
setIsSubmit(true);
195209

196210
// Create a copy of Placeholders array from props.item
197-
let Placeholders = [...props.item.Placeholders];
211+
let Placeholders = [...props.Placeholders];
198212
// Initialize an empty array to store updated documents
199213
let Documents = [];
200214
// Loop through each form
@@ -251,12 +265,16 @@ const BulkSendUi = (props) => {
251265
};
252266

253267
const batchQuery = async (Documents) => {
254-
const serverUrl = localStorage.getItem("baseUrl");
255-
const functionsUrl = `${serverUrl}functions/batchdocuments`;
268+
const token = props.jwttoken
269+
? { jwttoken: props.jwttoken }
270+
: { "X-Parse-Session-Token": localStorage.getItem("accesstoken") };
271+
const functionsUrl = `${localStorage.getItem(
272+
"baseUrl"
273+
)}functions/batchdocuments`;
256274
const headers = {
257275
"Content-Type": "application/json",
258276
"X-Parse-Application-Id": localStorage.getItem("parseAppId"),
259-
sessionToken: localStorage.getItem("accesstoken")
277+
...token
260278
};
261279
const params = { Documents: JSON.stringify(Documents) };
262280
try {
@@ -362,6 +380,7 @@ const BulkSendUi = (props) => {
362380
fieldIndex
363381
)
364382
}
383+
jwttoken={props?.jwttoken}
365384
/>
366385
</div>
367386
))}

apps/OpenSign/src/components/shared/fields/SelectSigners.js

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import React, { useState } from "react";
2-
import Parse from "parse";
32
import AsyncSelect from "react-select/async";
43
import { useTranslation } from "react-i18next";
4+
import axios from "axios";
55

66
const SelectSigners = (props) => {
77
const { t } = useTranslation();
@@ -31,17 +31,19 @@ const SelectSigners = (props) => {
3131

3232
const loadOptions = async (inputValue) => {
3333
try {
34-
const currentUser = Parse.User.current();
35-
const contactbook = new Parse.Query("contracts_Contactbook");
36-
contactbook.equalTo(
37-
"CreatedBy",
38-
Parse.User.createWithoutData(currentUser.id)
39-
);
40-
if (inputValue.length > 1) {
41-
contactbook.matches("Name", new RegExp(inputValue, "i"));
42-
}
43-
contactbook.notEqualTo("IsDeleted", true);
44-
const contactRes = await contactbook.find();
34+
const baseURL = localStorage.getItem("baseUrl");
35+
const url = `${baseURL}functions/getsigners`;
36+
const token = props?.jwttoken
37+
? { jwttoken: props?.jwttoken }
38+
: { "X-Parse-Session-Token": localStorage.getItem("accesstoken") };
39+
const headers = {
40+
"Content-Type": "application/json",
41+
"X-Parse-Application-Id": localStorage.getItem("parseAppId"),
42+
...token
43+
};
44+
const search = inputValue;
45+
const axiosRes = await axios.post(url, { search }, { headers });
46+
const contactRes = axiosRes?.data?.result || [];
4547
if (contactRes) {
4648
const res = JSON.parse(JSON.stringify(contactRes));
4749
//compareArrays is a function where compare between two array (total signersList and dcument signers list)

apps/OpenSign/src/components/shared/fields/SuggestionInput.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ const SuggestionInput = (props) => {
2525
if (timer) clearTimeout(timer);
2626
timer = setTimeout(() => {
2727
(async () => {
28-
const res = await findContact(inputValue);
28+
const res = await findContact(inputValue, props.jwttoken);
2929
if (res?.length > 0) {
3030
setSuggestions(res);
3131
setShowSuggestions(true);
@@ -37,6 +37,7 @@ const SuggestionInput = (props) => {
3737
}, 1000);
3838
}
3939
return () => clearTimeout(timer);
40+
// eslint-disable-next-line react-hooks/exhaustive-deps
4041
}, [inputValue]);
4142

4243
const handleInputChange = async (e) => {

apps/OpenSign/src/constant/Utils.js

Lines changed: 59 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,8 @@ export async function fetchSubscription(
3434
extUserId,
3535
contactObjId,
3636
isGuestSign = false,
37-
isPublic = false
37+
isPublic = false,
38+
jwtToken
3839
) {
3940
try {
4041
const Extand_Class = localStorage.getItem("Extand_Class");
@@ -48,10 +49,13 @@ export async function fetchSubscription(
4849
}
4950
const baseURL = localStorage.getItem("baseUrl");
5051
const url = `${baseURL}functions/getsubscriptions`;
52+
const token = jwtToken
53+
? { jwttoken: jwtToken }
54+
: { sessionToken: localStorage.getItem("accesstoken") };
5155
const headers = {
5256
"Content-Type": "application/json",
5357
"X-Parse-Application-Id": localStorage.getItem("parseAppId"),
54-
sessionToken: localStorage.getItem("accesstoken")
58+
...token
5559
};
5660
const params = isGuestSign
5761
? { contactId: contactObjId }
@@ -226,12 +230,25 @@ export const pdfNewWidthFun = (divRef) => {
226230
};
227231

228232
//`contractUsers` function is used to get contract_User details
229-
export const contractUsers = async () => {
233+
export const contractUsers = async (jwttoken) => {
230234
try {
231-
const userDetails = await Parse.Cloud.run("getUserDetails");
235+
const url = `${localStorage.getItem("baseUrl")}functions/getUserDetails`;
236+
const parseAppId = localStorage.getItem("parseAppId");
237+
const accesstoken = localStorage.getItem("accesstoken");
238+
const token = jwttoken
239+
? { jwttoken: jwttoken }
240+
: { "X-Parse-Session-Token": accesstoken };
241+
const headers = {
242+
headers: {
243+
"Content-Type": "application/json",
244+
"X-Parse-Application-Id": parseAppId,
245+
...token
246+
}
247+
};
248+
const userDetails = await axios.post(url, {}, headers);
232249
let data = [];
233-
if (userDetails) {
234-
const json = JSON.parse(JSON.stringify(userDetails));
250+
if (userDetails?.data?.result) {
251+
const json = JSON.parse(JSON.stringify(userDetails.data.result));
235252
data.push(json);
236253
}
237254
return data;
@@ -1762,14 +1779,17 @@ export const contactBook = async (objectId) => {
17621779
};
17631780

17641781
//function for getting document details from contract_Documents class
1765-
export const contractDocument = async (documentId) => {
1782+
export const contractDocument = async (documentId, JwtToken) => {
17661783
const data = { docId: documentId };
1784+
const token = JwtToken
1785+
? { jwtToken: JwtToken }
1786+
: { sessionToken: localStorage.getItem("accesstoken") };
17671787
const documentDeatils = await axios
17681788
.post(`${localStorage.getItem("baseUrl")}functions/getDocument`, data, {
17691789
headers: {
17701790
"Content-Type": "application/json",
17711791
"X-Parse-Application-Id": localStorage.getItem("parseAppId"),
1772-
sessionToken: localStorage.getItem("accesstoken")
1792+
...token
17731793
}
17741794
})
17751795
.then((Listdata) => {
@@ -1969,20 +1989,28 @@ export const getAppLogo = async () => {
19691989
}
19701990
};
19711991

1972-
export const getTenantDetails = async (objectId) => {
1992+
export const getTenantDetails = async (objectId, jwttoken) => {
19731993
try {
1974-
const tenantCreditsQuery = new Parse.Query("partners_Tenant");
1975-
tenantCreditsQuery.equalTo("UserId", {
1976-
__type: "Pointer",
1977-
className: "_User",
1978-
objectId: objectId
1994+
const url = `${localStorage.getItem("baseUrl")}functions/gettenant`;
1995+
const parseAppId = localStorage.getItem("parseAppId");
1996+
const accesstoken = localStorage.getItem("accesstoken");
1997+
const token = jwttoken
1998+
? { jwttoken: jwttoken }
1999+
: { "X-Parse-Session-Token": accesstoken };
2000+
const data = jwttoken ? {} : { userId: objectId };
2001+
const res = await axios.post(url, data, {
2002+
headers: {
2003+
"Content-Type": "application/json",
2004+
"X-Parse-Application-Id": parseAppId,
2005+
...token
2006+
}
19792007
});
1980-
const res = await tenantCreditsQuery.first();
19812008
if (res) {
1982-
const updateRes = JSON.parse(JSON.stringify(res));
2009+
const updateRes = JSON.parse(JSON.stringify(res.data.result));
19832010
return updateRes;
19842011
}
1985-
} catch (e) {
2012+
} catch (err) {
2013+
console.log("err in gettenant", err);
19862014
return "user does not exist!";
19872015
}
19882016
};
@@ -2231,18 +2259,21 @@ export const handleDownloadCertificate = async (
22312259
}
22322260
}
22332261
};
2234-
export async function findContact(value) {
2262+
export async function findContact(value, jwttoken) {
22352263
try {
2236-
const currentUser = Parse.User.current();
2237-
const contactbook = new Parse.Query("contracts_Contactbook");
2238-
contactbook.equalTo(
2239-
"CreatedBy",
2240-
Parse.User.createWithoutData(currentUser.id)
2241-
);
2242-
contactbook.notEqualTo("IsDeleted", true);
2243-
contactbook.matches("Email", new RegExp(value, "i"));
2244-
2245-
const contactRes = await contactbook.find();
2264+
const baseURL = localStorage.getItem("baseUrl");
2265+
const url = `${baseURL}functions/getsigners`;
2266+
const token = jwttoken
2267+
? { jwttoken: jwttoken }
2268+
: { "X-Parse-Session-Token": localStorage.getItem("accesstoken") };
2269+
const headers = {
2270+
"Content-Type": "application/json",
2271+
"X-Parse-Application-Id": localStorage.getItem("parseAppId"),
2272+
...token
2273+
};
2274+
const searchEmail = value;
2275+
const axiosRes = await axios.post(url, { searchEmail }, { headers });
2276+
const contactRes = axiosRes?.data?.result || [];
22462277
if (contactRes) {
22472278
const res = JSON.parse(JSON.stringify(contactRes));
22482279
return res;

0 commit comments

Comments
 (0)