diff --git a/apps/OpenSign/src/components/pdf/PlaceholderType.js b/apps/OpenSign/src/components/pdf/PlaceholderType.js index 918fdc129..b23f056e1 100644 --- a/apps/OpenSign/src/components/pdf/PlaceholderType.js +++ b/apps/OpenSign/src/components/pdf/PlaceholderType.js @@ -38,15 +38,17 @@ function PlaceholderType(props) { "December" ]; const validateExpression = (regexValidation) => { - let regexObject = regexValidation; - if (props.pos?.options.validation.type === "regex") { - regexObject = RegexParser(regexValidation); - } - // new RegExp(regexValidation); - let isValidate = regexObject.test(textValue); - if (!isValidate) { - props?.setValidateAlert(true); - inputRef.current.focus(); + if (textValue) { + let regexObject = regexValidation; + if (props.pos?.options.validation.type === "regex") { + regexObject = RegexParser(regexValidation); + } + // new RegExp(regexValidation); + let isValidate = regexObject.test(textValue); + if (!isValidate) { + props?.setValidateAlert(true); + inputRef.current.focus(); + } } }; diff --git a/apps/OpenSign/src/components/pdf/RecipientList.js b/apps/OpenSign/src/components/pdf/RecipientList.js index ba9b5166c..780ee2a5d 100644 --- a/apps/OpenSign/src/components/pdf/RecipientList.js +++ b/apps/OpenSign/src/components/pdf/RecipientList.js @@ -230,7 +230,11 @@ const RecipientList = (props) => { )} - {obj.Name && {obj.Role}} + {obj.Name && ( + + {obj?.Role || obj?.Email} + + )} {isMobile && props.sendInOrder && ( diff --git a/apps/OpenSign/src/components/pdf/RenderAllPdfPage.js b/apps/OpenSign/src/components/pdf/RenderAllPdfPage.js index 7c045bbc4..cb1fa0700 100644 --- a/apps/OpenSign/src/components/pdf/RenderAllPdfPage.js +++ b/apps/OpenSign/src/components/pdf/RenderAllPdfPage.js @@ -4,7 +4,6 @@ import { Document, Page } from "react-pdf"; import { themeColor } from "../../constant/const"; function RenderAllPdfPage({ - pdfUrl, signPdfUrl, allPages, setAllPages, @@ -50,8 +49,7 @@ function RenderAllPdfPage({ {Array.from(new Array(allPages), (el, index) => (
{type}
)} -
- {`(${Role})`} -
+ {Role && ( +
+ {`(${Role})`} +
+ )} ); } else { diff --git a/apps/OpenSign/src/components/pdf/SignerListPlace.js b/apps/OpenSign/src/components/pdf/SignerListPlace.js index be9965bf4..9a8bab189 100644 --- a/apps/OpenSign/src/components/pdf/SignerListPlace.js +++ b/apps/OpenSign/src/components/pdf/SignerListPlace.js @@ -71,7 +71,7 @@ function SignerListPlace(props) {
- {props.handleAddSigner && ( + {props.handleAddSigner ? (
Add role
+ ) : ( +
props.setIsAddSigner(true)} + style={{ + opacity: props.isMailSend && "0.5", + pointerEvents: props.isMailSend && "none" + }} + > + + Add recipients +
)} ); diff --git a/apps/OpenSign/src/components/pdf/WidgetComponent.js b/apps/OpenSign/src/components/pdf/WidgetComponent.js index e9bff561a..957ea9536 100644 --- a/apps/OpenSign/src/components/pdf/WidgetComponent.js +++ b/apps/OpenSign/src/components/pdf/WidgetComponent.js @@ -38,7 +38,8 @@ function WidgetComponent({ sendInOrder, isTemplateFlow, setBlockColor, - blockColor + blockColor, + setIsAddSigner }) { const [isSignersModal, setIsSignersModal] = useState(false); @@ -319,7 +320,7 @@ function WidgetComponent({ )} - {handleAddSigner && ( + {handleAddSigner ? (
Add role
+ ) : ( +
setIsAddSigner(true)} + > + + Add recipients +
)}
@@ -424,7 +439,7 @@ function WidgetComponent({ textAlign: "center" }} > - Please add a role + Please add a {title ? title : "recipients"}
)} diff --git a/apps/OpenSign/src/components/shared/fields/SelectSigners.js b/apps/OpenSign/src/components/shared/fields/SelectSigners.js index f598b9265..f6ec88c82 100644 --- a/apps/OpenSign/src/components/shared/fields/SelectSigners.js +++ b/apps/OpenSign/src/components/shared/fields/SelectSigners.js @@ -53,9 +53,22 @@ const SelectSigners = (props) => { const contactRes = await contactbook.find(); if (contactRes) { const res = JSON.parse(JSON.stringify(contactRes)); - // console.log("userList ", res); - setUserList(res); - return await res.map((item) => ({ + //compareArrays is a function where compare between two array (total signersList and dcument signers list) + //and filter signers from total signer's list which already present in document's signers list + const compareArrays = (res, signerObj) => { + return res.filter( + (item1) => + !signerObj.find((item2) => item2.objectId === item1.objectId) + ); + }; + + //get update signer's List if signersdata is present + const updateSignersList = + props?.signersData && compareArrays(res, props?.signersData); + + const result = updateSignersList ? updateSignersList : res; + setUserList(result); + return await result.map((item) => ({ label: item.Email, value: item.objectId })); diff --git a/apps/OpenSign/src/pages/PdfRequestFiles.js b/apps/OpenSign/src/pages/PdfRequestFiles.js index 71db81ab4..3acb27776 100644 --- a/apps/OpenSign/src/pages/PdfRequestFiles.js +++ b/apps/OpenSign/src/pages/PdfRequestFiles.js @@ -1173,7 +1173,7 @@ function PdfRequestFiles() { {/* this component used to render all pdf pages in left side */} ({ ...x, Id: randomId(), - Role: "User " + (index + 1), + // Role: "User " + (index + 1), blockColor: color[index % color.length] })); setSignersData(updatedSigners); @@ -358,7 +359,7 @@ function PlaceHolderSign() { setBlockColor(updatedSigners[0].blockColor); } } else { - setRoleName("User 1"); + // setRoleName("User 1"); if ( documentData[0].Placeholders && documentData[0].Placeholders.length > 0 @@ -1525,8 +1526,25 @@ function PlaceHolderSign() { } }; + //function to add new signer in document signers list + const handleAddNewRecipients = (data) => { + const newId = randomId(); + signersdata.push({ + ...data, + className: "contracts_Contactbook", + Id: newId, + blockColor: color[signersdata.length] + }); + setUniqueId(newId); + setIsSelectId(signersdata.length - 1); + setBlockColor(color[signersdata.length]); + setContractName("contracts_Contactbook"); + setSignerObjId(data.objectId); + }; + const closePopup = () => { setIsAddUser({}); + setIsAddSigner(false); }; //function for handle ontext change and save again text in delta in Request Email flow @@ -1546,6 +1564,30 @@ function PlaceHolderSign() { style: { fontSize: "13px" } } ]; + + // `handleDeleteUser` function is used to delete record and placeholder when user click on delete which is place next user name in recipients list + const handleDeleteUser = (Id) => { + const updateSigner = signersdata + .filter((x) => x.Id !== Id) + .map((x, i) => ({ ...x, blockColor: color[i] })); + setSignersData(updateSigner); + const updatePlaceholderUser = signerPos + .filter((x) => x.Id !== Id) + .map((x, i) => ({ ...x, blockColor: color[i] })); + const index = signersdata.findIndex((x) => x.Id === Id); + if (index === signersdata.length - 1) { + setUniqueId(updateSigner[updateSigner.length - 1]?.Id || ""); + setIsSelectId(index - 1 || 0); + setBlockColor(color[index - 1 || 0]); + } else { + setUniqueId(updateSigner[index]?.Id || ""); + setIsSelectId(index); + setBlockColor(color[index]); + } + + setSignerPos(updatePlaceholderUser); + setIsMailSend(false); + }; return ( <> @@ -1712,9 +1754,7 @@ function PlaceHolderSign() { "cursor-pointer underline text-blue-700 focus:outline-none" } onClick={() => { - isSubscribe || - (!isEnableSubscription && - setIsCustomize(!isCustomize)); + setIsCustomize(!isCustomize); }} > Cutomize Email @@ -1982,6 +2022,8 @@ function PlaceHolderSign() { setSignersData={setSignersData} blockColor={blockColor} setBlockColor={setBlockColor} + setIsAddSigner={setIsAddSigner} + handleDeleteUser={handleDeleteUser} /> </div> ) : ( @@ -2007,6 +2049,9 @@ function PlaceHolderSign() { blockColor={blockColor} setBlockColor={setBlockColor} isMailSend={isMailSend} + setIsAddSigner={setIsAddSigner} + handleDeleteUser={handleDeleteUser} + roleName={roleName} // handleAddSigner={handleAddSigner} /> <div data-tut="reactourSecond"> @@ -2033,35 +2078,6 @@ function PlaceHolderSign() { )} </DndProvider> <div> - {/* <ModalUi - headerColor={"#dc3545"} - isOpen={signerExistModal} - title={"Users required"} - handleClose={() => { - setSignerExistModal(false); - }} - > - <div style={{ height: "100%", padding: 20 }}> - <p>Please assign signers to all placeholders</p> - - <div - style={{ - height: "1px", - backgroundColor: "#9f9f9f", - width: "100%", - marginTop: "15px", - marginBottom: "15px" - }} - ></div> - <button - onClick={() => setSignerExistModal(false)} - type="button" - className="finishBtn cancelBtn" - > - Close - </button> - </div> - </ModalUi> */} <ModalUi headerColor={"#dc3545"} isOpen={isAlreadyPlace.status} @@ -2095,6 +2111,13 @@ function PlaceHolderSign() { isAddUser={isAddUser} uniqueId={uniqueId} closePopup={closePopup} + signersData={signersdata} + /> + <LinkUserModal + handleAddUser={handleAddNewRecipients} + isAddSigner={isAddSigner} + closePopup={closePopup} + signersData={signersdata} /> <WidgetNameModal widgetName={widgetName} diff --git a/apps/OpenSign/src/pages/SignyourselfPdf.js b/apps/OpenSign/src/pages/SignyourselfPdf.js index 3be0dc283..e946d0a28 100644 --- a/apps/OpenSign/src/pages/SignyourselfPdf.js +++ b/apps/OpenSign/src/pages/SignyourselfPdf.js @@ -1001,7 +1001,6 @@ function SignYourSelf() { {/* this component used to render all pdf pages in left side */} <RenderAllPdfPage - pdfUrl={pdfUrl} signPdfUrl={pdfDetails[0] && pdfDetails[0].URL} allPages={allPages} setAllPages={setAllPages} diff --git a/apps/OpenSign/src/pages/TemplatePlaceholder.js b/apps/OpenSign/src/pages/TemplatePlaceholder.js index 477eb9a02..a90bfd600 100644 --- a/apps/OpenSign/src/pages/TemplatePlaceholder.js +++ b/apps/OpenSign/src/pages/TemplatePlaceholder.js @@ -1548,6 +1548,7 @@ const TemplatePlaceholder = () => { isAddUser={isAddUser} uniqueId={uniqueId} closePopup={closePopup} + signersData={signersdata} /> </div> <ModalUi diff --git a/apps/OpenSign/src/primitives/LinkUserModal.js b/apps/OpenSign/src/primitives/LinkUserModal.js index 8cb272191..a8caa61b2 100644 --- a/apps/OpenSign/src/primitives/LinkUserModal.js +++ b/apps/OpenSign/src/primitives/LinkUserModal.js @@ -7,12 +7,16 @@ const LinkUserModal = (props) => { return ( <ModalUi title={"Add/Choose Signer"} - isOpen={props.isAddUser[props.uniqueId]} + isOpen={ + props?.isAddSigner || + (props?.isAddUser && props?.isAddUser[props?.uniqueId]) + } handleClose={props.closePopup} > <SelectSigners details={props.handleAddUser} closePopup={props.closePopup} + signersData={props?.signersData} /> <div style={{ diff --git a/apps/OpenSign/src/primitives/Validate.js b/apps/OpenSign/src/primitives/Validate.js index c2920b631..8bba5ef71 100644 --- a/apps/OpenSign/src/primitives/Validate.js +++ b/apps/OpenSign/src/primitives/Validate.js @@ -9,9 +9,15 @@ const Validate = () => { useEffect(() => { (async () => { try { + const userDetails = JSON.parse( + localStorage.getItem( + `Parse/${localStorage.getItem("parseAppId")}/currentUser` + ) + ); + // Use the session token to validate the user const userQuery = new Parse.Query(Parse.User); - const user = await userQuery.get(Parse.User.current().id, { + const user = await userQuery.get(userDetails?.objectId, { sessionToken: localStorage.getItem("accesstoken") }); if (user) { @@ -24,6 +30,7 @@ const Validate = () => { setIsUserValid(false); } })(); + // eslint-disable-next-line react-hooks/exhaustive-deps }, []);