diff --git a/src/components/client/SignCompletionScreen.tsx b/src/components/client/SignCompletionScreen.tsx index 3ecd120..2038f29 100644 --- a/src/components/client/SignCompletionScreen.tsx +++ b/src/components/client/SignCompletionScreen.tsx @@ -301,7 +301,7 @@ const SignCompletionScreen: React.FC = () => { > {/* */} - Back Sign Made Easy + Back to Sign Made Easy {/* */} : { + + 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(); @@ -151,7 +161,6 @@ const SignDocument = () => { const [stamp, setStamp] = useState({ open: false, blob: "" }); - console.log(recipient, "recipient Line 145") // Handling Date Opacity const [dateValues, setDateValues] = useState<{ [key: string]: string }>({}); @@ -179,6 +188,7 @@ const SignDocument = () => { const [showCompletionScreen, setShowCompletionScreen] = useState(false) const [saved, setSaved] = useState({ + signatureId: null, saveType: null, save: false, signature: null, @@ -190,7 +200,6 @@ const SignDocument = () => { const [signConfObj, setSignConfObj] = useState({}); - console.log("signConfObj", signConfObj) const zoom = (percentage: number, contentClass: string) => { const content = document.querySelector(`.${contentClass}`); @@ -224,15 +233,12 @@ const SignDocument = () => { } }, [droppedItems]) - console.log(saved, "Line 162") useEffect(() => { if (recSignStatus === "COMPLETED") { - console.log("SETTING HIDE TAGS to TRUE LIne 161") // setHideTags(true); setTransparentTags(true); } else { - console.log("SETTING HIDE TAGS to TRUE LIne 161") setHideTags(false); } }, [recSignStatus]) @@ -256,7 +262,6 @@ const SignDocument = () => { }, [saved]) const handleSignClick = (index: number, id: number) => { - console.log("IDNumber", id) setSignTagId(id) if (saved.save) { if (index in signConfObj) { @@ -287,7 +292,6 @@ const SignDocument = () => { const handleStampClick = (index: number) => { - console.log("Stamp Clicked", index) setStamp({ open: true, blob: "" @@ -308,10 +312,8 @@ const SignDocument = () => { { "ngrok-skip-browser-warning": "69420", } }) .then((res) => { - console.dir(res) if (res.status === 200) { - console.log(res, "Line 288") setSelectedDocuments(res.data.documents) setRecipient(res.data.details) @@ -323,7 +325,7 @@ const SignDocument = () => { setProvideTags(true) } - if (res.data.status ==="COMPLETED" ) { + if (res.data.status === "COMPLETED") { setShowCompletionScreen(true) } @@ -335,12 +337,10 @@ const SignDocument = () => { }) .catch((err) => { - console.error(err.message) }); } - console.log(droppedItems, "Line 261") const handleFormSubmit = (e: React.FormEvent) => { e.preventDefault(); @@ -366,7 +366,6 @@ const SignDocument = () => { } } - console.log(signInitialsCount, Object.keys(signConfObj).length, "boom") if (signInitialsCount !== Object.keys(signConfObj).length) { toast.error("Please ensure all signature and initials are signed", { @@ -384,7 +383,6 @@ const SignDocument = () => { } for (const tag of droppedItems) { - console.log(tag, "Tag Data") // if ((tag.type === "SIGNATURE" || tag.subType === "INITIALS") && !tag.value) { if (("required" in tag && tag.required) && ((tag.type !== "SIGNATURE" && tag.type !== "INITIALS") && (tag.value === "" || !("value" in tag)))) { @@ -460,9 +458,6 @@ const SignDocument = () => { dispatch(showLoader("Signing ...")); axios.post(`${import.meta.env.VITE_BASE_URI}/api/sign?recipientId=${recipientId}`, submitData, { headers: { "ngrok-skip-browser-warning": "69420", } }) .then((res) => { - console.group("Submitting Sign Details"); - console.dir(res); - console.groupEnd(); if (res.status === 200) { setTransparentTags(true) setTimeout(() => { @@ -486,7 +481,6 @@ const SignDocument = () => { } }) .catch((err) => { - console.error(err.message) } ) }; @@ -538,11 +532,9 @@ const SignDocument = () => { headers: { "ngrok-skip-browser-warning": "69420" } }); if (response.status === 200) { - console.log("line 516", response.data) return response.data; } } catch (error) { - console.error("Error fetching signature data:", error); } return null; } @@ -552,9 +544,7 @@ const SignDocument = () => { // if (droppedItems) { // for (const tag of droppedItems) { // if (tag.type === "SIGNATURE" && "value" in tag) { - // console.log(tag, "line 533") // const signatureData = await fetchSignatureData(tag["value"]); - // console.log("Currnet Signature",signatureData); // } // } // } @@ -588,7 +578,6 @@ const SignDocument = () => { // HANDLE DROP - START const handleDrop = (event: React.DragEvent, docId: string, documentId: number, pageIndex: number) => { - console.log("// HANDLE DROP - START") event.preventDefault(); const data = window.dragElemData; @@ -763,7 +752,6 @@ const SignDocument = () => { left = Math.max(0, Math.min(left, conScrollWidth - elementRect.width)); top = Math.max(0, Math.min(top, conScrollHeight - elementRect.height)); - console.log(left, top, "LEFTTOP") if (groupElements != null && groupElements.length) handleGroupBorderPosition(groupElements, containerRect, offsetX, offsetY); @@ -791,18 +779,17 @@ const SignDocument = () => { // Updated handleRemoveTag function with your existing API logic and group handling const handleRemoveTag = (key: string, targetIndex: number) => { - console.log(droppedItems, "Line 784") - const tag = droppedItems[key][targetIndex]; const recipientId = tag.recipientId; + console.log(tag, "line 776"); + (async () => { if ("id" in tag) { try { const response = await api.delete(`/api/accounts/${accountId}/${transactionTemplateToggle}/${transactionId}/recipients/${recipientId}/tags/${tag.id}`) if (response.status !== 200) throw "Tag Deletion error" } catch (err) { - console.error("Tag Deletion error") return; } } @@ -826,7 +813,6 @@ const SignDocument = () => { if (isParentItem && groupItems.length > 1) { // If removing the parent and there are child items, mark all items in the group as deleted - console.log(`Removing parent item and all children for group: ${groupId}`); // Get indices of all group items to mark as deleted const indicesToDelete = groupItems.map(({ index }) => index); @@ -845,7 +831,6 @@ const SignDocument = () => { } else { // If removing a child item or the only item in group, just mark this item as deleted - console.log(`Removing individual item from group: ${groupId}`); setDroppedItems(prevState => ({ ...prevState, @@ -881,14 +866,13 @@ const SignDocument = () => { })() }; - console.log(droppedItems, "DROPPED ITEMS LINE 680") // const [showTerms, setShowTerms] = useState(true); return (
<> {/* */} - {showCompletionScreen && } + {showCompletionScreen && }
) => handleFormSubmit(e)} > @@ -1017,7 +1001,6 @@ const SignDocument = () => { { selectedDocuments && selectedDocuments.length > 0 && selectedDocuments.map((doc) => { - console.log(droppedItems, "tagJsontagJsontagJson") return (
@@ -1028,12 +1011,9 @@ const SignDocument = () => { { doc.pages && doc.pages.length > 0 && doc.pages.map((page, indx) => { const key = `${doc.documentId}_${page.index}`; - console.log(droppedItems, "line 820") // const tagJsonData = [...droppedItems]; - // console.log(tagJsonData, "Line 821") const currDocTags = droppedItems.filter((val) => val.pageIndex === page.index) - console.log(currDocTags, droppedItems, page, doc, "innnnnnnnnnnnn") return (
{ {currDocTags.map((item, index) => { - console.log(item, "micCheck 842") - if (item.pageIndex !== page.index) return; + if (item.pageIndex !== page.index || item.documentId != doc.documentId) return <>; return ( + <> -
setFocusElement({ ...item, focusElementIndx: index })} - key={item.id} - // draggable="false" - onPointerDown={(e) => handleTagMouseDown(e, key, index)} - className="absolute rounded dropped-item text-sm" - // onClick={() => handleTagClick(key, index)} - style={{ - left: `${item.dimensions.left}px`, - top: `${item.dimensions.top}px`, - width: `${item.dimensions.width}px`, - height: `${item.dimensions.height}px`, - border: `${((!hideTags && focusElement) && !transparentTags && focusElement.documentId === item.documentId && focusElement.focusElementIndx === index) ? '2px dashed #1c398e' : 'none'}`, - // display: `${hideTags ? 'none' : 'block'}` - }} - > +
setFocusElement({ ...item, focusElementIndx: index })} + key={item.id} + // draggable="false" + onPointerDown={(e) => handleTagMouseDown(e, key, index)} + className="absolute rounded dropped-item text-sm" + // onClick={() => handleTagClick(key, index)} + style={{ + left: `${item.dimensions.left}px`, + top: `${item.dimensions.top}px`, + width: `${item.dimensions.width}px`, + height: `${item.dimensions.height}px`, + border: `${((!hideTags && focusElement) && !transparentTags && focusElement.documentId === item.documentId && focusElement.focusElementIndx === index) ? '2px dashed #1c398e' : 'none'}`, + // display: `${hideTags ? 'none' : 'block'}` + }} + > - <> - {selectedTag?.key && selectedTag.key === key && selectedTag.index === index && -
-
-

-

- {/*

+ {selectedTag?.key && selectedTag.key === key && selectedTag.index === index && +

+
+

+

+ {/*

{IconComponent}

*/} -

{item.label}

- { - e.stopPropagation(); - handleRemoveTag(key, index) - }} className='cursor-pointer' /> -
-
} - +

{item.label}

+ { + console.log("Handle Remove Tag Called"); - {/* TEXT FIELD - START */} - { - item.type === "TEXT" && -
+ e.stopPropagation(); + handleRemoveTag(key, index) + }} className='cursor-pointer' /> +
+
} + - {/* + + {/* */} - { - item.subType === "SINGLE_LINE" &&

{ + const val = e.currentTarget.textContent; + handleTagUpdate(index, val as string); + }} + onKeyDown={(e) => { + if (e.key === "Enter") e.preventDefault(); + }} + contentEditable={true} + className="outline-none whitespace-nowrap w-full max-h-max" + >

+ } + { + item.subType === "PARAGRAPH" &&

{ + const val = e.currentTarget.textContent; + handleTagUpdate(index, val as string); + }} + contentEditable={true} + className="w-full outline-none max-h-max" + > +

+ } + { + item.subType === "PASSWORD" && item.mask &&

{ + const val = e.currentTarget.textContent; + handleTagUpdate(index, val as string); + }} + onKeyDown={(e) => { + if (e.key === "Enter") e.preventDefault(); + }} + onFocus={() => { + }} + onBlur={(e) => { + let val = e.target.textContent; + if (typeof item.mask?.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) + } + }} + contentEditable={true} + className="outline-none whitespace-nowrap w-full max-h-max" + >

+ } +
+ } + {/* TEXT FIELD - END */} + + + {/* CHECKBOX FIELD - START */} + { + item.type === "CHECKBOX" && +
+ { - const val = e.currentTarget.textContent; - handleTagUpdate(index, val as string); - }} - onKeyDown={(e) => { - if (e.key === "Enter") e.preventDefault(); - }} - contentEditable={true} - className="outline-none whitespace-nowrap w-full max-h-max" - >

- } - { - item.subType === "PARAGRAPH" &&

{ - const val = e.currentTarget.textContent; - handleTagUpdate(index, val as string); - }} - contentEditable={true} - className="w-full outline-none max-h-max" - > -

- } - { - item.subType === "PASSWORD" && item.mask &&

{ - const val = e.currentTarget.textContent; - handleTagUpdate(index, val as string); - }} - onKeyDown={(e) => { - if (e.key === "Enter") e.preventDefault(); - }} - onFocus={() => { - console.log("focus") - }} - onBlur={(e) => { - let val = e.target.textContent; - console.log(item.mask, val, "Line 586") - if (typeof item.mask?.maskType === "string" && typeof val === "string") { - val = val.replace(/ /g, ""); - console.log("onBlur", item.mask.maskCharacter, maskUtils((item.mask as { maskType: string }).maskType, val, (item.mask as { maskCharacter: string }).maskCharacter)) - e.target.textContent = maskUtils((item.mask as { maskType: string }).maskType, val, (item.mask as { maskCharacter: string }).maskCharacter) - } - }} - contentEditable={true} - className="outline-none whitespace-nowrap w-full max-h-max" - >

- } -
- } - {/* TEXT FIELD - END */} + className="w-full px-2 outline-none" + type="checkbox" /> +
+ } + {/* CHECKBOX FIELD - END */} - {/* CHECKBOX FIELD - START */} - { - item.type === "CHECKBOX" && -
- -
- } - {/* CHECKBOX FIELD - END */} + {/* SIGNATURE FIELD - START */} + { + item.type === "SIGNATURE" && +
handleSignClick(index, item.id)} + className={`flex justify-center items-center h-full w-full rounded cursor-pointer ${transparentTags || hideTags ? "pointer-events-none bg-transparent" : "bg-slate-200 shadow-sm border-slate-100 opacity-80"}`} + // style={{ height: item.dimensions.height + "px" }} + > + {/* */} + { + (!transparentTags && !hideTags && !(saved.save && (index in signConfObj && signConfObj[index].accepted))) ? + <> + + + : + + src={`data:image/png;base64,${saved.signature}`} + /> + } +
+ } + {/* SIGNATURE FIELD - END */} - {/* SIGNATURE FIELD - START */} - { - item.type === "SIGNATURE" && -
handleSignClick(index, item.id)} - className={`flex justify-center items-center h-full w-full rounded cursor-pointer ${transparentTags || hideTags ? "pointer-events-none bg-transparent" : "bg-slate-200 shadow-sm border-slate-100 opacity-80"}`} - // style={{ height: item.dimensions.height + "px" }} - > - {/* */} - { - (!transparentTags && !hideTags && !(saved.save && (index in signConfObj && signConfObj[index].accepted))) ? - <> - - + {/* INITIALS FIELD - START */} + { + item.type === "INITIALS" && +
handleSignClick(index, item.id)} + className={`flex justify-center items-center h-full w-full rounded cursor-pointer ${transparentTags || hideTags ? "pointer-events-none" : "bg-slate-200 shadow-sm border-slate-100 opacity-80"}`} + // style={{ height: item.dimensions.height + "px" }} + > + {((!transparentTags && !hideTags) && !(saved.save && (index in signConfObj) && signConfObj[index].accepted)) ? + : - src={`data:image/png;base64,${saved.signature}`} + className="w-[100%] h-full" + // src={saved.initial as string} + src={`data:image/png;base64,${saved.initial}`} /> - } -
- } - {/* SIGNATURE FIELD - END */} - - - {/* INITIALS FIELD - START */} - { - item.type === "INITIALS" && -
handleSignClick(index, item.id)} - className={`flex justify-center items-center h-full w-full rounded cursor-pointer ${transparentTags || hideTags ? "pointer-events-none" : "bg-slate-200 shadow-sm border-slate-100 opacity-80"}`} - // style={{ height: item.dimensions.height + "px" }} - > - {((!transparentTags && !hideTags) && !(saved.save && (index in signConfObj) && signConfObj[index].accepted)) ? - - : - - } -
- } - {/* INITIALS FIELD - END */} - - - {/* STAMP FIELD - START */} - { - item.type === "STAMP" && -
handleStampClick(index)} - className={`flex justify-center items-center h-full w-full rounded cursor-pointer ${transparentTags || hideTags ? "pointer-events-none" : "bg-slate-200 shadow-sm border-slate-100 opacity-80"}`} - // style={{ height: item.dimensions.height + "px" }} - > - {!transparentTags && !hideTags ? - - : - - } -
- } - {/* STAMP FIELD - END */} - - {/* IMAGE FIELD - START */} - { - item.type === "FILE" && -
handleSignClick(index)} - className={`flex justify-center items-center h-full w-full rounded cursor-pointer ${transparentTags || hideTags ? "pointer-events-none" : "bg-slate-200 shadow-sm border-slate-100 opacity-80"}`} - // style={{ height: item.dimensions.height + "px" }} - > - {!transparentTags && !hideTags ? - - : - - } -
- } - {/* IMAGE FIELD - END */} - - - {/* SELECT FIELD - START */} - { - item.type === "SELECT" && -
- -
- } - {/* SELECT FIELD - END */} +
+ } + {/* INITIALS FIELD - END */} + {/* STAMP FIELD - START */} + { + item.type === "STAMP" && +
handleStampClick(index)} + className={`flex justify-center items-center h-full w-full rounded cursor-pointer ${transparentTags || hideTags ? "pointer-events-none" : "bg-slate-200 shadow-sm border-slate-100 opacity-80"}`} + // style={{ height: item.dimensions.height + "px" }} + > + {!transparentTags && !hideTags ? + + : + + } +
+ } + {/* STAMP FIELD - END */} + + {/* IMAGE FIELD - START */} + { + item.type === "FILE" && +
handleSignClick(index)} + className={`flex justify-center items-center h-full w-full rounded cursor-pointer ${transparentTags || hideTags ? "pointer-events-none" : "bg-slate-200 shadow-sm border-slate-100 opacity-80"}`} + // style={{ height: item.dimensions.height + "px" }} + > + {!transparentTags && !hideTags ? + + : + + } +
+ } + {/* IMAGE FIELD - END */} - {/* TEMPORAL FIELD - START */} - - { - item.type === "TEMPORAL" && -
-

- {(item.id && item.id in dateValues) ? dateValues[item.id] : item.subType?.toLowerCase()} -

- { - e.target.showPicker?.() - if (item.id) setIsDateOpen(item.id) - }} - onBlur={(e) => { - let val = e.target.value; - - // Adding dummy time in case of time as it giving Invalid date without that - if (item.subType?.toLowerCase() === "time") val = "09/02/2025 " + val - - if (!item.id) return; - setIsDateOpen(null); - setDateValues({ - ...dateValues, - [item.id as string]: dayjs(val).format(item.format) + {/* SELECT FIELD - START */} + { + item.type === "SELECT" && +
+
+ } + {/* SELECT FIELD - END */} + + + + + {/* TEMPORAL FIELD - START */} + + { + item.type === "TEMPORAL" &&
- {/* +

+ {(item.id && item.id in dateValues) ? dateValues[item.id] : item.subType?.toLowerCase()} +

+ { + e.target.showPicker?.() + if (item.id) setIsDateOpen(item.id) + }} + onBlur={(e) => { + let val = e.target.value; + + // Adding dummy time in case of time as it giving Invalid date without that + if (item.subType?.toLowerCase() === "time") val = "09/02/2025 " + val + + if (!item.id) return; + setIsDateOpen(null); + setDateValues({ + ...dateValues, + [item.id as string]: dayjs(val).format(item.format) + }) + }} + style={{ opacity: `${item.id === isDateOpen ? "100" : "0"}` }} + className="w-full px-2 outline-none absolute" + onClick={() => { + + }} + type={`${item.subType?.toLowerCase() === "date" ? "date" : (item.subType?.toLowerCase() === "time" ? "time" : "datetime-local")}`} + /> + +
+ } + + {/* TEMPORAL FIELD - END */} + + + {/* Attachment Field - START */} + { + item.type.toLowerCase() === TagsTypes.ATTACHMENT && +
handleStampClick(index)} + className={`flex justify-center items-center h-full w-full rounded cursor-pointer ${transparentTags || hideTags ? "pointer-events-none" : "bg-slate-200 shadow-sm border-slate-100 opacity-80"}`} + // style={{ height: item.dimensions.height + "px" }} + > + {!transparentTags && !hideTags ? + ( +

+ {typeToIconMap.ATTACHMENT} +

+ ) + : + ( +

+ {typeToIconMap.ATTACHMENT} +

+ ) + } +
+ } + {/* Attachment Field - END */} + + + + {/* Focus Show Element */} + { + (!transparentTags && !hideTags) && (focusElement && focusElement.documentId === item.documentId && focusElement.focusElementIndx === index) && + <> +
+

{focusElement.label}

+
+
+ {/* */} - -
- - } -
- + +
+ + } +
+ ) }) } diff --git a/src/components/home/StartNow.tsx b/src/components/home/StartNow.tsx index 3ee5ccc..89217ef 100644 --- a/src/components/home/StartNow.tsx +++ b/src/components/home/StartNow.tsx @@ -50,7 +50,7 @@ const StartNow = () => {
fileInputRef.current?.click()} id='start-now-upload-con' - className="group cursor-pointer border-slate-300 rounded-lg bg-white/60 transition-all duration-200 p-4 flex flex-col items-center justify-center gap-2 text-center shadow-sm hover:shadow-md"> + className="group col-span-2 cursor-pointer border-slate-300 rounded-lg bg-white/60 transition-all duration-200 p-4 flex flex-col items-center justify-center gap-2 text-center shadow-sm hover:shadow-md"> {/* Upload icon with subtle animation */}
diff --git a/src/components/home/StartSection.tsx b/src/components/home/StartSection.tsx index d840fd5..3a8b4fc 100644 --- a/src/components/home/StartSection.tsx +++ b/src/components/home/StartSection.tsx @@ -28,16 +28,17 @@ const cards = [ // buttonText: 'Start Now', // bg: 'bg-white/60', // }, - { - icon: , - title: 'Sign an Agreement', - description: 'Upload a document you need to sign and place your signature.', - bg: 'bg-white/60', - }, + // { + // icon: , + // title: 'Sign an Agreement', + // description: 'Upload a document you need to sign and place your signature.', + // bg: 'bg-white/60', + // }, { icon: , title: 'Use a Template', description: 'Pick from ready-made templates for common agreements.', + link: "/templates", bg: 'bg-white/60', }, ]; @@ -54,19 +55,19 @@ const StartSection = () => { const defaultAccountId = user.account.id; - const handleStartSectionClick = (card: StartCard) => { - if ("buttonText" in card && card.buttonText === "Start Now") { - api.post(`/api/accounts/${defaultAccountId}/transactions`) - .then(res => { - if (res.status === 200 || res.status === 201) { - dispatch(updateTransactionStatus(TRANSACTION_STATUS_ENUMS.TRANSACTION_INITIATED)); - dispatch(setTransactionId(res.data)); - setTimeout(() => navigate(`/process-step-one/${defaultAccountId}/${res.data.id}`), 0) - } - }) - .catch(err => console.log(err)) - } - // navigate("/process-step-one"); + const handleStartSectionClick = (link: string) => { + // if ("buttonText" in card && card.buttonText === "Start Now") { + // api.post(`/api/accounts/${defaultAccountId}/transactions`) + // .then(res => { + // if (res.status === 200 || res.status === 201) { + // dispatch(updateTransactionStatus(TRANSACTION_STATUS_ENUMS.TRANSACTION_INITIATED)); + // dispatch(setTransactionId(res.data)); + // setTimeout(() => navigate(`/process-step-one/${defaultAccountId}/${res.data.id}`), 0) + // } + // }) + // .catch(err => console.log(err)) + // } + navigate(link); } // useEffect(() => { @@ -87,10 +88,10 @@ const StartSection = () => { -
+
{cards.map((card, index) => (
handleStartSectionClick(card)} + onClick={() => handleStartSectionClick(card.link)} key={index} className={`${card.bg} w-full max-h-max cursor-pointer relative border border-gray-200 rounded-xl p-4 shadow-sm hover:shadow-md transition-all flex flex-col justify-between`} > diff --git a/src/components/process/CompletionScreen/DocumentCompletionScreen.tsx b/src/components/process/CompletionScreen/DocumentCompletionScreen.tsx index 0d96c73..820dd6e 100644 --- a/src/components/process/CompletionScreen/DocumentCompletionScreen.tsx +++ b/src/components/process/CompletionScreen/DocumentCompletionScreen.tsx @@ -285,8 +285,8 @@ const DocumentCompletionScreen = () => { className='flex items-center gap-3'> - - Edit + {/* */} + View Transaction {/* + + {/* Delete Button */} + +
+ + + )}
- - {signType !== "self-sign" && ( -
- {/* Edit Button */} - - - {/* Delete Button */} - -
- - - )} -
- ))} + ) + })}
) : ( diff --git a/src/components/process/processStepTwo/DocumentContainer.tsx b/src/components/process/processStepTwo/DocumentContainer.tsx index 8ca80b9..3799711 100644 --- a/src/components/process/processStepTwo/DocumentContainer.tsx +++ b/src/components/process/processStepTwo/DocumentContainer.tsx @@ -77,35 +77,35 @@ const DocumentContainer: React.FC = ({ transactionSaving selectedDocuments.length === 0 && dispatch(fetchDocuments({ accountId, transactionId })); }, []) + + const fetchTags = async () => { + try { + const requests = selectedRecipients.map((recipient) => + api.get(`/api/accounts/${accountId}/${transactionTemplateToggle}/${transactionId}/recipients/${recipient.id}/tags`) + ); + const response = await Promise.all(requests); + let recTags = {} + for (const res of response) { + for (const tag of res.data) { + const key = `${tag.documentId}_${tag.pageIndex}`; + if (recTags[key]) { + recTags[key].push({ ...tag, update: false }); + } else { + recTags[key] = [{ ...tag, update: false }]; // Initialize with an array + } + } + } + // console.log(recTags, "Line 83"); + setDroppedItems(recTags) + // Handle your response here + } catch (err) { + console.error(err); + } + }; + // FETCHING TAG - START useEffect(() => { if (selectedRecipients.length === 0) return; - - const fetchTags = async () => { - try { - const requests = selectedRecipients.map((recipient) => - api.get(`/api/accounts/${accountId}/${transactionTemplateToggle}/${transactionId}/recipients/${recipient.id}/tags`) - ); - const response = await Promise.all(requests); - let recTags = {} - for (const res of response) { - for (const tag of res.data) { - const key = `${tag.documentId}_${tag.pageIndex}`; - if (recTags[key]) { - recTags[key].push(tag); - } else { - recTags[key] = [tag]; // Initialize with an array - } - } - } - // console.log(recTags, "Line 83"); - setDroppedItems(recTags) - // Handle your response here - } catch (err) { - console.error(err); - } - }; - fetchTags(); }, [selectedRecipients]); @@ -161,7 +161,6 @@ const DocumentContainer: React.FC = ({ transactionSaving delete updateTags[updateTags.length - 1].update } } - updatedData[recipientId] = updateTags } @@ -174,16 +173,30 @@ const DocumentContainer: React.FC = ({ transactionSaving }); try { - const responses = await Promise.all(requests); - const droppedItemsUpdateFalse = Object.fromEntries( - Object.entries(droppedItems).map(([recipientId, tags]) => { - return [recipientId, tags.map(tag => ({ ...tag, update: false }))]; - }) - ) + const response = await Promise.all(requests); - console.log(droppedItemsUpdateFalse, "Line 182") + let recTags = droppedItems; - setDroppedItems(droppedItemsUpdateFalse); + for (const res of response) { + for (const tag of res.data) { + const key = `${tag.documentId}_${tag.pageIndex}`; + if (recTags[key]) { + recTags[key].push({ ...tag, update: false }); + } else { + recTags[key] = [{ ...tag, update: false }]; // Initialize with an array + } + } + } + + setSelectedTag(null); + + // setTimeout(async () => { + // await fetchTags() + // setSelectedTag(null); + // }, 1000) + + // console.log(droppedItemsUpdateFalse, "Line 182") + // setDroppedItems(droppedItemsUpdateFalse); } catch (error) { console.error("Error submitting recipient tags:", error); } @@ -300,6 +313,11 @@ const DocumentContainer: React.FC = ({ transactionSaving await sendTagsToRecipients(tagsData, accountId, transactionId); + // if (save) { + // setSelectedTag(null); + // await fetchTags(); + // } + // SENDING Transaction - START if (!save) { const res = await api.put(`/api/accounts/${accountId}/${transactionTemplateToggle}/${transactionId}`, { status: "SENT" }) diff --git a/src/components/process/processStepTwo/LeftSideBar.tsx b/src/components/process/processStepTwo/LeftSideBar.tsx index bcd5417..ae4b5c4 100644 --- a/src/components/process/processStepTwo/LeftSideBar.tsx +++ b/src/components/process/processStepTwo/LeftSideBar.tsx @@ -24,8 +24,8 @@ const LeftSideBar: React.FC = ({ isFields, selectedRecipientIn let transactionId = params.transactionId if (!transactionId) { transactionTemplateToggle = TRANSACTION_TEMPLATE_TOGGLE.TEMPLATES; - transactionId = params.templateId; - dispatch(toggleToTemplates()); + transactionId = params.templateId; + dispatch(toggleToTemplates()); } if (!accountId || !transactionId) { window.location.href = "/"; @@ -80,7 +80,13 @@ const LeftSideBar: React.FC = ({ isFields, selectedRecipientIn

{/* */} -

{selectedRecipient.firstName} {selectedRecipient.lastName}

+

+ { + selectedRecipient.firstName.length === 0 && selectedRecipient.lastName.length === 0 ? + (selectedRecipient.email.length === 0 ? selectedRecipient.roleName : selectedRecipient.email) : + `${selectedRecipient.firstName + " " + selectedRecipient.lastName}` + } +

@@ -101,7 +107,13 @@ const LeftSideBar: React.FC = ({ isFields, selectedRecipientIn

{/* */} -

{recipient.firstName} {recipient.lastName}

+

+ { + recipient.firstName.length === 0 && recipient.lastName.length === 0 ? + (recipient.email.length === 0 ? recipient.roleName : recipient.email) : + `${recipient.firstName + " " + recipient.lastName}` + } +

{selectedRecipientIndx === indx && }
) @@ -111,9 +123,9 @@ const LeftSideBar: React.FC = ({ isFields, selectedRecipientIn {/* Side Bar showing Recipients - ENDS*/} {/* Drag Drop Tags Start */} -
+
diff --git a/src/components/process/processStepTwo/NavTwo.tsx b/src/components/process/processStepTwo/NavTwo.tsx index b940196..68243df 100644 --- a/src/components/process/processStepTwo/NavTwo.tsx +++ b/src/components/process/processStepTwo/NavTwo.tsx @@ -125,11 +125,11 @@ const NavTwo: React.FC = ({ transactionSaving, isFields, setIsField setTimeout(() => { if (transactionTemplateToggle === TRANSACTION_TEMPLATE_TOGGLE.TRANSACTIONS) { if (isSignSend) { - navigate(`./../../../sign/${selfUserSign.recipientId}`); + window.open(`./../../../sign/${selfUserSign.recipientId}`, "_self"); + } + else { + navigate(`/document-completion-screen/${accountId}/${transactionId}`) } - // else { - // navigate(`/document-completion-screen/${accountId}/${transactionId}`) - // } } else { navigate(`/templates`); toast.success("Template Saved...!", { diff --git a/src/components/process/processStepTwo/rightSideBar/RecipientsAttrCon.tsx b/src/components/process/processStepTwo/rightSideBar/RecipientsAttrCon.tsx index 78fc345..7224d26 100644 --- a/src/components/process/processStepTwo/rightSideBar/RecipientsAttrCon.tsx +++ b/src/components/process/processStepTwo/rightSideBar/RecipientsAttrCon.tsx @@ -53,7 +53,13 @@ const RecipientsAttrCon: React.FC = ({ selectedRecipientI

{/* */} -

{"firstName" in selectedRecipient && selectedRecipient.firstName} {"lastName" in selectedRecipient && selectedRecipient.lastName}

+

+ { + selectedRecipient.firstName.length === 0 && selectedRecipient.lastName.length === 0 ? + (selectedRecipient.email.length === 0 ? selectedRecipient.roleName : selectedRecipient.email) : + `${selectedRecipient.firstName + " " + selectedRecipient.lastName}` + } +

@@ -65,7 +71,7 @@ const RecipientsAttrCon: React.FC = ({ selectedRecipientI key={indx} className='flex items-center justify-between gap-2 w-full p-2 text-xs rounded-sm cursor-pointer hover:bg-slate-100' onClick={() => { - handlePropertyChange('recipientId', recipient.id); + handlePropertyChange('recipientId', recipient.id); setTimeout(() => { setDropDownToggle(false); }, 0) @@ -74,7 +80,13 @@ const RecipientsAttrCon: React.FC = ({ selectedRecipientI

{/* */} -

{recipient.firstName} {recipient.lastName}

+

+ { + recipient.firstName.length === 0 && recipient.lastName.length === 0 ? + (recipient.email.length === 0 ? recipient.roleName : recipient.email) : + `${recipient.firstName + " " + recipient.lastName}` + } +

{selectedRecipientId === recipient.id && }
) diff --git a/src/components/signature/SignCon.tsx b/src/components/signature/SignCon.tsx index 31c5545..e550131 100644 --- a/src/components/signature/SignCon.tsx +++ b/src/components/signature/SignCon.tsx @@ -166,6 +166,7 @@ const AddSignatureModal: React.FC = ({ if (initialsBlob && signatureBlob) { setSaved({ + signatureId: res.data.id, saveType: SaveTypeEnum.DRAW, save: true, signature: signatureBlob, @@ -293,6 +294,7 @@ const AddSignatureModal: React.FC = ({ initials: "", }) setSaved({ + signatureId: res.data.id ?? null, saveType: res.data.signatureType ?? null, save: true, signature: res.data.signatureBlob ?? null, @@ -647,7 +649,7 @@ const AddSignatureModal: React.FC = ({ ) : ( <> - CREATE SIGNATURE + {activeTab === "SAVED" ? "CHANGE SIGNATURE" : "CREATE SIGNATURE"} {/* isEditMode ? 'UPDATE SIGNATURE' : 'CREATE SIGNATURE' */} )} diff --git a/src/components/transactions/TransactionView.tsx b/src/components/transactions/TransactionView.tsx index c9255f1..b31dc69 100644 --- a/src/components/transactions/TransactionView.tsx +++ b/src/components/transactions/TransactionView.tsx @@ -9,6 +9,7 @@ import { IoCloseOutline } from 'react-icons/io5'; import { MdEditDocument } from "react-icons/md"; import { useSelector } from 'react-redux'; import { RootState } from '../../store/store'; +import { SignTypeEnum } from '../../utlity/types'; // Sample recipient data — you can replace this with actual API data later const recipients = [ @@ -62,7 +63,7 @@ const TransactionView = () => { const handleNavigateToSign = (id: number) => { - window.open(`./../../../../sign/${id}`) + window.open(`./../../../../sign/${id}/${SignTypeEnum.selfSign}`) } return ( @@ -138,7 +139,7 @@ const TransactionView = () => { {recipient.email === user.email && recipient.status !== "COMPLETED" &&

handleNavigateToSign(recipient.id)} - className='text-white rounded-sm bg-[var(--primary)] px-3 py-1 font-semibold'> + className='text-white rounded-sm bg-[var(--primary)] px-3 py-1 font-semibold cursor-pointer'> Sign

}