Skip to content

Commit 9a07c67

Browse files
Merge pull request #602 from OpenSignLabs/report_decline
feat: add revoke button in inprogress report to revoke/decline document
2 parents 509f8f9 + 33bfdee commit 9a07c67

File tree

3 files changed

+127
-21
lines changed

3 files changed

+127
-21
lines changed

apps/OpenSign/src/json/ReportJson.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,15 @@ export default function reportJson(id) {
8484
btnIcon: "fa fa-trash",
8585
redirectUrl: "",
8686
action: "delete"
87+
},
88+
{
89+
btnId: "1688",
90+
btnLabel: "Revoke",
91+
btnColor: "#ff4848",
92+
textColor: "white",
93+
btnIcon: "fa-solid fa-file-circle-xmark",
94+
redirectUrl: "",
95+
action: "revoke"
8796
}
8897
],
8998
helpMsg:

apps/OpenSign/src/pages/PdfRequestFiles.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1092,9 +1092,9 @@ function PdfRequestFiles() {
10921092
isDecline.currnt === "Sure"
10931093
? "Are you sure want to decline this document ?"
10941094
: isDecline.currnt === "YouDeclined"
1095-
? "You have declined this document!"
1096-
: isDecline.currnt === "another" &&
1097-
"You cannot sign this document as it has been declined by one or more recipient(s)."
1095+
? "You have declined this document!"
1096+
: isDecline.currnt === "another" &&
1097+
"You can not sign this document as it has been declined/revoked."
10981098
}
10991099
footerMessage={isDecline.currnt === "Sure"}
11001100
declineDoc={declineDoc}

apps/OpenSign/src/primitives/GetReportDisplay.js

