mirror of
https://github.com/OpenSignLabs/OpenSign.git
synced 2026-08-24 16:42:33 +02:00
fix: check subscription details issue in guest login flow
This commit is contained in:
@@ -13,10 +13,16 @@ export const openInNewTab = (url) => {
|
||||
window.open(url, "_blank", "noopener,noreferrer");
|
||||
};
|
||||
|
||||
export async function fetchSubscription() {
|
||||
export async function fetchSubscription(extUserId) {
|
||||
try {
|
||||
const extClass = localStorage.getItem("Extand_Class");
|
||||
const jsonSender = JSON.parse(extClass);
|
||||
let extUser;
|
||||
if (extClass) {
|
||||
const jsonSender = JSON.parse(extClass);
|
||||
extUser = jsonSender[0].objectId;
|
||||
} else {
|
||||
extUser = extUserId;
|
||||
}
|
||||
const baseURL = localStorage.getItem("baseUrl");
|
||||
const url = `${baseURL}functions/getsubscriptions`;
|
||||
const headers = {
|
||||
@@ -24,7 +30,7 @@ export async function fetchSubscription() {
|
||||
"X-Parse-Application-Id": localStorage.getItem("parseAppId"),
|
||||
sessionToken: localStorage.getItem("accesstoken")
|
||||
};
|
||||
const params = { extUserId: jsonSender[0].objectId };
|
||||
const params = { 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;
|
||||
|
||||
@@ -138,8 +138,8 @@ function PdfRequestFiles() {
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
}, [divRef.current]);
|
||||
|
||||
async function checkIsSubscribed() {
|
||||
const res = await fetchSubscription();
|
||||
async function checkIsSubscribed(extUserId) {
|
||||
const res = await fetchSubscription(extUserId);
|
||||
const plan = res.plan;
|
||||
const billingDate = res.billingDate;
|
||||
if (plan === "freeplan") {
|
||||
@@ -169,7 +169,8 @@ function PdfRequestFiles() {
|
||||
//getting document details
|
||||
const documentData = await contractDocument(documentId);
|
||||
if (documentData && documentData.length > 0) {
|
||||
const url = documentData[0] && documentData[0]?.URL;
|
||||
const url =
|
||||
documentData[0] && (documentData[0]?.SignedUrl || documentData[0]?.URL);
|
||||
//convert document url in array buffer format to use embed widgets in pdf using pdf-lib
|
||||
const arrayBuffer = await convertPdfArrayBuffer(url);
|
||||
if (arrayBuffer === "Error") {
|
||||
@@ -178,7 +179,7 @@ function PdfRequestFiles() {
|
||||
setPdfArrayBuffer(arrayBuffer);
|
||||
}
|
||||
if (isEnableSubscription) {
|
||||
await checkIsSubscribed(documentData[0]?.ExtUserPtr?.Email);
|
||||
await checkIsSubscribed(documentData[0]?.ExtUserPtr?.objectId);
|
||||
}
|
||||
setExtUserId(documentData[0]?.ExtUserPtr?.objectId);
|
||||
const isCompleted =
|
||||
|
||||
Reference in New Issue
Block a user