diff --git a/microfrontends/SignDocuments/src/Component/TemplatePlaceholder.js b/microfrontends/SignDocuments/src/Component/TemplatePlaceholder.js index 2eb0e8cf7..13cc69416 100644 --- a/microfrontends/SignDocuments/src/Component/TemplatePlaceholder.js +++ b/microfrontends/SignDocuments/src/Component/TemplatePlaceholder.js @@ -327,21 +327,13 @@ const TemplatePlaceholder = () => { //function for setting position after drop signature button over pdf const addPositionOfSignature = (item, monitor) => { - if (isMobile) { - if (selectedEmail) { getSignerPos(item, monitor); - } else { - setIsShowEmail(true); - } - } else { - getSignerPos(item, monitor); - } }; // `getSignerPos` is used to get placeholder position when user place it and save it in array const getSignerPos = (item, monitor) => { - const singer = signersdata.find((x) => x.Id === uniqueId); - if (singer) { + const signer = signersdata.find((x) => x.Id === uniqueId); + if (signer) { const posZIndex = zIndex + 1; setZIndex(posZIndex); const newWidth = containerWH.width; @@ -709,8 +701,7 @@ const TemplatePlaceholder = () => { } }; const handleSaveTemplate = async () => { - const singer = signersdata.find((x) => x.Id === uniqueId); - if (singer) { + if (signersdata?.length) { const loadObj = { isLoad: true, message: "This might take some time" @@ -899,12 +890,14 @@ const TemplatePlaceholder = () => { const updatePlaceholderUser = signerPos .filter((x) => x.Id !== Id) .map((x, i) => ({ ...x, blockColor: color[i] })); - // console.log("removePlaceholderUser ", removePlaceholderUser) - const index = signersdata.findIndex((x)=> x.Id === Id) - setUniqueId(updateSigner[index]?.Id ||""); - // setIsSelectId(index === -1 ? 0: index); - setIsSelectId(0); + if(index === signersdata.length - 1){ + setUniqueId(updateSigner[updateSigner.length - 1]?.Id ||""); + setIsSelectId(0); + }else{ + setUniqueId(updateSigner[index]?.Id ||""); + setIsSelectId(index); + } setSignerPos(updatePlaceholderUser); setIsMailSend(false); @@ -1205,6 +1198,9 @@ const TemplatePlaceholder = () => { handleAddSigner={handleAddSigner} setUniqueId={setUniqueId} setRoleName={setRoleName} + handleDeleteUser={handleDeleteUser} + handleRoleChange={handleRoleChange} + handleOnBlur={handleOnBlur} /> ) : ( diff --git a/microfrontends/SignDocuments/src/Component/component/fieldsComponent.js b/microfrontends/SignDocuments/src/Component/component/fieldsComponent.js index d785ad886..b3cb187bc 100644 --- a/microfrontends/SignDocuments/src/Component/component/fieldsComponent.js +++ b/microfrontends/SignDocuments/src/Component/component/fieldsComponent.js @@ -1,6 +1,6 @@ -import React from "react"; -import * as Select from "@radix-ui/react-select"; -import classnames from "classnames"; +import React, { useState } from "react"; +import ModalUi from "../../premitives/ModalUi"; +import RecipientList from "../../premitives/RecipientList"; function FieldsComponent({ pdfUrl, @@ -28,33 +28,20 @@ function FieldsComponent({ isSigners, dataTut, dataTut2, - setIsShowEmail, isMailSend, - selectedEmail, - setSelectedEmail, handleAddSigner, setUniqueId, - setRoleName + setRoleName, + handleDeleteUser, + signerPos, + handleRoleChange, + handleOnBlur }) { + const [isSignersModal, setIsSignersModal] = useState(false); const signStyle = pdfUrl ? "disableSign" : "signatureBtn"; const isMobile = window.innerWidth < 767; - const SelectItem = React.forwardRef( - ({ children, className, ...props }, forwardedRef) => { - return ( - - {children} - - - ); - } - ); - const color = [ "#93a3db", "#e6c3db", @@ -70,6 +57,9 @@ function FieldsComponent({ "#ffffcc" ]; + const handleModal = () => { + setIsSignersModal(!isSignersModal); + }; return ( <> {isMobile && isSignYourself ? ( @@ -92,97 +82,24 @@ function FieldsComponent({ alignItems: "center", justifyContent: "center" }} + onClick={() => { + if (signersdata?.length) { + handleModal(); + } + }} > - Signer : + Recipient + + + {signersdata[isSelectListId]?.Role && ( +
+ {signersdata[isSelectListId]?.Name + ? ` : ${signersdata[isSelectListId]?.Name}` + : ` : ${signersdata[isSelectListId]?.Role}`} +
+ )}
- - { - const [selectedKey, selectedData] = obj.split("|"); - const parseData = JSON.parse(selectedData); - - setSignerObjId(parseData.objectId); - setIsSelectId(selectedKey); - setContractName(parseData.className); - setSelectedEmail(true); - setUniqueId(parseData.Id); - setRoleName(parseData.Role); - }} - > - - - {!selectedEmail && ( - - - - )} - - - - - - - - - {signersdata.map((obj, ind) => { - return ( - - {obj.Email ? obj.Email : obj.Role } - - ); - })} - - - - - - - - )} {handleAddSigner && ( @@ -206,17 +123,7 @@ function FieldsComponent({ style={{ backgroundColor: themeColor() }} >
{ - if (isSigners) { - if (selectedEmail) { - addPositionOfSignature("onclick", false); - } else { - setIsShowEmail(true); - } - } else { - addPositionOfSignature("onclick", false); - } - }} + onClick={() => addPositionOfSignature("onclick", false)} ref={(element) => { dragSignatureSS(element); if (element) { @@ -426,6 +333,25 @@ function FieldsComponent({
)} + + + ); } diff --git a/microfrontends/SignDocuments/src/Component/component/header.js b/microfrontends/SignDocuments/src/Component/component/header.js index cdf13b65f..b92dfff72 100644 --- a/microfrontends/SignDocuments/src/Component/component/header.js +++ b/microfrontends/SignDocuments/src/Component/component/header.js @@ -540,7 +540,7 @@ function Header({
{signerPos.length === 0 ? ( - Add all {signersdata.length - signerPos.length}{" "} + Add {signersdata.length - signerPos.length}{" "} recipients signature ) : ( diff --git a/microfrontends/SignDocuments/src/Component/component/renderPdf.js b/microfrontends/SignDocuments/src/Component/component/renderPdf.js index 43c95d53e..808e12c9b 100644 --- a/microfrontends/SignDocuments/src/Component/component/renderPdf.js +++ b/microfrontends/SignDocuments/src/Component/component/renderPdf.js @@ -386,13 +386,18 @@ function RenderPdf({ ); if (checkSign.length > 0) { return ( -

{checkSign[0].Name}

+ <> +
+ {checkSign[0].Name} +
+
{`(${Role})`}
+ ); } else { - return

{Role}

; + return
{Role}
; } } else { - return

{Role}

; + return
{Role}
; } }; return ( @@ -455,13 +460,9 @@ function RenderPdf({ handleSignYourselfImageResize( ref, pos.key, - direction, - position, xyPostion, index, - setXyPostion, - pdfOriginalWidth, - containerWH + setXyPostion ); }} size={{ @@ -506,7 +507,11 @@ function RenderPdf({ marginTop: "0px" }} > - {pos.isStamp ? "stamp" : "signature"} + {pos.isStamp ? ( +
stamp
+ ) : ( +
signature
+ )} {handleUserName( data.signerObjId, data.Role @@ -708,9 +713,11 @@ function RenderPdf({ marginTop: "0px" }} > - {pos.isStamp - ? "stamp" - : "signature"} + {pos.isStamp ? ( +
stamp
+ ) : ( +
signature
+ )} {handleUserName( data.signerObjId, data.Role @@ -778,25 +785,12 @@ function RenderPdf({ handleSignYourselfImageResize( ref, pos.key, - direction, - position, xyPostion, index, - setXyPostion, - pdfOriginalWidth, - containerWH + setXyPostion + ); }} - onTouchEnd={(e) => { - if (!isDragging && isMobile) { - setTimeout(() => { - e.stopPropagation(); - setIsSignPad(true); - setSignKey(pos.key); - setIsStamp(pos.isStamp); - }, 500); - } - }} >
{ if (!isDragging && isMobile) { setTimeout(() => { @@ -868,10 +869,6 @@ function RenderPdf({ }} > {pos.isStamp ? "stamp" : "signature"} - {handleUserName( - data.signerObjId, - data.Role - )}
)}
@@ -979,13 +976,9 @@ function RenderPdf({ handleSignYourselfImageResize( ref, pos.key, - direction, - position, xyPostion, index, - setXyPostion, - pdfOriginalWidth, - containerWH + setXyPostion ); }} key={pos.key} @@ -1044,7 +1037,11 @@ function RenderPdf({ marginTop: "0px" }} > - {pos.isStamp ? "stamp" : "signature"} + {pos.isStamp ? ( +
stamp
+ ) : ( +
signature
+ )} {handleUserName( data.signerObjId, data.Role @@ -1223,9 +1220,11 @@ function RenderPdf({ justifyContent: "center" }} > - {pos.isStamp - ? "stamp" - : "signature"} + {pos.isStamp ? ( +
stamp
+ ) : ( +
signature
+ )} {handleUserName( data.signerObjId, data.Role @@ -1300,13 +1299,9 @@ function RenderPdf({ handleSignYourselfImageResize( ref, pos.key, - direction, - position, xyPostion, index, - setXyPostion, - pdfOriginalWidth, - containerWH + setXyPostion ); }} > diff --git a/microfrontends/SignDocuments/src/Component/component/signerListPlace.js b/microfrontends/SignDocuments/src/Component/component/signerListPlace.js index 85b44237c..9a4c56b08 100644 --- a/microfrontends/SignDocuments/src/Component/component/signerListPlace.js +++ b/microfrontends/SignDocuments/src/Component/component/signerListPlace.js @@ -1,106 +1,9 @@ -import React, { useRef, useState } from "react"; +import React from "react"; import { themeColor } from "../../utils/ThemeColor/backColor"; import "../../css/signerListPlace.css"; +import RecipientList from "../../premitives/RecipientList"; -function SignerListPlace({ - signerPos, - signersdata, - isSelectListId, - setSignerObjId, - setIsSelectId, - setContractName, - handleAddSigner, - setUniqueId, - setRoleName, - handleDeleteUser, - handleRoleChange, - handleOnBlur -}) { - const color = [ - "#93a3db", - "#e6c3db", - "#c0e3bc", - "#bce3db", - "#b8ccdb", - "#ceb8db", - "#ffccff", - "#99ffcc", - "#cc99ff", - "#ffcc99", - "#66ccff", - "#ffffcc" - ]; - - const nameColor = [ - "#304fbf", - "#7d5270", - "#5f825b", - "#578077", - "#576e80", - "#6d527d", - "#cc00cc", - "#006666", - "#cc00ff", - "#ff9900", - "#336699", - "#cc9900" - ]; - const [isHover, setIsHover] = useState(); - const [isEdit, setIsEdit] = useState(false); - //function for onhover signer name change background color - const inputRef = useRef(null); - const onHoverStyle = (ind, blockColor) => { - const style = { - background: blockColor ? blockColor : color[ind % color.length], - padding: "10px", - marginTop: "2px", - display: "flex", - flexDirection: "row", - borderBottom: "1px solid #e3e1e1", - alignItems: "center" - }; - return style; - }; - //function for onhover signer name remove background color - const nonHoverStyle = (ind) => { - const style = { - padding: "10px", - marginTop: "2px", - display: "flex", - flexDirection: "row", - borderBottom: "1px solid #e3e1e1", - alignItems: "center" - }; - return style; - }; - - const getFirstLetter = (name) => { - const firstLetter = name?.charAt(0); - return firstLetter; - }; - - const darkenColor = (color, factor) => { - // Remove '#' from the color code and parse it to get RGB values - const hex = color.replace("#", ""); - const r = parseInt(hex.substring(0, 2), 16); - const g = parseInt(hex.substring(2, 4), 16); - const b = parseInt(hex.substring(4, 6), 16); - - // Darken the color by reducing each RGB component - const darkerR = Math.floor(r * (1 - factor)); - const darkerG = Math.floor(g * (1 - factor)); - const darkerB = Math.floor(b * (1 - factor)); - - // Convert the darkened RGB components back to hex - return `#${((darkerR << 16) | (darkerG << 8) | darkerB) - .toString(16) - .padStart(6, "0")}`; - }; - - const isWidgetExist = (Id) => { - return signerPos.some((x) => x.Id === Id); - }; - +function SignerListPlace(props) { return (
Recipients
-
- <> - {signersdata.length > 0 && - signersdata.map((obj, ind) => { - return ( -
setIsHover(ind)} - onMouseLeave={() => setIsHover(null)} - key={ind} - style={ - isHover === ind || isSelectListId === ind - ? onHoverStyle(ind, obj.blockColor) - : nonHoverStyle(ind) - } - onClick={() => { - setSignerObjId(obj?.objectId); - setIsSelectId(ind); - setContractName(obj?.className); - setUniqueId(obj.Id); - setRoleName(obj.Role); - }} - > -
-
- - {isWidgetExist(obj.Id) ? ( - - ) : ( - <> - {obj.Name - ? getFirstLetter(obj.Name) - : getFirstLetter(obj.Role)} - - )} - -
-
- {obj.Name ? ( - - {obj.Name} - - ) : ( - <> - { - setIsEdit({ [obj.Id]: true }); - setRoleName(obj.Role); - }} - > - {isEdit?.[obj.Id] && handleRoleChange ? ( - handleRoleChange(e, obj.Id)} - onBlur={() => { - setIsEdit({}); - handleOnBlur(obj.Role, obj.Id); - }} - onKeyDown={(e) => { - if (e.key === "Enter") { - e.preventDefault(); - inputRef.current.blur(); - } - }} - /> - ) : ( - obj.Role - )} - - - )} - {obj.Email && ( - - {obj.Email} - - )} -
-
- {handleDeleteUser && ( -
{ - e.stopPropagation(); - handleDeleteUser(obj.Id); - }} - style={{ cursor: "pointer" }} - > - -
- )} -
-
- ); - })} - +
- {handleAddSigner && ( -
handleAddSigner()}> + {props.handleAddSigner && ( +
props.handleAddSigner()} + > Add role
diff --git a/microfrontends/SignDocuments/src/premitives/RecipientList.js b/microfrontends/SignDocuments/src/premitives/RecipientList.js new file mode 100644 index 000000000..9f533a849 --- /dev/null +++ b/microfrontends/SignDocuments/src/premitives/RecipientList.js @@ -0,0 +1,205 @@ +import React, { useRef, useState } from "react"; +import "../css/signerListPlace.css"; +import { darkenColor, getFirstLetter } from "../utils/Utils"; + +const RecipientList = (props) => { + const color = [ + "#93a3db", + "#e6c3db", + "#c0e3bc", + "#bce3db", + "#b8ccdb", + "#ceb8db", + "#ffccff", + "#99ffcc", + "#cc99ff", + "#ffcc99", + "#66ccff", + "#ffffcc" + ]; + + const nameColor = [ + "#304fbf", + "#7d5270", + "#5f825b", + "#578077", + "#576e80", + "#6d527d", + "#cc00cc", + "#006666", + "#cc00ff", + "#ff9900", + "#336699", + "#cc9900" + ]; + const [isHover, setIsHover] = useState(); + const [isEdit, setIsEdit] = useState(false); + //function for onhover signer name change background color + const inputRef = useRef(null); + const onHoverStyle = (ind, blockColor) => { + const style = { + background: blockColor ? blockColor : color[ind % color.length], + padding: "10px", + marginTop: "2px", + display: "flex", + flexDirection: "row", + borderBottom: "1px solid #e3e1e1", + alignItems: "center" + }; + return style; + }; + //function for onhover signer name remove background color + const nonHoverStyle = (ind) => { + const style = { + padding: "10px", + marginTop: "2px", + display: "flex", + flexDirection: "row", + borderBottom: "1px solid #e3e1e1", + alignItems: "center" + }; + return style; + }; + const isWidgetExist = (Id) => { + return props.signerPos.some((x) => x.Id === Id); + }; + + return ( + <> + {props.signersdata.length > 0 && + props.signersdata.map((obj, ind) => { + return ( +
setIsHover(ind)} + onMouseLeave={() => setIsHover(null)} + key={ind} + style={ + isHover === ind || props.isSelectListId === ind + ? onHoverStyle(ind, obj.blockColor) + : nonHoverStyle(ind) + } + onClick={() => { + props.setSignerObjId(obj?.objectId); + props.setIsSelectId(ind); + props.setContractName(obj?.className); + props.setUniqueId(obj.Id); + props.setRoleName(obj.Role); + }} + > +
+
+ + {isWidgetExist(obj.Id) ? ( + + ) : ( + <> + {obj.Name + ? getFirstLetter(obj.Name) + : getFirstLetter(obj.Role)} + + )} + +
+
+ {obj.Name ? ( + + {obj.Name} + + ) : ( + <> + { + setIsEdit({ [obj.Id]: true }); + props.setRoleName(obj.Role); + }} + > + {isEdit?.[obj.Id] && props.handleRoleChange ? ( + props.handleRoleChange(e, obj.Id)} + onBlur={() => { + setIsEdit({}); + props.handleOnBlur(obj.Role, obj.Id); + }} + onKeyDown={(e) => { + if (e.key === "Enter") { + e.preventDefault(); + inputRef.current.blur(); + } + }} + /> + ) : ( + obj.Role + )} + + + )} + {obj.Name && ( + + {obj.Role} + + )} +
+
+ {props.handleDeleteUser && ( +
{ + e.stopPropagation(); + props.handleDeleteUser(obj.Id); + }} + style={{ cursor: "pointer" }} + > + +
+ )} +
+
+ ); + })} + + ); +}; + +export default RecipientList; diff --git a/microfrontends/SignDocuments/src/premitives/SelectSigners.js b/microfrontends/SignDocuments/src/premitives/SelectSigners.js index 11eb5c053..88b188842 100644 --- a/microfrontends/SignDocuments/src/premitives/SelectSigners.js +++ b/microfrontends/SignDocuments/src/premitives/SelectSigners.js @@ -61,7 +61,7 @@ const SelectSigners = (props) => { // console.log("userList ", res); setUserList(res); return await res.map((item) => ({ - label: item.Name, + label: item.Email, value: item.objectId })); } diff --git a/microfrontends/SignDocuments/src/utils/Utils.js b/microfrontends/SignDocuments/src/utils/Utils.js index fab57658f..803d278d3 100644 --- a/microfrontends/SignDocuments/src/utils/Utils.js +++ b/microfrontends/SignDocuments/src/utils/Utils.js @@ -1046,3 +1046,29 @@ export const createDocument = async (template, placeholders, signerData) => { } } }; + +export const getFirstLetter = (name) => { + const firstLetter = name?.charAt(0); + return firstLetter; +}; + + +export const darkenColor = (color, factor) => { + // Remove '#' from the color code and parse it to get RGB values + const hex = color.replace("#", ""); + const r = parseInt(hex.substring(0, 2), 16); + const g = parseInt(hex.substring(2, 4), 16); + const b = parseInt(hex.substring(4, 6), 16); + + // Darken the color by reducing each RGB component + const darkerR = Math.floor(r * (1 - factor)); + const darkerG = Math.floor(g * (1 - factor)); + const darkerB = Math.floor(b * (1 - factor)); + + // Convert the darkened RGB components back to hex + return `#${((darkerR << 16) | (darkerG << 8) | darkerB) + .toString(16) + .padStart(6, "0")}`; +}; + +