Lines changed: 115 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React, { useState, useEffect, useMemo } from "react";
1+
import React, { useState, useEffect, useMemo } from "react";
22
import pad from "../assets/images/pad.svg";
33
import { useNavigate } from "react-router-dom";
44
import axios from "axios";
@@ -25,13 +25,14 @@ const ReportTable = ({
2525
const [currentPage, setCurrentPage] = useState(1);
2626
const [actLoader, setActLoader] = useState({});
2727
const [isAlert, setIsAlert] = useState(false);
28-
const [isErr, setIsErr] = useState(false);
2928
const [isDocErr, setIsDocErr] = useState(false);
3029
const [isContactform, setIsContactform] = useState(false);
3130
const [isDeleteModal, setIsDeleteModal] = useState({});
31+
const [isRevoke, setIsRevoke] = useState({});
3232
const [isShare, setIsShare] = useState({});
3333
const [shareUrls, setShareUrls] = useState([]);
3434
const [copied, setCopied] = useState(false);
35+
const [alertMsg, setAlertMsg] = useState({ type: "success", message: "" });
3536
const startIndex = (currentPage - 1) * docPerPage;
3637

3738
// For loop is used to calculate page numbers visible below table
@@ -164,7 +165,10 @@ const ReportTable = ({
164165
} catch (err) {
165166
console.log("Err", err);
166167
setIsAlert(true);
167-
setIsErr(true);
168+
setAlertMsg({
169+
type: "danger",
170+
message: "Something went wrong, Please try again later!"
171+
});
168172
setTimeout(() => setIsAlert(false), 1500);
169173
setActLoader({});
170174
}
@@ -174,14 +178,20 @@ const ReportTable = ({
174178
}
175179
} else {
176180
setIsAlert(true);
177-
setIsErr(true);
181+
setAlertMsg({
182+
type: "danger",
183+
message: "Something went wrong, Please try again later!"
184+
});
178185
setTimeout(() => setIsAlert(false), 1500);
179186
setActLoader({});
180187
}
181188
} catch (err) {
182189
console.log("err", err);
183190
setIsAlert(true);
184-
setIsErr(true);
191+
setAlertMsg({
192+
type: "danger",
193+
message: "Something went wrong, Please try again later!"
194+
});
185195
setTimeout(() => setIsAlert(false), 1500);
186196
setActLoader({});
187197
}
@@ -200,6 +210,8 @@ const ReportTable = ({
200210
setIsDeleteModal({ [item.objectId]: true });
201211
} else if (act.action === "share") {
202212
handleShare(item);
213+
} else if (act.action === "revoke") {
214+
setIsRevoke({ [item.objectId]: true });
203215
}
204216
};
205217
// Get current list
@@ -248,19 +260,29 @@ const ReportTable = ({
248260
if (res.data && res.data.updatedAt) {
249261
setActLoader({});
250262
setIsAlert(true);
263+
setAlertMsg({
264+
type: "success",
265+
message: "Record deleted successfully!"
266+
});
251267
setTimeout(() => setIsAlert(false), 1500);
252268
const upldatedList = List.filter((x) => x.objectId !== item.objectId);
253269
setList(upldatedList);
254270
}
255271
} catch (err) {
256272
console.log("err", err);
257273
setIsAlert(true);
258-
setIsErr(true);
274+
setAlertMsg({
275+
type: "danger",
276+
message: "Something went wrong, Please try again later!"
277+
});
259278
setTimeout(() => setIsAlert(false), 1500);
260279
setActLoader({});
261280
}
262281
};
263-
const handleCloseDeleteModal = () => setIsDeleteModal({});
282+
const handleClose = () => {
283+
setIsRevoke({});
284+
setIsDeleteModal({});
285+
};
264286

265287
const handleShare = (item) => {
266288
setActLoader({ [item.objectId]: true });
@@ -281,6 +303,53 @@ const ReportTable = ({
281303
navigator.clipboard.writeText(share.url);
282304
setCopied({ ...copied, [share.email]: true });
283305
};
306+
//function to handle revoke/decline docment
307+
const handleRevoke = async (item) => {
308+
setIsRevoke({});
309+
setActLoader({ [`${item.objectId}`]: true });
310+
const data = {
311+
IsDeclined: true
312+
};
313+
314+
await axios
315+
.put(
316+
`${localStorage.getItem("baseUrl")}classes/${localStorage.getItem(
317+
"_appName"
318+
)}_Document/${item.objectId}`,
319+
data,
320+
{
321+
headers: {
322+
"Content-Type": "application/json",
323+
"X-Parse-Application-Id": localStorage.getItem("parseAppId"),
324+
"X-Parse-Session-Token": localStorage.getItem("accesstoken")
325+
}
326+
}
327+
)
328+
.then(async (result) => {
329+
const res = result.data;
330+
if (res) {
331+
setActLoader({});
332+
setIsAlert(true);
333+
setAlertMsg({
334+
type: "success",
335+
message: "Record revoked successfully!"
336+
});
337+
setTimeout(() => setIsAlert(false), 1500);
338+
const upldatedList = List.filter((x) => x.objectId !== item.objectId);
339+
setList(upldatedList);
340+
}
341+
})
342+
.catch((err) => {
343+
console.log("err", err);
344+
setIsAlert(true);
345+
setAlertMsg({
346+
type: "danger",
347+
message: "Something went wrong, Please try again later!"
348+
});
349+
setTimeout(() => setIsAlert(false), 1500);
350+
setActLoader({});
351+
});
352+
};
284353
return (
285354
<div className="relative">
286355
{Object.keys(actLoader)?.length > 0 && (
@@ -292,13 +361,7 @@ const ReportTable = ({
292361
</div>
293362
)}
294363
<div className="p-2 overflow-x-scroll w-full bg-white rounded-md">
295-
{isAlert && (
296-
<Alert type={isErr ? "danger" : "success"}>
297-
{isErr
298-
? "Something went wrong, Please try again later!"
299-
: "Record deleted successfully!"}
300-
</Alert>
301-
)}
364+
{isAlert && <Alert type={alertMsg.type}>{alertMsg.message}</Alert>}
302365
<div className="flex flex-row items-center justify-between my-2 mx-3 text-[20px] md:text-[23px]">
303366
<div className="font-light">
304367
{ReportName}{" "}
@@ -370,7 +433,7 @@ const ReportTable = ({
370433
<ModalUi
371434
isOpen
372435
title={"Delete Contact"}
373-
handleClose={handleCloseDeleteModal}
436+
handleClose={handleClose}
374437
>
375438
<div className="m-[20px]">
376439
<div className="text-lg font-normal text-black">
@@ -388,7 +451,7 @@ const ReportTable = ({
388451
Yes
389452
</button>
390453
<button
391-
onClick={handleCloseDeleteModal}
454+
onClick={handleClose}
392455
className="px-4 py-1.5 text-black border-[1px] border-[#ccc] shadow-md rounded focus:outline-none"
393456
style={{
394457
backgroundColor: modalCancelBtnColor
@@ -459,7 +522,7 @@ const ReportTable = ({
459522
<ModalUi
460523
isOpen
461524
title={"Delete Document"}
462-
handleClose={handleCloseDeleteModal}
525+
handleClose={handleClose}
463526
>
464527
<div className="m-[20px]">
465528
<div className="text-lg font-normal text-black">
@@ -477,7 +540,7 @@ const ReportTable = ({
477540
Yes
478541
</button>
479542
<button
480-
onClick={handleCloseDeleteModal}
543+
onClick={handleClose}
481544
className="px-4 py-1.5 text-black border-[1px] border-[#ccc] shadow-md rounded focus:outline-none"
482545
style={{
483546
backgroundColor: modalCancelBtnColor
@@ -531,6 +594,40 @@ const ReportTable = ({
531594
</div>
532595
</ModalUi>
533596
)}
597+
{isRevoke[item.objectId] && (
598+
<ModalUi
599+
isOpen
600+
title={"Revoke document"}
601+
handleClose={handleClose}
602+
>
603+
<div className="m-[20px]">
604+
<div className="text-lg font-normal text-black">
605+
Are you sure you want to revoke this document?
606+
</div>
607+
<hr className="bg-[#ccc] mt-4 " />
608+
<div className="flex items-center mt-3 gap-2 text-white">
609+
<button
610+
onClick={() => handleRevoke(item)}
611+
className="px-4 py-1.5 text-white rounded shadow-md text-center focus:outline-none "
612+
style={{
613+
backgroundColor: modalSubmitBtnColor
614+
}}
615+
>
616+
Yes
617+
</button>
618+
<button
619+
onClick={handleClose}
620+
className="px-4 py-1.5 text-black border-[1px] border-[#ccc] shadow-md rounded focus:outline-none"
621+
style={{
622+
backgroundColor: modalCancelBtnColor
623+
}}
624+
>
625+
No
626+
</button>
627+
</div>
628+
</div>
629+
</ModalUi>
630+
)}
534631
</td>
535632
</tr>
536633
)

0 commit comments

Comments
 (0)