Skip to content

Commit 4c16267

Browse files
Merge pull request #753 from OpenSignLabs/raktima-opensignlabs-patch-7
feat: celebration confetti on document completion
2 parents 444c9bb + eeb878b commit 4c16267

File tree

5 files changed

+73
-25
lines changed

5 files changed

+73
-25
lines changed

apps/OpenSign/package-lock.json

Lines changed: 20 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

apps/OpenSign/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
"radix-ui": "^1.0.1",
1818
"react": "^18.2.0",
1919
"react-bootstrap": "^2.10.2",
20+
"react-confetti": "^6.1.0",
2021
"react-cookie": "^7.1.4",
2122
"react-datepicker": "^6.4.0",
2223
"react-dnd": "^16.0.1",

apps/OpenSign/src/components/pdf/EmailComponent.js

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ import loader from "../../assets/images/loader2.gif";
1010
function EmailComponent({
1111
isEmail,
1212
pdfUrl,
13-
isCeleb,
1413
setIsEmail,
1514
setSuccessEmail,
1615
pdfName,
@@ -22,6 +21,7 @@ function EmailComponent({
2221
const [emailList, setEmailList] = useState([]);
2322
const [emailValue, setEmailValue] = useState();
2423
const [isLoading, setIsLoading] = useState(false);
24+
const [isEmailCelebration, setIsEmailCelebration] = useState(false);
2525
//function for send email
2626
const sendEmail = async () => {
2727
setIsLoading(true);
@@ -62,6 +62,10 @@ function EmailComponent({
6262
" target=_blank>here</a> </p></div></div></body></html>"
6363
};
6464
sendMail = await axios.post(url, params, { headers: headers });
65+
setIsEmailCelebration(true);
66+
setTimeout(() => {
67+
setIsEmailCelebration(false);
68+
}, 3000);
6569
} catch (error) {
6670
console.log("error", error);
6771
setIsLoading(false);
@@ -245,22 +249,17 @@ function EmailComponent({
245249
</div>
246250
</div>
247251
<div style={{ height: "100%", padding: 20 }}>
248-
{isCeleb && (
249-
<div
250-
style={{
251-
position: "absolute",
252-
marginLeft: "50px"
253-
}}
254-
>
252+
{isEmailCelebration && (
253+
<div className="absolute w-[100%] flex justify-center items-center">
255254
<img
256255
alt="print img"
257256
width={300}
258257
height={250}
259-
// style={styles.gifCeleb}
260258
src={celebration}
261259
/>
262260
</div>
263261
)}
262+
264263
<p
265264
style={{
266265
fontFamily: "system-ui",

apps/OpenSign/src/pages/PdfRequestFiles.js

Lines changed: 33 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import { useLocation, useNavigate, useParams } from "react-router-dom";
1111
import SignPad from "../components/pdf/SignPad";
1212
import RenderAllPdfPage from "../components/pdf/RenderAllPdfPage";
1313
import Tour from "reactour";
14+
import Confetti from "react-confetti";
1415
import moment from "moment";
1516
import {
1617
contractDocument,
@@ -61,6 +62,7 @@ function PdfRequestFiles() {
6162
const [handleError, setHandleError] = useState();
6263
const [selectWidgetId, setSelectWidgetId] = useState("");
6364
const [otpLoader, setOtpLoader] = useState(false);
65+
const [isCelebration, setIsCelebration] = useState(false);
6466
const [isLoading, setIsLoading] = useState({
6567
isLoad: true,
6668
message: "This might take some time"
@@ -219,7 +221,7 @@ function PdfRequestFiles() {
219221
}
220222
}
221223
//function for get document details for perticular signer with signer'object id
222-
const getDocumentDetails = async () => {
224+
const getDocumentDetails = async (isNextUser) => {
223225
let currUserId;
224226
//getting document details
225227
const documentData = await contractDocument(documentId);
@@ -412,6 +414,27 @@ function PdfRequestFiles() {
412414
setSignerPos(documentData[0].Placeholders);
413415
}
414416
setPdfDetails(documentData);
417+
// Check if the current signer is not a last signer and handle the complete message.
418+
if (isNextUser) {
419+
const getSignedAuditTrail = documentData[0].AuditTrail.filter(
420+
(data) => data.Activity === "Signed"
421+
);
422+
const isLastSigner =
423+
getSignedAuditTrail?.length === documentData?.[0]?.Signers?.length;
424+
if (!isLastSigner) {
425+
setIsCompleted({
426+
isModal: true,
427+
message:
428+
"You have successfully signed the document. You can download or print a copy of the partially signed document. A copy of the digitally signed document will be sent to the owner over email once it is signed by all signers."
429+
});
430+
} else {
431+
setIsCelebration(true);
432+
setTimeout(() => {
433+
setIsCelebration(false);
434+
}, 5000);
435+
}
436+
}
437+
415438
setIsUiLoading(false);
416439
} else {
417440
alert("No data found!");
@@ -701,19 +724,12 @@ function PdfRequestFiles() {
701724
setIsSigned(true);
702725
setSignedSigners([]);
703726
setUnSignedSigners([]);
704-
getDocumentDetails();
727+
getDocumentDetails(true);
705728
const index = pdfDetails?.[0].Signers.findIndex(
706729
(x) => x.Email === jsonSender.email
707730
);
708731
const newIndex = index + 1;
709732
const user = pdfDetails?.[0].Signers[newIndex];
710-
if (user) {
711-
setIsCompleted({
712-
isModal: true,
713-
message:
714-
"You have successfully signed the document. You can download or print a copy of the partially signed document. A copy of the digitally signed document will be sent to the owner over email once it is signed by all signers."
715-
});
716-
}
717733
if (sendInOrder) {
718734
const requestBody = pdfDetails?.[0]?.RequestBody;
719735
const requestSubject = pdfDetails?.[0]?.RequestSubject;
@@ -1120,7 +1136,6 @@ function PdfRequestFiles() {
11201136
alertMessage: ""
11211137
});
11221138
};
1123-
11241139
return (
11251140
<DndProvider backend={HTML5Backend}>
11261141
<Title title={"Request Sign"} />
@@ -1169,6 +1184,14 @@ function PdfRequestFiles() {
11691184
</span>
11701185
</div>
11711186
)}
1187+
{isCelebration && (
1188+
<div style={{ position: "relative", zIndex: "1000" }}>
1189+
<Confetti
1190+
width={window.innerWidth}
1191+
height={window.innerHeight}
1192+
/>
1193+
</div>
1194+
)}
11721195

11731196
<div
11741197
className="relative flex flex-col md:flex-row justify-between bg-[#ebebeb]"

apps/OpenSign/src/pages/SignyourselfPdf.js

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { PDFDocument } from "pdf-lib";
33
import "../styles/signature.css";
44
import Parse from "parse";
55
import { isEnableSubscription, themeColor } from "../constant/const";
6+
import Confetti from "react-confetti";
67
import axios from "axios";
78
import Loader from "../primitives/LoaderWithMsg";
89
import loader from "../assets/images/loader2.gif";
@@ -70,7 +71,6 @@ function SignYourSelf() {
7071
const [dragKey, setDragKey] = useState();
7172
const [signKey, setSignKey] = useState();
7273
const [imgWH, setImgWH] = useState({});
73-
const [isCeleb, setIsCeleb] = useState(false);
7474
const [pdfNewWidth, setPdfNewWidth] = useState();
7575
const [pdfOriginalWidth, setPdfOriginalWidth] = useState();
7676
const [successEmail, setSuccessEmail] = useState(false);
@@ -109,6 +109,7 @@ function SignYourSelf() {
109109
const [isDontShow, setIsDontShow] = useState(false);
110110
const [extUserId, setExtUserId] = useState("");
111111
const [isCompleted, setIsCompleted] = useState(false);
112+
const [isCelebration, setIsCelebration] = useState(false);
112113
const [pdfArrayBuffer, setPdfArrayBuffer] = useState("");
113114
const [activeMailAdapter, setActiveMailAdapter] = useState("");
114115
const [isEmailVerified, setIsEmailVerified] = useState(true);
@@ -229,8 +230,12 @@ function SignYourSelf() {
229230
setIsUiLoading(false);
230231
setIsSignPad(false);
231232
setIsEmail(true);
233+
setIsCelebration(true);
232234
setXyPostion([]);
233235
setSignBtnPosition([]);
236+
setTimeout(() => {
237+
setIsCelebration(false);
238+
}, 5000);
234239
}
235240
}
236241
} else if (
@@ -649,10 +654,6 @@ function SignYourSelf() {
649654
});
650655
return;
651656
} else {
652-
setIsCeleb(true);
653-
setTimeout(() => {
654-
setIsCeleb(false);
655-
}, 3000);
656657
setIsUiLoading(true);
657658
const existingPdfBytes = pdfArrayBuffer;
658659
// Load a PDFDocument from the existing PDF bytes
@@ -1122,6 +1123,11 @@ function SignYourSelf() {
11221123
</span>
11231124
</div>
11241125
)}
1126+
{isCelebration && (
1127+
<div style={{ position: "relative", zIndex: "999" }}>
1128+
<Confetti width={window.innerWidth} height={window.innerHeight} />
1129+
</div>
1130+
)}
11251131

11261132
<div className="signatureContainer" ref={divRef}>
11271133
{!isEmailVerified && (
@@ -1258,7 +1264,6 @@ function SignYourSelf() {
12581264
<EmailComponent
12591265
isEmail={isEmail}
12601266
pdfUrl={pdfUrl}
1261-
isCeleb={isCeleb}
12621267
setIsEmail={setIsEmail}
12631268
pdfName={pdfDetails[0] && pdfDetails[0].Name}
12641269
setSuccessEmail={setSuccessEmail}

0 commit comments

Comments
 (0)