From 02bfa840947d77db448aec1a90da833c7e1a39a0 Mon Sep 17 00:00:00 2001 From: JaiPandey425 Date: Fri, 8 Aug 2025 17:08:18 +0530 Subject: [PATCH] first-form-docs reset --- src/components/home/StartNow.tsx | 5 ++-- .../DocumentCompletionScreen.tsx | 26 ++++++++--------- .../processStepOne/RecipientAddCard.tsx | 25 ++++++++++++----- .../process/processStepOne/RecipientCards.tsx | 2 +- .../processStepTwo/DocumentContainer.tsx | 3 +- .../setting/Signature/AddSignatureModal.tsx | 28 ++++++++++--------- 6 files changed, 52 insertions(+), 37 deletions(-) diff --git a/src/components/home/StartNow.tsx b/src/components/home/StartNow.tsx index 89217ef..60a5c14 100644 --- a/src/components/home/StartNow.tsx +++ b/src/components/home/StartNow.tsx @@ -1,6 +1,6 @@ import { useRef, useState } from 'react'; import { FiUpload } from 'react-icons/fi' -import { uploadDocuments } from '../../store/slices/documentSlice'; +import { resetDocuments, uploadDocuments } from '../../store/slices/documentSlice'; import { useDispatch, useSelector } from 'react-redux'; import { toast } from 'react-toastify'; import { useNavigate } from 'react-router-dom'; @@ -37,7 +37,8 @@ const StartNow = () => { }); }; - const handleFileChange = (e: React.ChangeEvent) => { + const handleFileChange = async (e: React.ChangeEvent) => { + await dispatch(resetDocuments()) const selectedFiles = e.target.files ? Array.from(e.target.files) : []; if (selectedFiles.length > 0) { setFiles((prev) => [...prev, ...selectedFiles]); diff --git a/src/components/process/CompletionScreen/DocumentCompletionScreen.tsx b/src/components/process/CompletionScreen/DocumentCompletionScreen.tsx index 251cbd2..ce2a410 100644 --- a/src/components/process/CompletionScreen/DocumentCompletionScreen.tsx +++ b/src/components/process/CompletionScreen/DocumentCompletionScreen.tsx @@ -46,7 +46,7 @@ type Signer = { // Signers List Component const SignersList: React.FC<{ signers: Signer[] }> = ({ signers }) => { return ( -
+ //

@@ -58,9 +58,9 @@ const SignersList: React.FC<{ signers: Signer[] }> = ({ signers }) => {

-
+
{signers.map((signer) => ( -
+
{signer.name.length > 2 ? signer.name.split(" ").map(n => n[0].toUpperCase()).join("") : signer.email.split("").map(n => n[0].toUpperCase()).join("")}
@@ -86,7 +86,7 @@ const SignersList: React.FC<{ signers: Signer[] }> = ({ signers }) => { ))}
-
+ //
); }; @@ -121,10 +121,10 @@ const SigningOrderDiagram: React.FC<{ signers: Signer[] }> = ({ signers }) => { ) || -1; return ( -
+ //

Signing Flow

-
+
{/* Mail icon */}
@@ -194,7 +194,7 @@ const SigningOrderDiagram: React.FC<{ signers: Signer[] }> = ({ signers }) => {
-
+ //
); }; const DocumentSubmissionOptions = () => { @@ -387,8 +387,8 @@ const DocumentSubmissionOptions = () => { case 'success': return (
-
- +
+

Document Send Successfully!

@@ -430,22 +430,23 @@ const DocumentSubmissionOptions = () => { } }; + + return (
{/* Header */}
- +

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

- {/*
*/}
{/* Left Panel - Configuration */} @@ -457,7 +458,6 @@ const DocumentSubmissionOptions = () => {

Choose an action after a signer completes the document.

-
{options.map((option) => { const Icon = option.icon; diff --git a/src/components/process/processStepOne/RecipientAddCard.tsx b/src/components/process/processStepOne/RecipientAddCard.tsx index cf65bc0..02fd656 100644 --- a/src/components/process/processStepOne/RecipientAddCard.tsx +++ b/src/components/process/processStepOne/RecipientAddCard.tsx @@ -22,11 +22,11 @@ interface ContactType { export interface ContactTypeObj { type: string; contacts: ContactType[]; - setEditRecipientCurrentEmail : any + setEditRecipientCurrentEmail: any } -const RecipientAddCard = ({ transactionTemplateToggle, editRecipient, editCase, setEditRecipient, setEditCase, topRef , setEditRecipientCurrentEmail }) => { +const RecipientAddCard = ({ transactionTemplateToggle, editRecipient, editCase, setEditRecipient, setEditCase, topRef, setEditRecipientCurrentEmail }) => { const [activeAccountId, setActiveAccountId] = useState( JSON.parse(sessionStorage.getItem('activeAccountId') || 'null') ); @@ -113,7 +113,7 @@ const RecipientAddCard = ({ transactionTemplateToggle, editRecipient, editCase, hostName: editRecipient.hostName || "", hostEmail: editRecipient.hostEmail || "", roleName: editRecipient.roleName || "", - type: editRecipient.type || recipientType.SIGNER, + type: editRecipient.type, allowSenderToEdit: editRecipient.allowSenderToEdit ?? true, allowSenderToDelete: editRecipient.allowSenderToDelete ?? true, uuid: String(editRecipient?.id ?? editRecipient?.uuid ?? ''), @@ -210,11 +210,22 @@ const RecipientAddCard = ({ transactionTemplateToggle, editRecipient, editCase, submitForm(); function submitForm() { - if (editCase === 'Edit') { - dispatch(updateRecipient(recipient)); + let updatedRecipient = { ...recipient }; + + // Clear hostName and hostEmail if type is SIGNER or CC + if ( + updatedRecipient.type === recipientType.SIGNER || + updatedRecipient.type === recipientType.CC + ) { + updatedRecipient.hostName = ""; + updatedRecipient.hostEmail = ""; + } + + if (editCase === "Edit") { + dispatch(updateRecipient(updatedRecipient)); } else { dispatch(addRecipient({ - ...recipient, + ...updatedRecipient, uuid: uuidv4(), newOne: true, })); @@ -580,7 +591,7 @@ const RecipientAddCard = ({ transactionTemplateToggle, editRecipient, editCase, type="radio" name="recipient-type" value={option.value} - defaultChecked={option.value === recipientType.SIGNER} + checked={recipient.type === option.value} onClick={(e) => setRecipients({ ...recipient, type: e.target.value })} className="accent-[var(--primary)] cursor-pointer" /> diff --git a/src/components/process/processStepOne/RecipientCards.tsx b/src/components/process/processStepOne/RecipientCards.tsx index 6348b1b..581107b 100644 --- a/src/components/process/processStepOne/RecipientCards.tsx +++ b/src/components/process/processStepOne/RecipientCards.tsx @@ -141,7 +141,7 @@ const RecipientCards = ({ setEditRecipient, setEditCase, transactionTemplateTogg {recipients.map((recipient, idx) => (
{/* {signingOrder && ( */} diff --git a/src/components/process/processStepTwo/DocumentContainer.tsx b/src/components/process/processStepTwo/DocumentContainer.tsx index 3799711..e472519 100644 --- a/src/components/process/processStepTwo/DocumentContainer.tsx +++ b/src/components/process/processStepTwo/DocumentContainer.tsx @@ -4,7 +4,7 @@ import { RootState } from '../../../store/store' import api from '../../../config/api'; -import RightSideBar from './rightSideBar/RightSideBar'; +import RightSideBar, { TEXT } from './rightSideBar/RightSideBar'; import { DroppedItem, TagsTypes } from '../../../utlity/types'; import { useNavigate, useParams } from 'react-router-dom'; @@ -241,6 +241,7 @@ const DocumentContainer: React.FC = ({ transactionSaving const isDeleted = "isDeleted" in dropTag ? dropTag.isDeleted : false + const updatedTagData = { "id": "id" in dropTag ? dropTag.id : null, "label": dropTag.label, diff --git a/src/components/setting/Signature/AddSignatureModal.tsx b/src/components/setting/Signature/AddSignatureModal.tsx index 9478964..9a7fb94 100644 --- a/src/components/setting/Signature/AddSignatureModal.tsx +++ b/src/components/setting/Signature/AddSignatureModal.tsx @@ -55,7 +55,7 @@ const AddSignatureModal: React.FC = ({ getAllSignatures, editingSignature }) => { - const [activeTab, setActiveTab] = useState<'TYPE' | 'DRAW' | 'UPLOAD' >('TYPE'); + const [activeTab, setActiveTab] = useState<'SELECT' | 'DRAW' | 'UPLOAD'>('SELECT'); const [fullName, setFullName] = useState(''); const [initials, setInitials] = useState(''); const [isSubmitting, setIsSubmitting] = useState(false); @@ -107,7 +107,7 @@ const AddSignatureModal: React.FC = ({ // Navigation items const navigationItems = [ - { id: 'TYPE', label: 'TYPE', icon: }, + { id: 'SELECT', label: 'SELECT', icon: }, { id: 'DRAW', label: 'DRAW', icon: }, { id: 'UPLOAD', label: 'UPLOAD', icon: }, // { id: 'SELECT', label: 'SELECT', icon: }, @@ -118,7 +118,7 @@ const AddSignatureModal: React.FC = ({ if (editingSignature) { setFullName(`${editingSignature.firstName} ${editingSignature.lastName}`); setInitials(`${editingSignature.firstName.slice(0, 1)}${editingSignature.lastName.slice(0, 1)}`); - setActiveTab(editingSignature.signatureType as 'TYPE' | 'DRAW' | 'UPLOAD'); + setActiveTab(editingSignature.signatureType as 'SELECT' | 'DRAW' | 'UPLOAD'); // Set font for SELECT tab const fontOption = signatureOptions.find(option => option.style === editingSignature.font); @@ -193,10 +193,12 @@ const AddSignatureModal: React.FC = ({ const handleSubmit = async () => { setIsSubmitting(true); - if (!signatures.fullSignature || !signatures.initials) { - alert('Please provide both signature and initials'); - setIsSubmitting(false); - return; + if (activeTab === 'DRAW' || activeTab === 'UPLOAD') { + if (!signatures.fullSignature || !signatures.initials) { + alert('Please provide both signature and initials'); + setIsSubmitting(false); + return; + } } try { @@ -207,7 +209,7 @@ const AddSignatureModal: React.FC = ({ firstName: fullName.split(' ')[0] || user.firstName, lastName: fullName.split(' ')[1] || user.lastName, font: selectedSignature.style, - default:checked + default: checked }; let res; @@ -273,7 +275,7 @@ const AddSignatureModal: React.FC = ({ const renderContent = () => { switch (activeTab) { - case 'TYPE': + case 'SELECT': return (
@@ -481,7 +483,7 @@ const AddSignatureModal: React.FC = ({ {navigationItems.map((item) => (

- {checked - ? 'Signature will be used by default.' - : 'Signature will not be used by default.'} + + Signature will be used by default. +