Skip to content

Commit 3fc41f4

Browse files
feat : implement credit deduction in the public signature process
1 parent b20aa33 commit 3fc41f4

File tree

7 files changed

+256
-158
lines changed

7 files changed

+256
-158
lines changed

apps/OpenSign/public/locales/en/translation.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -647,6 +647,7 @@
647647
"copied-code":"COPIED",
648648
"Installation":"Installation",
649649
"Usage" :"Usage",
650-
"unauthorized-modal":"You don't have permission to perform this action, please contact {{adminName}}<{{adminEmail}}>."
651-
650+
"unauthorized-modal":"You don't have permission to perform this action, please contact {{adminName}}<{{adminEmail}}>.",
651+
"insufficient-credits":"Insufficient Signing Credits",
652+
"insufficient-credits-mssg":"The owner of this document currently lacks the necessary OpenSign credits for you to sign. Please reach out to the owner if you require further details."
652653
}

apps/OpenSign/public/locales/fr/translation.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -647,6 +647,7 @@
647647
"copied-code":"COPIÉ",
648648
"Installation":"Installation",
649649
"Usage" :"Usage",
650-
"unauthorized-modal":"Vous n'êtes pas autorisé à effectuer cette action, veuillez contacter {{adminName}}<{{adminEmail}}>."
651-
650+
"unauthorized-modal":"Vous n'êtes pas autorisé à effectuer cette action, veuillez contacter {{adminName}}<{{adminEmail}}>.",
651+
"insufficient-credits":"Crédits de signature insuffisants",
652+
"insufficient-credits-mssg" :"Le propriétaire de ce document ne dispose actuellement pas des crédits OpenSign nécessaires pour que vous puissiez le signer. Veuillez contacter le propriétaire si vous avez besoin de plus de détails."
652653
}

