Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion apps/OpenSign/src/components/pdf/EmailComponent.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,16 @@ function EmailComponent({
pdfName,
sender,
setIsAlert,
extUserId
extUserId,
activeMailAdapter
}) {
const [emailList, setEmailList] = useState([]);
const [emailValue, setEmailValue] = useState();
const [isLoading, setIsLoading] = useState(false);
//function for send email
const sendEmail = async () => {
setIsLoading(true);

let sendMail;
for (let i = 0; i < emailList.length; i++) {
try {
Expand All @@ -39,6 +41,7 @@ function EmailComponent({
const openSignUrl = "https://www.opensignlabs.com/contact-us";
const themeBGcolor = themeColor;
let params = {
mailProvider: activeMailAdapter,
extUserId: extUserId,
pdfName: pdfName,
url: pdfUrl,
Expand Down
23 changes: 17 additions & 6 deletions apps/OpenSign/src/constant/Utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,10 @@ export const openInNewTab = (url) => {
window.open(url, "_blank", "noopener,noreferrer");
};

export async function fetchSubscription(extUserId) {
export async function fetchSubscription(extUserId, contactObjId) {
try {
const extClass = localStorage.getItem("Extand_Class");
const isGuestSign = localStorage.getItem("isGuestSigner");
let extUser;
if (extClass) {
const jsonSender = JSON.parse(extClass);
Expand All @@ -30,11 +31,19 @@ export async function fetchSubscription(extUserId) {
"X-Parse-Application-Id": localStorage.getItem("parseAppId"),
sessionToken: localStorage.getItem("accesstoken")
};
const params = { extUserId: extUser };
const params = isGuestSign
? { contactId: contactObjId }
: { extUserId: extUser };
const tenatRes = await axios.post(url, params, { headers: headers });
const plan = tenatRes.data?.result?.result?.PlanCode;
const billingDate = tenatRes.data?.result?.result?.Next_billing_date?.iso;
return { plan, billingDate };
let plan, status, billingDate;
if (isGuestSign) {
plan = tenatRes.data?.result?.result?.plan;
status = tenatRes.data?.result?.result?.isSubscribed;
} else {
plan = tenatRes.data?.result?.result?.PlanCode;
billingDate = tenatRes.data?.result?.result?.Next_billing_date?.iso;
}
return { plan, billingDate, status };
} catch (err) {
console.log("Err in fetch subscription", err);
return { plan: "", billingDate: "" };
Expand Down Expand Up @@ -528,7 +537,8 @@ export const signPdfFun = async (
signerObjectId,
setIsAlert,
objectId,
isSubscribed
isSubscribed,
activeMailAdapter
) => {
let singleSign,
isCustomCompletionMail = false;
Expand All @@ -548,6 +558,7 @@ export const signPdfFun = async (
}

singleSign = {
mailProvider: activeMailAdapter,
pdfFile: base64Url,
docId: documentId,
userId: signerObjectId,
Expand Down
48 changes: 39 additions & 9 deletions apps/OpenSign/src/pages/PdfRequestFiles.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ import {
radioButtonWidget,
replaceMailVaribles,
fetchSubscription,
convertPdfArrayBuffer
convertPdfArrayBuffer,
contractUsers
} from "../constant/Utils";
import Loader from "../primitives/LoaderWithMsg";
import HandleError from "../primitives/HandleError";
Expand Down Expand Up @@ -138,10 +139,12 @@ function PdfRequestFiles() {
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [divRef.current]);

async function checkIsSubscribed(extUserId) {
const res = await fetchSubscription(extUserId);
async function checkIsSubscribed(extUserId, contactId) {
const isGuestSign = localStorage.getItem("isGuestSigner");
const res = await fetchSubscription(extUserId, contactId);
const plan = res.plan;
const billingDate = res.billingDate;
const billingDate = res?.billingDate;
const status = res?.status;
if (plan === "freeplan") {
return true;
} else if (billingDate) {
Expand All @@ -155,8 +158,15 @@ function PdfRequestFiles() {
navigate(`/subscription`);
}
}
} else if (isGuestSign) {
if (status) {
setIsSubscribed(true);
return true;
} else {
setIsSubscriptionExpired(true);
}
} else {
if (location.pathname.includes("/load/")) {
if (isGuestSign) {
setIsSubscriptionExpired(true);
} else {
navigate(`/subscription`);
Expand All @@ -178,9 +188,7 @@ function PdfRequestFiles() {
} else {
setPdfArrayBuffer(arrayBuffer);
}
if (isEnableSubscription) {
await checkIsSubscribed(documentData[0]?.ExtUserPtr?.objectId);
}

setExtUserId(documentData[0]?.ExtUserPtr?.objectId);
const isCompleted =
documentData[0].IsCompleted && documentData[0].IsCompleted;
Expand All @@ -196,6 +204,12 @@ function PdfRequestFiles() {
);

currUserId = getCurrentSigner[0] ? getCurrentSigner[0].objectId : "";
if (isEnableSubscription) {
await checkIsSubscribed(
documentData[0]?.ExtUserPtr?.objectId,
currUserId
);
}
setSignerObjectId(currUserId);
if (documentData[0].SignedUrl) {
setPdfUrl(documentData[0].SignedUrl);
Expand Down Expand Up @@ -577,6 +591,20 @@ function PdfRequestFiles() {
);
//get ExistUserPtr object id of user class to get tenantDetails
const objectId = pdfDetails?.[0]?.ExtUserPtr?.UserId?.objectId;

const res = await contractUsers(jsonSender?.email);
console.log("res", res);
let activeMailAdapter = "";
if (res === "Error: Something went wrong!") {
setHandleError("Error: Something went wrong!");
setIsLoading({
isLoad: false
});
} else if (!res || res?.length === 0) {
activeMailAdapter = "";
} else if (res[0] && res.length) {
activeMailAdapter = res[0]?.active_mail_adapter;
}
//function for call to embed signature in pdf and get digital signature pdf
try {
const res = await signPdfFun(
Expand All @@ -585,7 +613,8 @@ function PdfRequestFiles() {
signerObjectId,
setIsAlert,
objectId,
isSubscribed
isSubscribed,
activeMailAdapter
);
if (res && res.status === "success") {
setPdfUrl(res.data);
Expand Down Expand Up @@ -677,6 +706,7 @@ function PdfRequestFiles() {
}

let params = {
mailProvider: activeMailAdapter,
extUserId: extUserId,
recipient: user.Email,
subject: requestSubject
Expand Down
17 changes: 10 additions & 7 deletions apps/OpenSign/src/pages/PlaceHolderSign.js
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ function PlaceHolderSign() {
const [requestSubject, setRequestSubject] = useState("");
const [requestBody, setRequestBody] = useState("");
const [pdfArrayBuffer, setPdfArrayBuffer] = useState("");
const [activeMailAdapter, setActiveMailAdapter] = useState("");
const [isAlreadyPlace, setIsAlreadyPlace] = useState({
status: false,
message: ""
Expand Down Expand Up @@ -406,7 +407,14 @@ function PlaceHolderSign() {
setIsLoading(loadObj);
}
const res = await contractUsers(jsonSender.email);
if (res[0] && res.length) {
if (res === "Error: Something went wrong!") {
const loadObj = {
isLoad: false
};
setHandleError("Error: Something went wrong!");
setIsLoading(loadObj);
} else if (res[0] && res.length) {
setActiveMailAdapter(res[0]?.active_mail_adapter);
setSignerUserId(res[0].objectId);
const tourstatus = res[0].TourStatus && res[0].TourStatus;
if (tourstatus && tourstatus.length > 0) {
Expand All @@ -422,12 +430,6 @@ function PlaceHolderSign() {
isLoad: false
};
setIsLoading(loadObj);
} else if (res === "Error: Something went wrong!") {
const loadObj = {
isLoad: false
};
setHandleError("Error: Something went wrong!");
setIsLoading(loadObj);
} else if (res.length === 0) {
setHandleError("No Data Found!");
const loadObj = {
Expand Down Expand Up @@ -1104,6 +1106,7 @@ function PlaceHolderSign() {
}

let params = {
mailProvider: activeMailAdapter,
extUserId: extUserId,
recipient: signerMail[i].Email,
subject: isCustomize
Expand Down
20 changes: 12 additions & 8 deletions apps/OpenSign/src/pages/SignyourselfPdf.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ function SignYourSelf() {
const [extUserId, setExtUserId] = useState("");
const [isCompleted, setIsCompleted] = useState(false);
const [pdfArrayBuffer, setPdfArrayBuffer] = useState("");
const [activeMailAdapter, setActiveMailAdapter] = useState("");
const divRef = useRef(null);
const nodeRef = useRef(null);
const [, drop] = useDrop({
Expand Down Expand Up @@ -266,7 +267,14 @@ function SignYourSelf() {
setIsLoading(loadObj);
});
const contractUsersRes = await contractUsers(jsonSender.email);
if (contractUsersRes[0] && contractUsersRes.length > 0) {
if (contractUsersRes === "Error: Something went wrong!") {
const loadObj = {
isLoad: false
};
setHandleError("Error: Something went wrong!");
setIsLoading(loadObj);
} else if (contractUsersRes[0] && contractUsersRes.length > 0) {
setActiveMailAdapter(contractUsersRes[0]?.active_mail_adapter);
setContractName("_Users");
setSignerUserId(contractUsersRes[0].objectId);
const tourstatuss =
Expand All @@ -286,12 +294,6 @@ function SignYourSelf() {
isLoad: false
};
setIsLoading(loadObj);
} else if (contractUsersRes === "Error: Something went wrong!") {
const loadObj = {
isLoad: false
};
setHandleError("Error: Something went wrong!");
setIsLoading(loadObj);
} else if (contractUsersRes.length === 0) {
const contractContactBook = await contactBook(jsonSender.objectId);
if (contractContactBook && contractContactBook.length > 0) {
Expand Down Expand Up @@ -615,7 +617,8 @@ function SignYourSelf() {
let singleSign = {
pdfFile: base64Url,
docId: documentId,
isCustomCompletionMail: isCustomCompletionMail
isCustomCompletionMail: isCustomCompletionMail,
mailProvider: activeMailAdapter
};

await axios
Expand Down Expand Up @@ -1138,6 +1141,7 @@ function SignYourSelf() {
sender={jsonSender}
setIsAlert={setIsAlert}
extUserId={extUserId}
activeMailAdapter={activeMailAdapter}
/>
{/* pdf header which contain funish back button */}
<Header
Expand Down
Loading