Skip to content

Commit fc564ca

Browse files
fix: check subscription details issue in guest login flow
1 parent 37b2e4c commit fc564ca

File tree

2 files changed

+14
-7
lines changed

2 files changed

+14
-7
lines changed

apps/OpenSign/src/constant/Utils.js

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,18 +13,24 @@ export const openInNewTab = (url) => {
1313
window.open(url, "_blank", "noopener,noreferrer");
1414
};
1515

16-
export async function fetchSubscription() {
16+
export async function fetchSubscription(extUserId) {
1717
try {
1818
const extClass = localStorage.getItem("Extand_Class");
19-
const jsonSender = JSON.parse(extClass);
19+
let extUser;
20+
if (extClass) {
21+
const jsonSender = JSON.parse(extClass);
22+
extUser = jsonSender[0].objectId;
23+
} else {
24+
extUser = extUserId;
25+
}
2026
const baseURL = localStorage.getItem("baseUrl");
2127
const url = `${baseURL}functions/getsubscriptions`;
2228
const headers = {
2329
"Content-Type": "application/json",
2430
"X-Parse-Application-Id": localStorage.getItem("parseAppId"),
2531
sessionToken: localStorage.getItem("accesstoken")
2632
};
27-
const params = { extUserId: jsonSender[0].objectId };
33+
const params = { extUserId: extUser };
2834
const tenatRes = await axios.post(url, params, { headers: headers });
2935
const plan = tenatRes.data?.result?.result?.PlanCode;
3036
const billingDate = tenatRes.data?.result?.result?.Next_billing_date?.iso;

apps/OpenSign/src/pages/PdfRequestFiles.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -138,8 +138,8 @@ function PdfRequestFiles() {
138138
// eslint-disable-next-line react-hooks/exhaustive-deps
139139
}, [divRef.current]);
140140

141-
async function checkIsSubscribed() {
142-
const res = await fetchSubscription();
141+
async function checkIsSubscribed(extUserId) {
142+
const res = await fetchSubscription(extUserId);
143143
const plan = res.plan;
144144
const billingDate = res.billingDate;
145145
if (plan === "freeplan") {
@@ -169,7 +169,8 @@ function PdfRequestFiles() {
169169
//getting document details
170170
const documentData = await contractDocument(documentId);
171171
if (documentData && documentData.length > 0) {
172-
const url = documentData[0] && documentData[0]?.URL;
172+
const url =
173+
documentData[0] && (documentData[0]?.SignedUrl || documentData[0]?.URL);
173174
//convert document url in array buffer format to use embed widgets in pdf using pdf-lib
174175
const arrayBuffer = await convertPdfArrayBuffer(url);
175176
if (arrayBuffer === "Error") {
@@ -178,7 +179,7 @@ function PdfRequestFiles() {
178179
setPdfArrayBuffer(arrayBuffer);
179180
}
180181
if (isEnableSubscription) {
181-
await checkIsSubscribed(documentData[0]?.ExtUserPtr?.Email);
182+
await checkIsSubscribed(documentData[0]?.ExtUserPtr?.objectId);
182183
}
183184
setExtUserId(documentData[0]?.ExtUserPtr?.objectId);
184185
const isCompleted =

0 commit comments

Comments
 (0)