apps/OpenSign/src/constant/Utils.js

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,14 +33,15 @@ export const openInNewTab = (url, target) => {
3333
export async function fetchSubscription(
3434
extUserId,
3535
contactObjId,
36-
isGuestSign = false
36+
isGuestSign = false,
37+
isPublic = false
3738
) {
3839
try {
3940
const Extand_Class = localStorage.getItem("Extand_Class");
4041
const extClass = Extand_Class && JSON.parse(Extand_Class);
4142
// console.log("extClass ", extClass);
4243
let extUser;
43-
if (extClass && extClass.length > 0) {
44+
if (extClass && extClass.length > 0 && !isPublic) {
4445
extUser = extClass[0].objectId;
4546
} else {
4647
extUser = extUserId;
@@ -54,8 +55,10 @@ export async function fetchSubscription(
5455
};
5556
const params = isGuestSign
5657
? { contactId: contactObjId }
57-
: { extUserId: extUser };
58+
: { extUserId: extUser, ispublic: isPublic };
59+
console.log("params", params);
5860
const tenatRes = await axios.post(url, params, { headers: headers });
61+
console.log("tenantRes", tenatRes);
5962
let plan, status, billingDate, adminId;
6063
if (isGuestSign) {
6164
plan = tenatRes.data?.result?.result?.plan;

apps/OpenSign/src/pages/PdfRequestFiles.js

Lines changed: 73 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,13 @@ function PdfRequestFiles(props) {
243243
};
244244
async function checkIsSubscribed(extUserId, contactId) {
245245
const isGuestSign = isGuestSignFlow || false;
246-
const res = await fetchSubscription(extUserId, contactId, isGuestSign);
246+
const isPublic = props.templateId ? true : false;
247+
const res = await fetchSubscription(
248+
extUserId,
249+
contactId,
250+
isGuestSign,
251+
isPublic
252+
);
247253
const plan = res.plan;
248254
const billingDate = res?.billingDate;
249255
const status = res?.status;
@@ -296,14 +302,16 @@ function PdfRequestFiles(props) {
296302
? [templateDeatils.data.result]
297303
: [];
298304
if (documentData && documentData[0]?.error) {
299-
props?.setTemplateStatus({
300-
status: "Invalid"
301-
});
302-
} else if (documentData && documentData.length > 0) {
303-
if (documentData[0]?.IsPublic) {
305+
props?.setTemplateStatus &&
304306
props?.setTemplateStatus({
305-
status: "Success"
307+
status: "Invalid"
306308
});
309+
} else if (documentData && documentData.length > 0) {
310+
if (documentData[0]?.IsPublic) {
311+
props?.setTemplateStatus &&
312+
props?.setTemplateStatus({
313+
status: "Success"
314+
});
307315
const url =
308316
documentData[0] &&
309317
(documentData[0]?.SignedUrl || documentData[0]?.URL);
@@ -347,14 +355,16 @@ function PdfRequestFiles(props) {
347355
isLoad: false
348356
});
349357
} else {
350-
props?.setTemplateStatus({
351-
status: "Private"
352-
});
358+
props?.setTemplateStatus &&
359+
props?.setTemplateStatus({
360+
status: "Private"
361+
});
353362
}
354363
} else {
355-
props?.setTemplateStatus({
356-
status: "Invalid"
357-
});
364+
props?.setTemplateStatus &&
365+
props?.setTemplateStatus({
366+
status: "Invalid"
367+
});
358368
}
359369
} catch (err) {
360370
console.log("err in get template details ", err);
@@ -1286,7 +1296,11 @@ function PdfRequestFiles(props) {
12861296
.catch((err) => {
12871297
console.log("error updating field is decline ", err);
12881298
setIsUiLoading(false);
1289-
alert(t("something-went-wrong-mssg"));
1299+
setIsAlert({
1300+
title: "Error",
1301+
isShow: true,
1302+
alertMessage: t("something-went-wrong-mssg")
1303+
});
12901304
});
12911305
};
12921306
//function to add default signature for all requested placeholder of sign
@@ -1467,11 +1481,32 @@ function PdfRequestFiles(props) {
14671481
await SendOtp();
14681482
} else {
14691483
console.log("error in public-sign to create user details");
1470-
alert(t("something-went-wrong-mssg"));
1484+
setIsAlert({
1485+
title: "Error",
1486+
isShow: true,
1487+
alertMessage: t("something-went-wrong-mssg")
1488+
});
14711489
}
14721490
} catch (e) {
14731491
console.log("e", e);
1474-
// setIsLoader(false);
1492+
if (
1493+
e?.response?.data?.error === "Insufficient Credit" ||
1494+
e?.response?.data?.error === "Plan expired"
1495+
) {
1496+
handleCloseOtp();
1497+
setIsAlert({
1498+
title: t("insufficient-credits"),
1499+
isShow: true,
1500+
alertMessage: t("insufficient-credits-mssg")
1501+
});
1502+
} else {
1503+
handleCloseOtp();
1504+
setIsAlert({
1505+
title: "Error",
1506+
isShow: true,
1507+
alertMessage: t("something-went-wrong-mssg")
1508+
});
1509+
}
14751510
}
14761511
};
14771512

@@ -1503,7 +1538,11 @@ function PdfRequestFiles(props) {
15031538
}
15041539
} catch (error) {
15051540
console.log("error in verify otp in public-sign", error);
1506-
alert(t("something-went-wrong-mssg"));
1541+
setIsAlert({
1542+
title: "Error",
1543+
isShow: true,
1544+
alertMessage: t("something-went-wrong-mssg")
1545+
});
15071546
}
15081547
};
15091548

@@ -1602,6 +1641,7 @@ function PdfRequestFiles(props) {
16021641
</div>
16031642
);
16041643
};
1644+
console.log("templateId", props.templateId);
16051645
return (
16061646
<DndProvider backend={HTML5Backend}>
16071647
<Title title={props.templateId ? "Public Sign" : "Request Sign"} />
@@ -1656,27 +1696,6 @@ function PdfRequestFiles(props) {
16561696
{!requestSignTour &&
16571697
signerObjectId &&
16581698
requestSignTourFunction()}
1659-
<ModalUi
1660-
isOpen={isAlert.isShow}
1661-
title={t("alert-message")}
1662-
handleClose={() =>
1663-
setIsAlert({ isShow: false, alertMessage: "" })
1664-
}
1665-
>
1666-
<div className="h-full p-[20px]">
1667-
<p>{isAlert.alertMessage}</p>
1668-
<button
1669-
onClick={() =>
1670-
setIsAlert({ isShow: false, alertMessage: "" })
1671-
}
1672-
type="button"
1673-
className="op-btn op-btn-primary mt-3 px-4"
1674-
>
1675-
{t("ok")}
1676-
</button>
1677-
</div>
1678-
</ModalUi>
1679-
16801699
<Tour
16811700
showNumber={false}
16821701
showNavigation={false}
@@ -2184,6 +2203,22 @@ function PdfRequestFiles(props) {
21842203
</button>
21852204
</div>
21862205
</ModalUi>
2206+
<ModalUi
2207+
isOpen={isAlert.isShow}
2208+
title={isAlert?.title || t("alert-message")}
2209+
handleClose={() => setIsAlert({ isShow: false, alertMessage: "" })}
2210+
>
2211+
<div className="h-full p-[20px]">
2212+
<p>{isAlert.alertMessage}</p>
2213+
<button
2214+
onClick={() => setIsAlert({ isShow: false, alertMessage: "" })}
2215+
type="button"
2216+
className="op-btn op-btn-primary mt-3 px-4"
2217+
>
2218+
{t("close")}
2219+
</button>
2220+
</div>
2221+
</ModalUi>
21872222
</>
21882223
)}
21892224
</DndProvider>

apps/OpenSign/src/script/locales/en/translation.json

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
"upgrade-now": "Upgrade now",
4242
"upgrade-to": "Upgrade to",
4343
"plan": "Plan",
44-
"subscribe-card-teamplan":"Unlock the full power of collaboration! Create unlimited organizations, teams, and hierarchies. Share templates seamlessly across teams and assign custom user roles. Elevate your workflow today!",
44+
"subscribe-card-teamplan": "Unlock the full power of collaboration! Create unlimited organizations, teams, and hierarchies. Share templates seamlessly across teams and assign custom user roles. Elevate your workflow today!",
4545
"subscribe-card-plan": "Unlock premium features starting at just {{premiumPrice}}/month. Enjoy enhanced performance and only {{addonPrice}} per additional credit after your included premium credits.",
4646
"user-name-limit-char": "To have a username less than 8 character please subscribe",
4747
"tour-content": "Don't show this again",
@@ -614,24 +614,25 @@
614614
"select-date-format": "Select a date format",
615615
"quantityofcredits": "Quantity of premium credits",
616616
"remainingcredits": "Premium credits available:",
617-
"remainingcreditshelp":"Use premium credits for API document signing, bulk sending, or embedding OpenSign integration on your website. You have {{allowedcredits}} included credits and {{addoncredits}} additional purchased credits remaining.",
617+
"remainingcreditshelp": "Use premium credits for API document signing, bulk sending, or embedding OpenSign integration on your website. You have {{allowedcredits}} included credits and {{addoncredits}} additional purchased credits remaining.",
618618
"additional-credits": "Please purchase premium credits",
619619
"quotaerrquicksend": "Quota Reached, You don't have enough credits.",
620620
"buycredits": "Buy Premium Credits",
621-
"rotate-right":"Rotate right",
622-
"rotate-left":"Rotate left",
623-
"rotate-alert-mssg":"All widgets on this page will be lost. Are you sure you want to proceed?",
624-
"templateid":"Template-Id",
625-
"bulksendsubcriptionalert":"Please upgrade to Professional or Team plan to use bulk send.",
626-
"generate-test-token":"Generate Test Token",
627-
"regenerate-test-token":"Regenerate Test Token",
628-
"help-test-token":"This token can be used to test the APIs at the https://sandbox.opensignlabs.com/api/v1 endpoint, allowing you to conduct unlimited document signatures. Please note that the sandbox API will sign your documents with self-signed certificates, which may not be recognized as valid by Adobe. Once you’ve completed your testing, you can upgrade to one of our paid plans to generate a production token.",
629-
"help-api-token":"This token can be used to access the production APIs at the {{origin}}/api/v1 endpoint. It can only be generated on one of our paid plans.",
630-
"Add-Webhook":"Add Webhook",
621+
"rotate-right": "Rotate right",
622+
"rotate-left": "Rotate left",
623+
"rotate-alert-mssg": "All widgets on this page will be lost. Are you sure you want to proceed?",
624+
"templateid": "Template-Id",
625+
"bulksendsubcriptionalert": "Please upgrade to Professional or Team plan to use bulk send.",
626+
"generate-test-token": "Generate Test Token",
627+
"regenerate-test-token": "Regenerate Test Token",
628+
"help-test-token": "This token can be used to test the APIs at the https://sandbox.opensignlabs.com/api/v1 endpoint, allowing you to conduct unlimited document signatures. Please note that the sandbox API will sign your documents with self-signed certificates, which may not be recognized as valid by Adobe. Once you’ve completed your testing, you can upgrade to one of our paid plans to generate a production token.",
629+
"help-api-token": "This token can be used to access the production APIs at the {{origin}}/api/v1 endpoint. It can only be generated on one of our paid plans.",
630+
"Add-Webhook": "Add Webhook",
631631
"quotamailinfo": "You can send upto 15 signature request emails every month. Upgrade now to send unlimited signing requests directly.",
632632
"quotamail": "You've reached your limit of 15 signature request emails for this month. Upgrade now to continue sending emails directly.",
633-
"quotamailTip":"Tip: You can still sign unlimited documents by manually sharing the signing request links.",
634-
"quotamailhead":"Quota Reached",
635-
"unauthorized-modal":"You don't have permission to perform this action, please contact {{adminName}}<{{adminEmail}}>."
636-
633+
"quotamailTip": "Tip: You can still sign unlimited documents by manually sharing the signing request links.",
634+
"quotamailhead": "Quota Reached",
635+
"unauthorized-modal": "You don't have permission to perform this action, please contact {{adminName}}<{{adminEmail}}>.",
636+
"insufficient-credits": "Insufficient Signing Credits",
637+
"insufficient-credits-mssg":"The owner of this document currently lacks the necessary OpenSign credits for you to sign. Please reach out to the owner if you require further details."
637638
}

apps/OpenSign/src/script/locales/fr/translation.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -632,6 +632,7 @@
632632
"quotamail": "Vous avez atteint votre limite de 15 e-mails de demande de signature pour ce mois. Mettez à niveau maintenant pour continuer à envoyer des e-mails directement.",
633633
"quotamailTip":"Astuce : Vous pouvez toujours signer un nombre illimité de documents en partageant manuellement les liens de demande de signature.",
634634
"quotamailhead":"Quota atteint",
635-
"unauthorized-modal":"Vous n'êtes pas autorisé à effectuer cette action, veuillez contacter {{adminName}}<{{adminEmail}}>."
636-
635+
"unauthorized-modal":"Vous n'êtes pas autorisé à effectuer cette action, veuillez contacter {{adminName}}<{{adminEmail}}>.",
636+
"insufficient-credits":"Crédits de signature insuffisants",
637+
"insufficient-credits-mssg" :"Le propriétaire de ce document ne dispose actuellement pas des crédits OpenSign nécessaires pour que vous puissiez le signer. Veuillez contacter le propriétaire si vous avez besoin de plus de détails."
637638
}

0 commit comments

Comments
 (0)