MCPcopy Index your code
hub / github.com/OpenSignLabs/OpenSign / handleAddUser

Function handleAddUser

apps/OpenSign/src/pages/PlaceHolderSign.jsx:1615–1670  ·  view source on GitHub ↗
(data, signerObjId, signerRole)

Source from the content-addressed store, hash-verified

1613 };
1614 //`handleAddUser` function to use add new user
1615 const handleAddUser = (data, signerObjId, signerRole) => {
1616 const id = signerObjId ? signerObjId : uniqueId;
1617 setRoleName("");
1618 setCurrWidgetsDetails({});
1619 let assignedId = id;
1620 if (isAddSigner) {
1621 assignedId = handleAddNewRecipients(data, signerRole);
1622 } else {
1623 if (data && data.objectId) {
1624 const signerPtr = {
1625 __type: "Pointer",
1626 className: "contracts_Contactbook",
1627 objectId: data.objectId
1628 };
1629 const updatePlaceHolder = signerPos.map((x) => {
1630 if (x.Id === id || x.signerObjId === id) {
1631 const updated = {
1632 ...x,
1633 signerPtr,
1634 signerObjId: data.objectId
1635 };
1636
1637 // Only update email if it already exists in `x`
1638 if ("email" in x) {
1639 updated.email = data?.Email || ""; // keep old if no new email
1640 }
1641
1642 return updated;
1643 }
1644 return { ...x };
1645 });
1646 setSignerPos(updatePlaceHolder);
1647 const updateSigner = signersdata.map((x) => {
1648 if (x.Id === id || x.objectId === id) {
1649 return { ...x, ...data, className: "contracts_Contactbook" };
1650 }
1651 return { ...x };
1652 });
1653 if (updateSigner && updateSigner.length > 0) {
1654 const currEmail = pdfDetails[0].ExtUserPtr.Email;
1655 const getCurrentUserDeatils = updateSigner.filter(
1656 (x) => x.Email === currEmail
1657 );
1658 if (getCurrentUserDeatils && getCurrentUserDeatils.length > 0) {
1659 setCurrentId(getCurrentUserDeatils[0].Email);
1660 }
1661 }
1662 setSignersData(updateSigner);
1663 const index = updateSigner.findIndex(
1664 (x) => x.Id === id || x.objectId === id
1665 );
1666 setIsSelectId(index);
1667 }
1668 }
1669 return assignedId;
1670 };
1671 //function to add new signer in document signers list
1672 const handleAddNewRecipients = (data, signerRole) => {

Callers 1

handleAddFunction · 0.50

Calls 1

handleAddNewRecipientsFunction · 0.85

Tested by

no test coverage detected