diff --git a/src/SigningOrderDiagram .tsx b/src/SigningOrderDiagram .tsx index c9fe0b5..f04f611 100644 --- a/src/SigningOrderDiagram .tsx +++ b/src/SigningOrderDiagram .tsx @@ -1,5 +1,5 @@ import React from "react"; -import { FaCheck, FaLock, FaClock, FaEnvelope, FaTimes } from "react-icons/fa"; +import { FaCheck, FaLock, FaClock, FaEnvelope, FaTimes, FaUserTimes } from "react-icons/fa"; import { IoCloseOutline } from "react-icons/io5"; type Signer = { @@ -48,8 +48,10 @@ const groupByRoutingOrder = (data: Signer[]) => { }; const getInitials = (name: string) => { + if (!name.trim()) return ""; return name .split(" ") + .filter(n => n) .map((n) => n[0].toUpperCase()) .join(""); }; @@ -63,6 +65,8 @@ const SigningOrderDiagram : React.FC = (signers) => { .map(Number) .sort((a, b) => a - b); + console.log("sortedOrders",sortedOrders,grouped) + const currentProcessingOrder = sortedOrders.find((order) => grouped[order].some((signer) => !signer.completed) @@ -109,14 +113,14 @@ const SigningOrderDiagram : React.FC = (signers) => {
- {getInitials(signer.name)} + {(signer?.name !== '' || signer?.roleName) ? getInitials(signer?.name || signer?.roleName) : ""} {icon}
-

{signer.name.split(" ")[0]}

+

{(signer?.name?.split(" ")[0] || signer?.roleName)}

); })} diff --git a/src/components/process/CompletionScreen/DocumentCompletionScreen.tsx b/src/components/process/CompletionScreen/DocumentCompletionScreen.tsx index 9fca64a..251cbd2 100644 --- a/src/components/process/CompletionScreen/DocumentCompletionScreen.tsx +++ b/src/components/process/CompletionScreen/DocumentCompletionScreen.tsx @@ -1,17 +1,29 @@ -import React, { useEffect, useState } from "react"; +import React, { useState, useEffect } from 'react'; import { + FaArrowLeft, FaCheck, - FaFileAlt, + FaExternalLinkAlt, + FaEye, + FaEyeSlash, + FaRedo, + FaImage, FaUsers, + FaFileAlt, FaEnvelope, - FaClock, + FaCog, + FaShieldAlt, + FaBell, FaDownload, FaShare, - FaShieldAlt, - FaLock, - FaPen, - FaCheckCircle + FaEdit, + FaSave, + FaClock, + FaLock } from 'react-icons/fa'; + +import { RootState } from '../../../store/store'; + +import api from '../../../config/api'; import { fetchRecipients } from "../../../store/slices/selectedRecipientsSlice"; import { fetchDocuments } from "../../../store/slices/documentSlice"; import { useDispatch, useSelector } from "react-redux"; @@ -21,7 +33,7 @@ import confetti from 'canvas-confetti' import { IoClose } from "react-icons/io5"; import { IoMdClose, IoMdHome } from "react-icons/io"; import { Bounce, toast } from "react-toastify"; -import api from "../../../config/api"; + type Signer = { id: number; @@ -34,7 +46,7 @@ type Signer = { // Signers List Component const SignersList: React.FC<{ signers: Signer[] }> = ({ signers }) => { return ( -
+

@@ -112,7 +124,7 @@ const SigningOrderDiagram: React.FC<{ signers: Signer[] }> = ({ signers }) => {

Signing Flow

-
+
{/* Mail icon */}
@@ -163,7 +175,7 @@ const SigningOrderDiagram: React.FC<{ signers: Signer[] }> = ({ signers }) => {

- {signer.name.split(" ")[0]} + {signer.name.split(" ")[0] || signer.firstName.split(0,1)}

); @@ -185,22 +197,7 @@ const SigningOrderDiagram: React.FC<{ signers: Signer[] }> = ({ signers }) => {
); }; - -// Main DocumentCompletionScreen Component -const DocumentCompletionScreen = () => { - const documentList = [ - { title: 'Document 1', pages: 12 }, - { title: 'Document 2', pages: 8 }, - { title: 'Document 3', pages: 5 }, - { title: 'Document 4', pages: 22 }, - { title: 'Document 5', pages: 10 }, - { title: 'Document 6', pages: 15 }, - { title: 'Document 7', pages: 7 }, - { title: 'Document 8', pages: 9 }, - { title: 'Document 9', pages: 6 }, - { title: 'Document 10', pages: 11 }, - { title: 'Document 11', pages: 4 }, // Won't be shown due to slice - ]; +const DocumentSubmissionOptions = () => { const location = useLocation(); const [status, setStatus] = useState(null); console.log("location.pathname", location.pathname, status) @@ -218,6 +215,8 @@ const DocumentCompletionScreen = () => { const selectedRecipients = useSelector((state: RootState) => state.selectedRecipients.recipients); // const selectedDocuments = useSelector((state: RootState) => state.selectedDocuments.selectedDocuments) const selectedDocuments = useSelector((state: RootState) => state.documents.documents) + console.log('Line 218', selectedDocuments) + const [transactionData,setTransactionData] = useState({}) useEffect(() => { @@ -277,7 +276,10 @@ const DocumentCompletionScreen = () => { // /api/accounts/{accountId}/transactions/{trxId} try { const res = await api.get(`/api/accounts/${accountId}/transactions/${transactionId}`); - setStatus(res?.data?.status); + if (res?.data) { + setStatus(res?.data?.status); + setTransactionData(res?.data) + } } catch (error) { console.error("Failed to fetch transaction:", error); } @@ -292,140 +294,251 @@ const DocumentCompletionScreen = () => { useEffect(() => { if (status === "SENT") { - const currentPath = window.location.pathname; + const currentPath = window.location.pathname; - const handlePopState = (event) => { - // Show warning - alert("Back navigation is blocked on this screen."); + 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 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); + // 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); + }; } - - // Add popstate listener - window.addEventListener("popstate", handlePopState); - - // Cleanup on unmount - return () => { - window.removeEventListener("popstate", handlePopState); - }; - } }, [status]); -// useEffect(() => { -// if (status === 'SENT') { -// // Step 1: Push a dummy state to trap the user -// window.history.pushState(null, '', window.location.href); + // useEffect(() => { + // if (status === 'SENT') { + // // Step 1: Push a dummy state to trap the user + // window.history.pushState(null, '', window.location.href); -// // Step 2: Intercept back button -// const handlePopState = (event) => { -// // Push the same dummy state again to block back -// window.history.pushState(null, '', window.location.href); -// }; + // // Step 2: Intercept back button + // const handlePopState = (event) => { + // // Push the same dummy state again to block back + // window.history.pushState(null, '', window.location.href); + // }; -// window.addEventListener('popstate', handlePopState); + // window.addEventListener('popstate', handlePopState); -// return () => { -// window.removeEventListener('popstate', handlePopState); -// }; -// } -// }, [status]); + // return () => { + // window.removeEventListener('popstate', handlePopState); + // }; + // } + // }, [status]); + const [selectedOption, setSelectedOption] = useState('success'); + const [isVisible, setIsVisible] = useState(false); + const [previewData, setPreviewData] = useState({ + documentName: "Contract Agreement.pdf", + submissionCount: 1, + signerName: "Sumit Kumar", + signerEmail: "sumit.kumar@hicglobalsolutions.com", + submissionTime: new Date().toLocaleString() + }); + useEffect(() => { + setIsVisible(true); + }, []); + const options = [ + { + id: 'success', + icon: FaCheck, + title: 'Success screen', + description: 'Display confirmation message after successful document submission', + color: 'bg-green-50 border-green-200 hover:bg-green-100', + iconColor: 'text-green-600', + isPremium: false + }, + { + id: 'redirect', + icon: FaExternalLinkAlt, + title: 'Signing Flow', + description: 'Navigate user to view their transaction details', + color: 'bg-blue-50 border-blue-200 hover:bg-blue-100', + iconColor: 'text-blue-600', + isPremium: true + }, + { + id: 'public', + icon: FaEye, + title: 'Signature status', + description: 'Show transaction status on public dashboard', + color: 'bg-purple-50 border-purple-200 hover:bg-purple-100', + iconColor: 'text-purple-600', + isPremium: true + }, + ]; + const getPreviewContent = () => { + switch (selectedOption) { + case 'success': + return ( +
+
+ +
+
+

Document Send Successfully!

+ {selectedDocuments?.map((docs) => ( +

Your document "{docs.name}" has been sent for signature.

+ ) )} +
+
+
+ createdBy: + {transactionData?.createdBy?.name} +
+
+ Email: + {transactionData?.createdBy?.email} +
+
+ createdAt: + {transactionData.createdAt} +
+
+
+ ); + case 'redirect': + return ( + <> + + + + ); + case 'public': + return ( + <> + + + ); + default: + return null; + } + }; return ( - <> -
- {/* Top Banner */} -
-
- - - -

🎉 Awesome! The document’s been sent for signature. 🎉

-
+
+
-
- - - {/* */} - View Transaction - - - {/* */} - -
+ {/* Header */} +
+ +
+

🎉 Awesome! The document’s been sent for signature. 🎉

+ {/*
*/} +
+ {/* Left Panel - Configuration */} +
+ {/* Action Selection */} +
+
+

+ Choose an action after a signer completes the document. +

- {(selectedRecipients.length > 0 && selectedDocuments.length > 0) ? -
-
- {/* Header */} -
- {/* Left Section - Document Details */} -
- {/* Document Preview Card */} -
-
- {selectedDocuments?.map((item, index) => ( -
-
-
- {/* */} - document -
-
-

- Name : {item.name ?? '--'} -

-
- Status : {item.status ?? '--'} -
- +
+ {options.map((option) => { + const Icon = option.icon; + const isSelected = selectedOption === option.id; + + return ( +
setSelectedOption(option.id)} + className={` + relative cursor-pointer p-4 rounded-xl border-2 transition-all duration-200 group + ${isSelected + ? 'border-[var(--primary)] bg-blue-50 shadow-md scale-[1.02]' + : option.color + ' border-2' + } + hover:shadow-md hover:scale-[1.01] transform + `} + > +
+
+ +
+
+
+

+ {option.title} +

+ {option.isPremium && ( + ★ + )}
+

+ {option.description} +

- ))} -
-
-
+ {/* Selection indicator */} + {isSelected && ( +
+
+ +
+
+ )} +
+ ); + })}
+
+
- {/* Right Section - Signer Components */} -
- {/* Signing Order Diagram */} - + {/* Custom Image Section */} +
- {/* Signers List */} + {/* Right Panel - Preview */} +
+
+
+

Live Preview

+

See how your users will experience the completion

+
+
+
+ {getPreviewContent()}
- : } +
- +
); }; -export default DocumentCompletionScreen; \ No newline at end of file +export default DocumentSubmissionOptions; \ No newline at end of file