Skip to content

Commit

Permalink
Merge pull request #1428 from OpenSignLabs/validation
Browse files Browse the repository at this point in the history
fix: signature type not visible in signpad for public template
  • Loading branch information
raktima-opensignlabs authored Nov 8, 2024
2 parents 240c776 + b77b57d commit 737d66d
Show file tree
Hide file tree
Showing 5 changed files with 57 additions and 77 deletions.
4 changes: 3 additions & 1 deletion apps/OpenSign/src/components/pdf/SignPad.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,13 @@ function SignPad(props) {
useEffect(() => {
handleTab();
// eslint-disable-next-line react-hooks/exhaustive-deps
}, []);
}, [props.signatureTypes]);

function handleTab() {
const signtypes = props?.signatureTypes || [];
const index = signtypes?.findIndex((x) => x.enabled === true);
if (index !== -1) {
setIsSignTypes(true);
const tab = props?.signatureTypes[index].name;
if (tab === "draw") {
setIsTab("draw");
Expand Down
24 changes: 7 additions & 17 deletions apps/OpenSign/src/pages/DraftTemplate.js
Original file line number Diff line number Diff line change
Expand Up @@ -248,15 +248,18 @@ const DraftTemplate = () => {
}

if (documentData && documentData.length > 0) {
const docSignTypes = documentData?.[0]?.SignatureType || signatureTypes;
if (isEnableSubscription) {
checkIsSubscribed(documentData[0]?.ExtUserPtr?.Email);
}
const userSignatureType =
documentData[0]?.ExtUserPtr?.SignatureType || signatureTypes;
const docSignTypes =
documentData?.[0]?.SignatureType || userSignatureType;
const updatedSignatureType = await handleSignatureType(
tenantSignTypes,
docSignTypes
);
setSignatureType(updatedSignatureType);
if (isEnableSubscription) {
checkIsSubscribed(documentData[0]?.ExtUserPtr?.Email);
}
const updatedPdfDetails = [...documentData];
updatedPdfDetails[0].SignatureType = updatedSignatureType;
setPdfDetails(updatedPdfDetails);
Expand Down Expand Up @@ -327,19 +330,6 @@ const DraftTemplate = () => {

const res = await contractUsers(jwttoken);
if (res[0] && res.length) {
const userSignatureType = res[0]?.SignatureType || signatureTypes;
const docSignTypes =
documentData?.[0]?.SignatureType || userSignatureType;
const updatedSignatureType = await handleSignatureType(
tenantSignTypes,
docSignTypes
);
setSignatureType(updatedSignatureType);
if (documentData?.length && documentData?.[0]?.objectId) {
const updatedPdfDetails = [...documentData];
updatedPdfDetails[0].SignatureType = updatedSignatureType;
setPdfDetails(updatedPdfDetails);
}
setSignerUserId(res[0].objectId);
const tourstatus = res[0].TourStatus && res[0].TourStatus;
if (tourstatus && tourstatus.length > 0) {
Expand Down
54 changes: 31 additions & 23 deletions apps/OpenSign/src/pages/PdfRequestFiles.js
Original file line number Diff line number Diff line change
Expand Up @@ -421,12 +421,18 @@ function PdfRequestFiles(props) {
//getting document details
const documentData = await contractDocument(docId);
if (documentData && documentData.length > 0) {
const docSignTypes = documentData?.[0]?.SignatureType || signatureTypes;
const userSignatureType =
documentData[0]?.ExtUserPtr?.SignatureType || signatureTypes;
const docSignTypes =
documentData?.[0]?.SignatureType || userSignatureType;
const updatedSignatureType = await handleSignatureType(
tenantSignTypes,
docSignTypes
);
setSignatureType(updatedSignatureType);
const updatedPdfDetails = [...documentData];
updatedPdfDetails[0].SignatureType = updatedSignatureType;
setPdfDetails(updatedPdfDetails);
const url =
documentData[0] &&
(documentData[0]?.SignedUrl || documentData[0]?.URL);
Expand Down Expand Up @@ -2130,28 +2136,30 @@ function PdfRequestFiles(props) {
</div>
</ModalUi>
{/* this component is used for signature pad modal */}
<SignPad
signatureTypes={signatureType}
isSignPad={isSignPad}
isStamp={isStamp}
setIsImageSelect={setIsImageSelect}
setIsSignPad={setIsSignPad}
setImage={setImage}
isImageSelect={isImageSelect}
imageRef={imageRef}
onImageChange={onImageChange}
setSignature={setSignature}
image={image}
onSaveImage={saveImage}
onSaveSign={saveSign}
defaultSign={defaultSignImg}
myInitial={myInitial}
isInitial={isInitial}
setIsInitial={setIsInitial}
setIsStamp={setIsStamp}
currWidgetsDetails={currWidgetsDetails}
setCurrWidgetsDetails={setCurrWidgetsDetails}
/>
{documentId && (
<SignPad
signatureTypes={signatureType}
isSignPad={isSignPad}
isStamp={isStamp}
setIsImageSelect={setIsImageSelect}
setIsSignPad={setIsSignPad}
setImage={setImage}
isImageSelect={isImageSelect}
imageRef={imageRef}
onImageChange={onImageChange}
setSignature={setSignature}
image={image}
onSaveImage={saveImage}
onSaveSign={saveSign}
defaultSign={defaultSignImg}
myInitial={myInitial}
isInitial={isInitial}
setIsInitial={setIsInitial}
setIsStamp={setIsStamp}
currWidgetsDetails={currWidgetsDetails}
setCurrWidgetsDetails={setCurrWidgetsDetails}
/>
)}
{/* pdf header which contain funish back button */}
<Header
isPdfRequestFiles={isPublicTemplate ? false : true}
Expand Down
28 changes: 9 additions & 19 deletions apps/OpenSign/src/pages/PlaceHolderSign.js
Original file line number Diff line number Diff line change
Expand Up @@ -262,12 +262,6 @@ function PlaceHolderSign() {
const documentData = await contractDocument(documentId);
if (documentData && documentData.length > 0) {
const url = documentData[0] && documentData[0]?.URL;
const docSignTypes = documentData?.[0]?.SignatureType || signatureTypes;
const updatedSignatureType = await handleSignatureType(
tenantSignTypes,
docSignTypes
);
setSignatureType(updatedSignatureType);
//convert document url in array buffer format to use embed widgets in pdf using pdf-lib
const arrayBuffer = await convertPdfArrayBuffer(url);
if (arrayBuffer === "Error") {
Expand Down Expand Up @@ -320,6 +314,15 @@ function PlaceHolderSign() {
});
}
}
const userSignatureType =
documentData[0]?.ExtUserPtr?.SignatureType || signatureTypes;
const docSignTypes =
documentData?.[0]?.SignatureType || userSignatureType;
const updatedSignatureType = await handleSignatureType(
tenantSignTypes,
docSignTypes
);
setSignatureType(updatedSignatureType);
const updatedPdfDetails = [...documentData];
updatedPdfDetails[0].SignatureType = updatedSignatureType;
setPdfDetails(updatedPdfDetails);
Expand Down Expand Up @@ -445,19 +448,6 @@ function PlaceHolderSign() {
setHandleError(t("something-went-wrong-mssg"));
setIsLoading({ isLoad: false });
} else if (res.length && res[0]?.objectId) {
const userSignatureType = res[0]?.SignatureType || signatureTypes;
const docSignTypes =
documentData?.[0]?.SignatureType || userSignatureType;
const updatedSignatureType = await handleSignatureType(
tenantSignTypes,
docSignTypes
);
setSignatureType(updatedSignatureType);
if (documentData?.length && documentData?.[0]?.objectId) {
const updatedPdfDetails = [...documentData];
updatedPdfDetails[0].SignatureType = updatedSignatureType;
setPdfDetails(updatedPdfDetails);
}
setActiveMailAdapter(res[0]?.active_mail_adapter);
setSignerUserId(res[0].objectId);
const tourstatus = res[0].TourStatus && res[0].TourStatus;
Expand Down
24 changes: 7 additions & 17 deletions apps/OpenSign/src/pages/TemplatePlaceholder.js
Original file line number Diff line number Diff line change
Expand Up @@ -236,15 +236,18 @@ const TemplatePlaceholder = () => {
: [];

if (documentData && documentData.length > 0) {
const docSignTypes = documentData?.[0]?.SignatureType || signatureTypes;
if (isEnableSubscription) {
checkIsSubscribed(documentData[0]?.ExtUserPtr?.Email);
}
const userSignatureType =
documentData[0]?.ExtUserPtr?.SignatureType || signatureTypes;
const docSignTypes =
documentData?.[0]?.SignatureType || userSignatureType;
const updatedSignatureType = await handleSignatureType(
tenantSignTypes,
docSignTypes
);
setSignatureType(updatedSignatureType);
if (isEnableSubscription) {
checkIsSubscribed(documentData[0]?.ExtUserPtr?.Email);
}
const updatedPdfDetails = [...documentData];
updatedPdfDetails[0].SignatureType = updatedSignatureType;
setPdfDetails(updatedPdfDetails);
Expand Down Expand Up @@ -314,19 +317,6 @@ const TemplatePlaceholder = () => {
}
const res = await contractUsers();
if (res[0] && res.length) {
const userSignatureType = res[0]?.SignatureType || signatureTypes;
const docSignTypes =
documentData?.[0]?.SignatureType || userSignatureType;
const updatedSignatureType = await handleSignatureType(
tenantSignTypes,
docSignTypes
);
setSignatureType(updatedSignatureType);
if (documentData?.length && documentData?.[0]?.objectId) {
const updatedPdfDetails = [...documentData];
updatedPdfDetails[0].SignatureType = updatedSignatureType;
setPdfDetails(updatedPdfDetails);
}
setSignerUserId(res[0].objectId);
setCurrentEmail(res[0].Email);
const tourstatus = res[0].TourStatus && res[0].TourStatus;
Expand Down

0 comments on commit 737d66d

Please sign in to comment.