diff --git a/src/components/client/SignDocument.tsx b/src/components/client/SignDocument.tsx index 3944d11..8fb09d8 100644 --- a/src/components/client/SignDocument.tsx +++ b/src/components/client/SignDocument.tsx @@ -1,4 +1,4 @@ -import { useEffect, useState } from "react"; +import { useEffect, useLayoutEffect, useState } from "react"; import axios from "axios" import { RootState } from "../../store/store"; @@ -26,6 +26,8 @@ import typeToIconMap from "../../helper/iconMap"; import { droppedTagsDefaultField } from "../process/processStepTwo/DocumentContainer"; import SignCompletionScreen from "./SignCompletionScreen"; import api from "../../config/api"; +import RightSideBar from "../process/processStepTwo/rightSideBar/RightSideBar"; +import { RiDragMoveFill } from "react-icons/ri"; @@ -139,12 +141,6 @@ const fitObj = [ const SignDocument = () => { - useEffect(() => { - axios.get("https://concrete-gladly-mullet.ngrok-free.app/api/sign/session?recipientId=103&sessionId=iqlo2inofsqaqib8mcos4njssj").then((res) => { - console.log(res, "RESPONSE") - }) - }, []) - const { recipientId } = useParams(); const dispatch = useDispatch(); @@ -234,6 +230,8 @@ const SignDocument = () => { }, [droppedItems]) + console.log(droppedItems, "{droppedItems[selectedTag.key][selectedTag.index]}") + useEffect(() => { if (recSignStatus === "COMPLETED") { // setHideTags(true); @@ -686,6 +684,7 @@ const SignDocument = () => { // } if (prepData.type.toLowerCase() === TagsTypes.SIGNATURE || prepData.type.toLowerCase() === TagsTypes.INITIALS) { + const currDocTags = droppedItems.filter((val) => val.pageIndex === prepData.pageIndex) setSignConfObj({ ...signConfObj, @@ -1012,7 +1011,6 @@ const SignDocument = () => { doc.pages && doc.pages.length > 0 && doc.pages.map((page, indx) => { const key = `${doc.documentId}_${page.index}`; // const tagJsonData = [...droppedItems]; - const currDocTags = droppedItems.filter((val) => val.pageIndex === page.index) return (
{ @@ -1103,7 +1114,7 @@ const SignDocument = () => { >
} { - item.subType === "PARAGRAPH" &&{ const val = e.currentTarget.textContent; handleTagUpdate(index, val as string); @@ -1114,7 +1125,7 @@ const SignDocument = () => {
} { - item.subType === "PASSWORD" && item.mask &&{ const val = e.currentTarget.textContent; handleTagUpdate(index, val as string); @@ -1122,13 +1133,13 @@ const SignDocument = () => { onKeyDown={(e) => { if (e.key === "Enter") e.preventDefault(); }} - onFocus={() => { - }} + // onFocus={() => { + // }} onBlur={(e) => { let val = e.target.textContent; - if (typeof item.mask?.maskType === "string" && typeof val === "string") { + if (typeof item.maskType === "string" && typeof val === "string") { val = val.replace(/ /g, ""); - e.target.textContent = maskUtils((item.mask as { maskType: string }).maskType, val, (item.mask as { maskCharacter: string }).maskCharacter) + e.target.textContent = maskUtils(item.maskType, val, item.maskCharacter) } }} contentEditable={true} @@ -1139,6 +1150,125 @@ const SignDocument = () => { } {/* TEXT FIELD - END */} + {/* EMAIL FIELD - START */} + { + item.type === "EMAIL" && +
{ + const val = e.currentTarget.textContent; + handleTagUpdate(index, val as string); + }} + onKeyDown={(e) => { + if (e.key === "Enter") { + const val = e.currentTarget.textContent?.trim() || ""; + const emailRegex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/; + + if (val && !emailRegex.test(val)) { + alert("Please enter a valid email address"); + handleTagUpdate(index, "" as string) + e.currentTarget.textContent = ""; + e.currentTarget.focus(); // Optional: return focus if invalid + } + e.preventDefault() + }; + }} + + onBlur={(e) => { + const val = e.currentTarget.textContent?.trim() || ""; + const emailRegex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/; + + if (val && !emailRegex.test(val)) { + alert("Please enter a valid email address"); + handleTagUpdate(index, "" as string) + e.currentTarget.textContent = ""; + e.currentTarget.focus(); // Optional: return focus if invalid + } + }} + contentEditable={true} + className="outline-none whitespace-nowrap w-full max-h-max" + >
+ } +{ + const val = e.currentTarget.textContent; + handleTagUpdate(index, val as string); + }} + onKeyDown={(e) => { + if (e.key === "Enter") { + e.preventDefault() + }; + }} + + onBlur={(e) => { + + }} + contentEditable={true} + className="outline-none whitespace-nowrap w-full max-h-max" + >
+ } +{ + const val = e.currentTarget.textContent; + handleTagUpdate(index, val as string); + }} + onKeyDown={(e) => { + if (e.key === "Enter") { + e.preventDefault() + }; + }} + + onBlur={(e) => { + + }} + contentEditable={true} + className="outline-none whitespace-nowrap w-full max-h-max" + >
+ } +{focusElement.label}
-{focusElement.label}
+
page {indx + 1} of {doc.pages && doc.pages.length}
@@ -1188,17 +1205,16 @@ const DocumentContainer: React.FC