mirror of
https://github.com/OpenSignLabs/OpenSign.git
synced 2026-08-17 21:25:54 +02:00
fix: invalid template id error in while opening opening public template
This commit is contained in:
@@ -654,21 +654,20 @@ const DraftTemplate = () => {
|
||||
// `saveTemplate` is used to update template on server using savetemplate endpoint
|
||||
const saveTemplate = async () => {
|
||||
if (signersdata?.length) {
|
||||
const loadObj = { isLoad: true, message: t("loading-mssg") };
|
||||
setIsLoading(loadObj);
|
||||
setIsLoading({ isLoad: true, message: t("loading-mssg") });
|
||||
setIsSendAlert(false);
|
||||
let signers = [];
|
||||
if (signersdata?.length > 0) {
|
||||
signersdata.forEach((x) => {
|
||||
signers = signersdata?.reduce((acc, x) => {
|
||||
if (x.objectId) {
|
||||
const obj = {
|
||||
acc.push({
|
||||
__type: "Pointer",
|
||||
className: "contracts_Contactbook",
|
||||
objectId: x.objectId
|
||||
};
|
||||
signers.push(obj);
|
||||
});
|
||||
}
|
||||
});
|
||||
return acc;
|
||||
}, []);
|
||||
}
|
||||
let pdfUrl = pdfDetails[0]?.URL;
|
||||
if (pdfRotateBase64) {
|
||||
@@ -1277,10 +1276,11 @@ const DraftTemplate = () => {
|
||||
};
|
||||
const handleGeneratePublic = async () => {
|
||||
const unlinkSignerIndex = signerPos?.findIndex((x) => !x?.signerObjId);
|
||||
const unlinkSigners = signerPos?.filter((x) => !x?.signerObjId)?.length; // unLink with role
|
||||
const unlinkSigners = signerPos?.filter((x) => !x?.signerObjId)?.length; // count of total unlink roles
|
||||
if (unlinkSignerIndex === 0 && unlinkSigners === 1) {
|
||||
try {
|
||||
const data = { templateId: templateId, IsPublic: true };
|
||||
const role = signerPos[unlinkSignerIndex]?.Role;
|
||||
const data = { templateId: templateId, IsPublic: true, Role: role };
|
||||
const baseURL = localStorage.getItem("baseUrl");
|
||||
const url = `${baseURL}functions/updatetopublictemplate`;
|
||||
const headers = {
|
||||
|
||||
@@ -10,6 +10,7 @@ async function updateTemplate(template, isJwt = false) {
|
||||
const isPublic = template?.IsPublic !== undefined ? template?.IsPublic : false;
|
||||
if (template?.IsPublic !== undefined) {
|
||||
updateTemplate.set('IsPublic', isPublic);
|
||||
updateTemplate.set('PublicRole', template.PublicRole);
|
||||
}
|
||||
|
||||
let updateTemplateRes;
|
||||
@@ -29,7 +30,16 @@ async function updateTemplate(template, isJwt = false) {
|
||||
}
|
||||
export default async function updateToPublicTemplate(request) {
|
||||
const jwttoken = request.headers.jwttoken || '';
|
||||
const template = { Id: request.params.templateId, IsPublic: request.params?.IsPublic };
|
||||
const Role = request.params.Role;
|
||||
if (!Role) {
|
||||
throw new Parse.Error(Parse.Error.INVALID_QUERY, 'Please provide public role.');
|
||||
}
|
||||
const PublicRole = [Role];
|
||||
const template = {
|
||||
Id: request.params.templateId,
|
||||
IsPublic: request.params?.IsPublic,
|
||||
PublicRole: PublicRole,
|
||||
};
|
||||
|
||||
try {
|
||||
if (request.user) {
|
||||
|
||||
Reference in New Issue
Block a user