mirror of
https://github.com/OpenSignLabs/OpenSign.git
synced 2026-08-24 00:22:34 +02:00
feat: create duplicate template functionality feat: add support of csv and xlsx for bulk contacts import feat: add info text for forms and dashboard button feat: implement functionality to delete a PDF page while editing the document feat: show completed documents in which signers included but not owner in completed reports feat: add delete folder button in opensign drive feat: introduce Bcc email support for sending completed documents feat: allow merging multiple pdf while drafting document and template feat: add 'My Initials' tab for auto-signing in request-sign flow feat: add support for redirect URL to navigate after document completion feat: introduce privacy policy and digital signature terms before signing documents. feat: add feature to allow adding new pages to existing document feat: add save signature, initials, stamp functionality in sign pad for logged in user feat: add preferences menu feat: add save custom email template, notifyonsignature, set timezone, allow signature types in preferences feat: secure local url feat: implement Italian language translation feat: implement German language translation feat: update menu name from report to documents and shift contactbook in main menu feat: provide edit contact functionality fix: unable to delete folder when all its documents are deleted fix: fields.push is not function fix: document loading issue in opensign drive fix: adjust the guest signature flow to display the document in full screen, eliminating any blank space which is displayed below the place holder in mobile view fix: resolve issue of instance of pdfdict or pdfstream but got undefined build(deps): update dependencies refactor: change note text from add contact form
159 lines
5.0 KiB
JavaScript
159 lines
5.0 KiB
JavaScript
import React, { useEffect, useState } from "react";
|
|
import Parse from "parse";
|
|
import ReportTable from "../../primitives/GetReportDisplay";
|
|
import reportJson from "../../json/ReportJson";
|
|
import axios from "axios";
|
|
import Loader from "../../primitives/Loader";
|
|
import { useTranslation } from "react-i18next";
|
|
function DashboardReport(props) {
|
|
const { t } = useTranslation();
|
|
// console.log("props ", props)
|
|
const [List, setList] = useState([]);
|
|
const [isLoader, setIsLoader] = useState(true);
|
|
const [reportName, setReportName] = useState("");
|
|
const [actions, setActions] = useState([]);
|
|
const [heading, setHeading] = useState([]);
|
|
const [isNextRecord, setIsNextRecord] = useState(false);
|
|
const [isMoreDocs, setIsMoreDocs] = useState(true);
|
|
const abortController = new AbortController();
|
|
const docPerPage = 5;
|
|
|
|
useEffect(() => {
|
|
setReportName("");
|
|
getReportData(props.Record.reportId);
|
|
|
|
// Function returned from useEffect is called on unmount
|
|
return () => {
|
|
setIsLoader(true);
|
|
setList([]);
|
|
setIsNextRecord(false);
|
|
// Here it'll abort the fetch
|
|
abortController.abort();
|
|
};
|
|
// eslint-disable-next-line
|
|
}, [props.Record.reportId]);
|
|
|
|
// below useEffect call when isNextRecord state is true and fetch next record
|
|
useEffect(() => {
|
|
if (isNextRecord) {
|
|
getReportData(props.Record.reportId, List.length, 20);
|
|
}
|
|
// eslint-disable-next-line
|
|
}, [isNextRecord]);
|
|
|
|
const getReportData = async (id, skipUserRecord = 0, limit = 20) => {
|
|
setIsLoader(true);
|
|
const json = reportJson(id);
|
|
if (json) {
|
|
setActions(json.actions);
|
|
setReportName(json.reportName);
|
|
setHeading(json.heading);
|
|
const currentUser = Parse.User.current().id;
|
|
|
|
const headers = {
|
|
"Content-Type": "application/json",
|
|
"X-Parse-Application-Id": localStorage.getItem("parseAppId"),
|
|
sessiontoken: localStorage.getItem("accesstoken")
|
|
};
|
|
try {
|
|
const skipRecord = id === "5Go51Q7T8r" ? 0 : skipUserRecord;
|
|
const limitRecord = id === "5Go51Q7T8r" ? 200 : limit;
|
|
const params = { reportId: id, skip: skipRecord, limit: limitRecord };
|
|
const url = `${localStorage.getItem("baseUrl")}functions/getReport`;
|
|
const res = await axios.post(url, params, {
|
|
headers: headers,
|
|
signal: abortController.signal // is used to cancel fetch query
|
|
});
|
|
if (id === "5Go51Q7T8r") {
|
|
const listData = res.data?.result.filter((x) => x.Signers.length > 0);
|
|
let arr = [];
|
|
for (const obj of listData) {
|
|
const isSigner = obj.Signers.some(
|
|
(item) => item.UserId.objectId === currentUser
|
|
);
|
|
if (isSigner) {
|
|
let isRecord;
|
|
if (obj?.AuditTrail && obj?.AuditTrail.length > 0) {
|
|
isRecord = obj?.AuditTrail.some(
|
|
(item) =>
|
|
item?.UserPtr?.UserId?.objectId === currentUser &&
|
|
item.Activity === "Signed"
|
|
);
|
|
} else {
|
|
isRecord = false;
|
|
}
|
|
if (isRecord === false) {
|
|
arr.push(obj);
|
|
}
|
|
}
|
|
}
|
|
if (arr.length === docPerPage) {
|
|
setIsMoreDocs(true);
|
|
} else {
|
|
setIsMoreDocs(false);
|
|
}
|
|
setList((prevRecord) =>
|
|
prevRecord.length > 0 ? [...prevRecord, ...arr] : arr
|
|
);
|
|
} else {
|
|
if (res.data.result.length >= docPerPage) {
|
|
setIsMoreDocs(true);
|
|
} else {
|
|
setIsMoreDocs(false);
|
|
}
|
|
setIsNextRecord(false);
|
|
if (!res.data.result.error) {
|
|
setList((prevRecord) =>
|
|
prevRecord.length > 0
|
|
? [...prevRecord, ...res.data.result]
|
|
: res.data.result
|
|
);
|
|
}
|
|
}
|
|
setIsLoader(false);
|
|
} catch (err) {
|
|
const isCancel = axios.isCancel(err);
|
|
if (!isCancel) {
|
|
console.log("err ", err);
|
|
setIsLoader(false);
|
|
}
|
|
setIsLoader(false);
|
|
}
|
|
} else {
|
|
setIsLoader(false);
|
|
}
|
|
};
|
|
return (
|
|
<>
|
|
{isLoader ? (
|
|
<div className="h-[250px] flex justify-center items-center">
|
|
<Loader />
|
|
</div>
|
|
) : (
|
|
<>
|
|
{reportName ? (
|
|
<ReportTable
|
|
ReportName={reportName}
|
|
List={List}
|
|
setList={setList}
|
|
actions={actions}
|
|
heading={heading}
|
|
setIsNextRecord={setIsNextRecord}
|
|
isMoreDocs={isMoreDocs}
|
|
docPerPage={docPerPage}
|
|
/>
|
|
) : (
|
|
<div className="flex items-center justify-center h-[100px] w-full bg-white rounded">
|
|
<div className="text-center">
|
|
<p className="text-xl text-black">{t("report-not-found")}</p>
|
|
</div>
|
|
</div>
|
|
)}
|
|
</>
|
|
)}
|
|
</>
|
|
);
|
|
}
|
|
|
|
export default DashboardReport;
|