Skip to content

Commit

Permalink
Merge pull request #1120 from OpenSignLabs/rotatepage_document
Browse files Browse the repository at this point in the history
fix:  handle conditions and throw errors for public template script loading
  • Loading branch information
prafull-opensignlabs authored Aug 29, 2024
2 parents 5a6437e + 3395785 commit 9429b00
Show file tree
Hide file tree
Showing 5 changed files with 224 additions and 87 deletions.
4 changes: 3 additions & 1 deletion apps/OpenSign/public/locales/en/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,8 @@
"Share with team": "Share with team",
"Share": "Share",
"View": "View",
"option": "Option"
"option": "Option",
"Embed":"Embed"
},
"report-heading": {
"Sr.No": "Sr.No",
Expand Down Expand Up @@ -617,5 +618,6 @@
"rotate-right":"Rotate right",
"rotate-left":"Rotate left",
"rotate-alert-mssg":"All widgets on this page will be lost. Are you sure you want to proceed?",
"templateid":"Template-Id",
"bulksendsubcriptionalert":"Please upgrade to Professional or Team plan to use quicksend."
}
4 changes: 3 additions & 1 deletion apps/OpenSign/public/locales/fr/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,8 @@
"Share with team": "Partager avec l'équipe",
"Share": "Partager",
"View": "Voir",
"option": "Option"
"option": "Option",
"Embed":"Intégrer"
},
"report-help": {
"Draft Documents": "Il s'agit de documents que vous avez commencés mais que vous n'avez pas finalisés pour envoi.",
Expand Down Expand Up @@ -617,5 +618,6 @@
"rotate-right" :"Faire pivoter à droite",
"rotate-left" :"Faire pivoter à gauche",
"rotate-alert-mssg" :"Tous les widgets de cette page seront perdus. Êtes-vous sûr de vouloir continuer ?",
"templateid":"ID de modèle",
"bulksendsubcriptionalert":"Veuillez passer au forfait Professionnel ou Équipe pour utiliser Quicksend."
}
7 changes: 7 additions & 0 deletions apps/OpenSign/src/json/ReportJson.js
Original file line number Diff line number Diff line change
Expand Up @@ -354,6 +354,13 @@ export default function reportJson(id) {
redirectUrl: "template",
action: "redirect"
},
{
btnId: "2434",
btnLabel: "Embed",
hoverLabel: "Embed",
btnIcon: "fa-light fa-code",
action: "Embed"
},
{
btnId: "1834",
btnLabel: "Delete",
Expand Down
102 changes: 55 additions & 47 deletions apps/OpenSign/src/pages/PdfRequestFiles.js
Original file line number Diff line number Diff line change
Expand Up @@ -300,58 +300,66 @@ function PdfRequestFiles(props) {
templateDeatils.data && templateDeatils.data.result
? [templateDeatils.data.result]
: [];

if (documentData && documentData.length > 0) {
const url =
documentData[0] &&
(documentData[0]?.SignedUrl || documentData[0]?.URL);
if (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") {
setHandleError(t("something-went-wrong-mssg"));
if (documentData && documentData[0]?.error) {
props?.setTemplateStatus({
status: "Invalid"
});
} else if (documentData && documentData.length > 0) {
if (documentData[0]?.IsPublic) {
props?.setTemplateStatus({
status: "Success"
});
const url =
documentData[0] &&
(documentData[0]?.SignedUrl || documentData[0]?.URL);
if (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") {
setHandleError(t("something-went-wrong-mssg"));
} else {
setPdfArrayBuffer(arrayBuffer);
}
} else {
setPdfArrayBuffer(arrayBuffer);
setHandleError(t("something-went-wrong-mssg"));
}
} else {
setHandleError(t("something-went-wrong-mssg"));
}
setIsPublicTemplate(true);
const getPublicRole = documentData[0]?.PublicRole[0];
const getUniqueIdDetails = documentData[0]?.Placeholders.find(
(x) => x.Role === getPublicRole
);
if (getUniqueIdDetails) {
setUniqueId(getUniqueIdDetails.Id);
}
setSignerPos(documentData[0]?.Placeholders);
let placeholdersOrSigners = [];
// const placeholder = documentData[0]?.Placeholders;
for (const placeholder of documentData[0].Placeholders) {
//`emailExist` variable to handle condition for quick send flow and show unsigned signers list
const signerIdExist = placeholder?.signerObjId;
if (signerIdExist) {
const getSignerData = documentData[0].Signers.find(
(data) => data.objectId === placeholder?.signerObjId
);
placeholdersOrSigners.push(getSignerData);
} else {
placeholdersOrSigners.push(placeholder);
setIsPublicTemplate(true);
const getPublicRole = documentData[0]?.PublicRole[0];
const getUniqueIdDetails = documentData[0]?.Placeholders.find(
(x) => x.Role === getPublicRole
);
if (getUniqueIdDetails) {
setUniqueId(getUniqueIdDetails.Id);
}
setSignerPos(documentData[0]?.Placeholders);
let placeholdersOrSigners = [];
// const placeholder = documentData[0]?.Placeholders;
for (const placeholder of documentData[0].Placeholders) {
//`emailExist` variable to handle condition for quick send flow and show unsigned signers list
const signerIdExist = placeholder?.signerObjId;
if (signerIdExist) {
const getSignerData = documentData[0].Signers.find(
(data) => data.objectId === placeholder?.signerObjId
);
placeholdersOrSigners.push(getSignerData);
} else {
placeholdersOrSigners.push(placeholder);
}
}
setUnSignedSigners(placeholdersOrSigners);
setPdfDetails(documentData);
setIsLoading({
isLoad: false
});
} else {
props?.setTemplateStatus({
status: "Private"
});
}
setUnSignedSigners(placeholdersOrSigners);
setPdfDetails(documentData);
setIsLoading({ isLoad: false });
} else if (
documentData === "Error: Something went wrong!" ||
(documentData.result && documentData.result.error)
) {
console.log("err in get template details ");
setHandleError(t("something-went-wrong-mssg"));
setIsLoading({ isLoad: false });
} else {
setHandleError(t("no-data"));
setIsLoading({ isLoad: false });
props?.setTemplateStatus({
status: "Invalid"
});
}
} catch (err) {
console.log("err in get template details ", err);
Expand Down
Loading

0 comments on commit 9429b00

Please sign in to comment.