From 002c8e61105d4b69551e948a15f8a6791a347916 Mon Sep 17 00:00:00 2001 From: JaiPandey425 Date: Thu, 7 Aug 2025 16:06:32 +0530 Subject: [PATCH] self_Sign & completion screen navigate to back & without email and lastname show error toast --- src/App.tsx | 1 - .../client/SignCompletionScreen.tsx | 28 ++++++- src/components/client/SignDocument.tsx | 49 ++++++++++-- src/components/contacts/Contacts.tsx | 6 +- .../DocumentCompletionScreen.tsx | 80 ++++++++++++++++++- .../process/processStepOne/ProcessStepOne.tsx | 25 ++++-- .../processStepOne/RecipientAddCard.tsx | 4 +- .../process/processStepOne/RecipientCards.tsx | 78 +++++++++--------- .../process/processStepTwo/NavTwo.tsx | 7 +- .../process/processStepTwo/ProcessStepTwo.tsx | 5 +- src/components/templates/Templates.tsx | 24 +++++- 11 files changed, 242 insertions(+), 65 deletions(-) diff --git a/src/App.tsx b/src/App.tsx index 0486a18..6a6a7e3 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -22,7 +22,6 @@ import Templates from "./components/templates/Templates"; import DocumentCompletionScreen from "./components/process/CompletionScreen/DocumentCompletionScreen"; import JoyrideController from "./utlity/JoyRideTour"; import Contacts from "./components/contacts/Contacts"; - const App = () => { return ( diff --git a/src/components/client/SignCompletionScreen.tsx b/src/components/client/SignCompletionScreen.tsx index 2038f29..31a2d33 100644 --- a/src/components/client/SignCompletionScreen.tsx +++ b/src/components/client/SignCompletionScreen.tsx @@ -17,6 +17,32 @@ const SignCompletionScreen: React.FC = () => { const [showDownloadModal, setShowDownloadModal] = useState(false); const [animationPhase, setAnimationPhase] = useState(0); + + useEffect(() => { + const currentPath = window.location.pathname; + + const handlePopState = (event) => { + // Show warning + // alert("Back navigation is blocked on this screen."); + + // Push the current URL back to prevent navigating away + window.history.pushState(null, "", currentPath); + }; + + // Push extra states to build history buffer + for (let i = 0; i < 50; i++) { + window.history.pushState(null, "", currentPath); + } + + // Add popstate listener + window.addEventListener("popstate", handlePopState); + + // Cleanup on unmount + return () => { + window.removeEventListener("popstate", handlePopState); + }; + }, []); + useEffect(() => { // Trigger animation phases sequentially const timers = [ @@ -321,7 +347,7 @@ const SignCompletionScreen: React.FC = () => { {/* Additional Info */}

- Your document is signed and ready. You can download it or return to the sign made easy. + Your document is signed and saved. Download it or return to Sign Made Easy to continue — navigation is paused until an action is taken.

diff --git a/src/components/client/SignDocument.tsx b/src/components/client/SignDocument.tsx index 3944d11..05cbad2 100644 --- a/src/components/client/SignDocument.tsx +++ b/src/components/client/SignDocument.tsx @@ -161,6 +161,7 @@ const SignDocument = () => { const [stamp, setStamp] = useState({ open: false, blob: "" }); + console.log(recSignStatus, "recSignStatus") // Handling Date Opacity const [dateValues, setDateValues] = useState<{ [key: string]: string }>({}); @@ -261,6 +262,8 @@ const SignDocument = () => { } }, [saved]) + + const handleSignClick = (index: number, id: number) => { setSignTagId(id) if (saved.save) { @@ -305,6 +308,35 @@ const SignDocument = () => { } } + // Step 2: Prevent browser back when status === 'COMPLETED' + // useEffect(() => { + // if (recSignStatus !== "COMPLETED") return; + + // const currentPath = window.location.pathname; + + // const handlePopState = (event) => { + // // Show warning + // alert("Back navigation is blocked on this screen."); + + // // Push the current URL back to prevent navigating away + // window.history.pushState(null, "", currentPath); + // }; + + // // Push extra states to build history buffer + // for (let i = 0; i < 50; i++) { + // window.history.pushState(null, "", currentPath); + // } + + // // Add popstate listener + // window.addEventListener("popstate", handlePopState); + + // // Cleanup on unmount + // return () => { + // window.removeEventListener("popstate", handlePopState); + // }; + // }, [recSignStatus]); + + const fetchData = (isSign: boolean = false) => { axios.get(`${import.meta.env.VITE_BASE_URI}/api/sign?recipientId=${recipientId}`, { @@ -315,17 +347,17 @@ const SignDocument = () => { if (res.status === 200) { - setSelectedDocuments(res.data.documents) - setRecipient(res.data.details) - setDroppedItems(res.data.tagJsons) - setTransaction(res.data.transaction) - setRecSignStatus(res.data.status) + setSelectedDocuments(res?.data?.documents) + setRecipient(res?.data?.details) + setDroppedItems(res?.data?.tagJsons) + setTransaction(res?.data?.transaction) + setRecSignStatus(res?.data?.status) - if ("provideOwnTags" in res.data.details && res.data.details.provideOwnTags) { + if ("provideOwnTags" in res?.data?.details && res?.data?.details.provideOwnTags) { setProvideTags(true) } - if (res.data.status === "COMPLETED") { + if (res?.data?.status === "COMPLETED") { setShowCompletionScreen(true) } @@ -337,6 +369,7 @@ const SignDocument = () => { }) .catch((err) => { + console.log(err) }); } @@ -867,6 +900,8 @@ const SignDocument = () => { }; + + // const [showTerms, setShowTerms] = useState(true); return (
diff --git a/src/components/contacts/Contacts.tsx b/src/components/contacts/Contacts.tsx index 655e92e..ff45d09 100644 --- a/src/components/contacts/Contacts.tsx +++ b/src/components/contacts/Contacts.tsx @@ -134,7 +134,7 @@ const Contacts = () => {
-
+
@@ -162,7 +162,7 @@ const Contacts = () => { ) : ( - contacts.map((contact) => ( + contacts.map((contact, index) => ( @@ -181,7 +181,7 @@ const Contacts = () => { {openMenuId === contact.id && ( -
+
- - + + {/* Dropdown Trigger + Tooltip */}
{contact.firstName} {contact.lastName}{item.name || 'Untitled'}{formatDate(item.createdAt)}{formatDate(item.lastModifiedAt)}{formatTimestamp(item.createdAt)}{formatTimestamp(item.lastModifiedAt)} handleUseClick(item)}>Use @@ -173,7 +189,7 @@ const Templates = () => { {showMenu === index && (
{ // Ensure it only closes if focus truly leaves the container @@ -183,7 +199,7 @@ const Templates = () => { }} >