Skip to content

Commit

Permalink
Merge pull request #1152 from OpenSignLabs/validation
Browse files Browse the repository at this point in the history
fix: failed to load pdf issue on self-host with docker
  • Loading branch information
andrew-opensignlabs authored Sep 2, 2024
2 parents cb5bcd7 + a765668 commit d6f117c
Show file tree
Hide file tree
Showing 13 changed files with 273 additions and 141 deletions.
8 changes: 7 additions & 1 deletion apps/OpenSign/public/locales/en/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -623,5 +623,11 @@
"generate-test-token":"Generate Test Token",
"regenerate-test-token":"Regenerate Test Token",
"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.",
"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."
"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.",
"Add-Webhook":"Add Webhook",
"quotamailselfsign": "You've reached your limit of 20 emails for this month. Upgrade now to continue sending emails directly.",
"quotamail": "You've reached your limit of 20 signature request emails for this month. Upgrade now to continue sending emails directly.",
"quotamailTip":"Tip: You can still sign unlimited documents by manually sharing the signing request links below.",
"quotamailhead":"Quota Reached"

}
8 changes: 7 additions & 1 deletion apps/OpenSign/public/locales/fr/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -624,5 +624,11 @@
"generate-test-token": "Générer jeton de test",
"regenerate-test-token":"Régénérer le jeton de test",
"help-test-token":"Ce jeton peut être utilisé pour tester les API au niveau du point de terminaison https://sandbox.opensignlabs.com/api/v1, vous permettant ainsi d'effectuer un nombre illimité de signatures de documents. Veuillez noter que l'API sandbox signera vos documents avec des certificats auto-signés, qui peuvent ne pas être reconnus comme valides par Adobe. Une fois vos tests terminés, vous pouvez passer à l’un de nos forfaits payants pour générer un jeton de production.",
"help-api-token":"Ce jeton peut être utilisé pour accéder aux API de production au point de terminaison {{origin}}/api/v1. Il ne peut être généré que sur l'un de nos forfaits payants."
"help-api-token":"Ce jeton peut être utilisé pour accéder aux API de production au point de terminaison {{origin}}/api/v1. Il ne peut être généré que sur l'un de nos forfaits payants.",
"Add-Webhook":"Ajouter Webhook",
"quotamailselfsign": "Vous avez atteint votre limite de 20 e-mails pour ce mois. Mettez à niveau maintenant pour continuer à envoyer des e-mails directement.",
"quotamail": "Vous avez atteint votre limite de 20 e-mails de demande de signature pour ce mois. Mettez à niveau maintenant pour continuer à envoyer des e-mails directement.",
"quotamailTip":"Astuce : Vous pouvez toujours signer un nombre illimité de documents en partageant manuellement les liens de demande de signature ci-dessous.",
"quotamailhead":"Quota atteint"

}
19 changes: 8 additions & 11 deletions apps/OpenSign/src/components/pdf/EmailComponent.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ function EmailComponent({
sender,
setIsAlert,
extUserId,
activeMailAdapter
activeMailAdapter,
planCode
}) {
const { t } = useTranslation();
const [emailList, setEmailList] = useState([]);
Expand All @@ -34,7 +35,7 @@ function EmailComponent({
const imgPng =
"https://qikinnovation.ams3.digitaloceanspaces.com/logo.png";

let url = `${localStorage.getItem("baseUrl")}functions/sendmailv3/`;
let url = `${localStorage.getItem("baseUrl")}functions/sendmailv3`;
const headers = {
"Content-Type": "application/json",
"X-Parse-Application-Id": localStorage.getItem("parseAppId"),
Expand All @@ -50,6 +51,7 @@ function EmailComponent({
recipient: emailList[i],
subject: `${sender.name} has signed the doc - ${pdfName}`,
from: sender.email,
plan: planCode,
html:
"<html><head><meta http-equiv='Content-Type' content='text/html; charset=UTF-8' /></head><body> <div style='background-color:#f5f5f5;padding:20px'> <div style='box-shadow: rgba(0, 0, 0, 0.1) 0px 4px 12px;background-color:white;'> <div><img src=" +
imgPng +
Expand All @@ -74,24 +76,19 @@ function EmailComponent({
});
}
}

if (sendMail && sendMail.data.result.status === "success") {
if (sendMail?.data?.result?.status === "success") {
setSuccessEmail(true);
setIsEmail(false);
setTimeout(() => {
setSuccessEmail(false);
setIsEmail(false);
setEmailValue("");
setEmailList([]);
}, 1500);

setIsLoading(false);
} else if (sendMail && sendMail.data.result.status === "error") {
} else if (sendMail?.data?.result?.status === "quota-reached") {
setIsLoading(false);
setIsEmail(false);
setIsAlert({
isShow: true,
alertMessage: t("something-went-wrong-mssg")
});
setIsAlert({ isShow: true, alertMessage: "quotareached" });
setEmailValue("");
setEmailList([]);
} else {
Expand Down
3 changes: 3 additions & 0 deletions apps/OpenSign/src/pages/PdfRequestFiles.js
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@ function PdfRequestFiles(props) {
const [documentId, setDocumentId] = useState("");
const [isPublicContact, setIsPublicContact] = useState(false);
const [pdfArrayBuffer, setPdfArrayBuffer] = useState("");
const [plancode, setPlanCode] = useState("");
const isHeader = useSelector((state) => state.showHeader);
const divRef = useRef(null);

Expand Down Expand Up @@ -246,6 +247,7 @@ function PdfRequestFiles(props) {
const plan = res.plan;
const billingDate = res?.billingDate;
const status = res?.status;
setPlanCode(plan);
if (plan === "freeplan") {
return true;
} else if (billingDate) {
Expand Down Expand Up @@ -986,6 +988,7 @@ function PdfRequestFiles(props) {
? replaceVar?.subject
: `${pdfDetails?.[0].ExtUserPtr.Name} has requested you to sign "${pdfDetails?.[0].Name}"`,
from: senderEmail,
plan: plancode,
html: requestBody
? replaceVar?.body
: "<html><head><meta http-equiv='Content-Type' content='text/html; charset=UTF-8' /> </head> <body> <div style='background-color: #f5f5f5; padding: 20px'=> <div style=' box-shadow: rgba(0, 0, 0, 0.1) 0px 4px 12px;background: white;padding-bottom: 20px;'> <div style='padding:10px 10px 0 10px'><img src=" +
Expand Down
103 changes: 61 additions & 42 deletions apps/OpenSign/src/pages/PlaceHolderSign.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ import PdfZoom from "../components/pdf/PdfZoom";
import LottieWithLoader from "../primitives/DotLottieReact";
import { useTranslation } from "react-i18next";
import RotateAlert from "../components/RotateAlert";
import QuotaCard from "../primitives/QuotaCard";

function PlaceHolderSign() {
const { t } = useTranslation();
Expand Down Expand Up @@ -150,8 +151,8 @@ function PlaceHolderSign() {
const [isCustomize, setIsCustomize] = useState(false);
const [zoomPercent, setZoomPercent] = useState(0);
const [scale, setScale] = useState(1);

const [pdfRotateBase64, setPdfRotatese64] = useState("");
const [planCode, setPlanCode] = useState("");
const isMobile = window.innerWidth < 767;
const [, drop] = useDrop({
accept: "BOX",
Expand Down Expand Up @@ -240,6 +241,7 @@ function PlaceHolderSign() {
const res = await fetchSubscription();
const plan = res.plan;
const billingDate = res.billingDate;
setPlanCode(plan);
if (plan === "freeplan") {
return true;
} else if (billingDate) {
Expand Down Expand Up @@ -1058,7 +1060,7 @@ function PlaceHolderSign() {
try {
const imgPng =
"https://qikinnovation.ams3.digitaloceanspaces.com/logo.png";
let url = `${localStorage.getItem("baseUrl")}functions/sendmailv3/`;
let url = `${localStorage.getItem("baseUrl")}functions/sendmailv3`;
const headers = {
"Content-Type": "application/json",
"X-Parse-Application-Id": localStorage.getItem("parseAppId"),
Expand Down Expand Up @@ -1113,6 +1115,7 @@ function PlaceHolderSign() {
? replaceVar?.subject
: `${senderName} has requested you to sign "${documentName}"`,
from: senderEmail,
plan: planCode,
html: isCustomize
? replaceVar?.body
: "<html><head><meta http-equiv='Content-Type' content='text/html; charset=UTF-8' /> </head> <body> <div style='background-color: #f5f5f5; padding: 20px'=> <div style=' box-shadow: rgba(0, 0, 0, 0.1) 0px 4px 12px;background: white;padding-bottom: 20px;'> <div style='padding:10px 10px 0 10px'><img src=" +
Expand Down Expand Up @@ -1143,7 +1146,7 @@ function PlaceHolderSign() {
console.log("error", error);
}
}
if (sendMail.data.result.status === "success") {
if (sendMail?.data?.result?.status === "success") {
setMailStatus("success");
try {
let data;
Expand All @@ -1156,9 +1159,8 @@ function PlaceHolderSign() {
} else {
data = { SendMail: true };
}

await axios
.put(
try {
await axios.put(
`${localStorage.getItem(
"baseUrl"
)}classes/contracts_Document/${documentId}`,
Expand All @@ -1170,21 +1172,21 @@ function PlaceHolderSign() {
"X-Parse-Session-Token": localStorage.getItem("accesstoken")
}
}
)
.then(() => {})
.catch((err) => {
console.log("axois err ", err);
});
);
} catch (err) {
console.log("axois err ", err);
}
} catch (e) {
console.log("error", e);
}

setIsSend(true);
setIsMailSend(true);
const loadObj = {
isLoad: false
};
setIsLoading(loadObj);
setIsLoading({ isLoad: false });
setIsUiLoading(false);
} else if (sendMail?.data?.result?.status === "quota-reached") {
setMailStatus("quotareached");
setIsSend(true);
setIsMailSend(true);
setIsUiLoading(false);
} else {
setMailStatus("failed");
Expand Down Expand Up @@ -1829,7 +1831,7 @@ function PlaceHolderSign() {
<span className="ml-[5px] mr-[5px]">{t("or")}</span>
<span className="h-[1px] w-[20%] bg-[#ccc]"></span>
</div>
<div className="mt-3 mb-3">{handleShareList()}</div>
<div className="my-3">{handleShareList()}</div>
</>
)}
</div>
Expand All @@ -1838,7 +1840,11 @@ function PlaceHolderSign() {
{/* this modal is used show send mail message and after send mail success message */}
<ModalUi
isOpen={isSend}
title={t("Mails Sent")}
title={
mailStatus === "quotareached"
? t("quotamailhead")
: t("Mails Sent")
}
handleClose={() => {
setIsSend(false);
setSignerPos([]);
Expand All @@ -1852,40 +1858,53 @@ function PlaceHolderSign() {
<p>{t("placeholder-alert-4")}</p>
{isCurrUser && <p>{t("placeholder-alert-5")}</p>}
</div>
) : mailStatus === "quotareached" ? (
<div className="flex flex-col gap-y-3">
<QuotaCard
handleClose={() => {
setIsSend(false);
setSignerPos([]);
navigate("/report/1MwEuxLEkF");
}}
/>
<div className="my-3">{handleShareList()}</div>
</div>
) : (
<p>{t("placeholder-alert-6")}</p>
)}
{!mailStatus && (
<div className="w-full h-[1px] bg-[#9f9f9f] my-[15px]"></div>
)}
<div
className={
mailStatus === "success"
? "flex justify-center mt-1"
: ""
}
>
{isCurrUser && (
{mailStatus !== "quotareached" && (
<div
className={
mailStatus === "success"
? "flex justify-center mt-1"
: ""
}
>
{isCurrUser && (
<button
onClick={() => handleRecipientSign()}
type="button"
className="op-btn op-btn-primary mr-1"
>
{t("yes")}
</button>
)}
<button
onClick={() => handleRecipientSign()}
onClick={() => {
setIsSend(false);
setSignerPos([]);
navigate("/report/1MwEuxLEkF");
}}
type="button"
className="op-btn op-btn-primary mr-1"
className="op-btn op-btn-ghost"
>
{t("yes")}
{isCurrUser ? t("no") : t("close")}
</button>
)}
<button
onClick={() => {
setIsSend(false);
setSignerPos([]);
navigate("/report/1MwEuxLEkF");
}}
type="button"
className="op-btn op-btn-ghost"
>
{isCurrUser ? t("no") : t("close")}
</button>
</div>
</div>
)}
</div>
</ModalUi>
<ModalUi
Expand Down
Loading

0 comments on commit d6f117c

Please sign in to comment.