diff --git a/apps/OpenSign/src/primitives/GetReportDisplay.js b/apps/OpenSign/src/primitives/GetReportDisplay.js
index 259bad27c..46f832210 100644
--- a/apps/OpenSign/src/primitives/GetReportDisplay.js
+++ b/apps/OpenSign/src/primitives/GetReportDisplay.js
@@ -12,6 +12,7 @@ import Tour from "reactour";
import Parse from "parse";
import { saveAs } from "file-saver";
import {
+ checkIsSubscribedTeam,
// copytoData,
replaceMailVaribles
} from "../constant/Utils";
@@ -24,6 +25,9 @@ import ReactQuill from "react-quill";
import "react-quill/dist/quill.snow.css";
import BulkSendUi from "../components/BulkSendUi";
import Loader from "./Loader";
+import Select from "react-select";
+import { isEnableSubscription } from "../constant/const";
+import SubscribeCard from "./SubscribeCard";
const ReportTable = (props) => {
const navigate = useNavigate();
@@ -52,6 +56,10 @@ const ReportTable = (props) => {
const [templateDeatils, setTemplateDetails] = useState({});
const [placeholders, setPlaceholders] = useState([]);
const [isLoader, setIsLoader] = useState({});
+ const [isShareWith, setIsShareWith] = useState({});
+ const [departmentList, setDepartmentList] = useState([]);
+ const [selectedDepartments, setSelectedDepartments] = useState([]);
+ const onChange = (selectedOptions) => setSelectedDepartments(selectedOptions);
// const [selectedPublicRole, setSelectedPublicRole] = useState("");
// const [isCelebration, setIsCelebration] = useState(false);
// const [currentLists, setCurrentLists] = useState([]);
@@ -59,6 +67,9 @@ const ReportTable = (props) => {
// const [isPublicProfile, setIsPublicProfile] = useState({});
// const [publicUserName, setIsPublicUserName] = useState("");
const [isViewShare, setIsViewShare] = useState({});
+ const [isSubscribe, setIsSubscribe] = useState(true);
+ const Extand_Class = localStorage.getItem("Extand_Class");
+ const extClass = Extand_Class && JSON.parse(Extand_Class);
const startIndex = (currentPage - 1) * props.docPerPage;
const { isMoreDocs, setIsNextRecord } = props;
// For loop is used to calculate page numbers visible below table
@@ -125,9 +136,37 @@ const ReportTable = (props) => {
// below useEffect reset currenpage to 1 if user change route
useEffect(() => {
checkTourStatus();
+ fetchDepartmentList();
return () => setCurrentPage(1);
+ // eslint-disable-next-line
}, []);
+ // `fetchDepartmentList` is used to fetch department list for share with functionality
+ const fetchDepartmentList = async () => {
+ if (props.ReportName === "Templates") {
+ try {
+ const extUser = JSON.parse(localStorage.getItem("Extand_Class"))?.[0];
+ const department = new Parse.Query("contracts_Departments");
+ department.equalTo("OrganizationId", {
+ __type: "Pointer",
+ className: "contracts_Organizations",
+ objectId: extUser.OrganizationId.objectId
+ });
+ department.equalTo("IsActive", true);
+ const departmentRes = await department.find();
+ if (departmentRes.length > 0) {
+ const _departmentRes = JSON.parse(JSON.stringify(departmentRes));
+ const formatedList = _departmentRes.map((x) => ({
+ label: x.Name,
+ value: x.objectId
+ }));
+ setDepartmentList(formatedList);
+ }
+ } catch (err) {
+ console.log("Err in fetch top level departmentlist", err);
+ }
+ }
+ };
// `formatRow` is used to show data in poper manner like
// if data is of array type then it will join array items with ","
// if data is of object type then it Name values will be show in row
@@ -158,9 +197,7 @@ const ReportTable = (props) => {
} else {
setActLoader({ [`${item.objectId}_${act.btnId}`]: true });
try {
- const params = {
- templateId: item.objectId
- };
+ const params = { templateId: item.objectId };
const templateDeatils = await axios.post(
`${localStorage.getItem("baseUrl")}functions/getTemplate`,
params,
@@ -191,6 +228,19 @@ const ReportTable = (props) => {
});
}
+ // console.log("extClass ", extClass);
+ let extUserId = Doc.ExtUserPtr.objectId;
+ let creatorId = Doc.CreatedBy.objectId;
+ if (extClass && extClass.length > 0) {
+ if (Doc.ExtUserPtr?.objectId !== extClass[0].objectId) {
+ const Extand_Class = localStorage.getItem("Extand_Class");
+ const extClass = Extand_Class && JSON.parse(Extand_Class);
+ if (extClass && extClass.length > 0) {
+ extUserId = extClass[0].objectId;
+ creatorId = extClass[0]?.UserId.objectId;
+ }
+ }
+ }
let placeholdersArr = [];
if (Doc.Placeholders?.length > 0) {
placeholdersArr = Doc.Placeholders;
@@ -205,12 +255,12 @@ const ReportTable = (props) => {
ExtUserPtr: {
__type: "Pointer",
className: "contracts_Users",
- objectId: Doc.ExtUserPtr.objectId
+ objectId: extUserId
},
CreatedBy: {
__type: "Pointer",
className: "_User",
- objectId: Doc.CreatedBy.objectId
+ objectId: creatorId
},
Signers: signers,
SendinOrder: Doc?.SendinOrder || false,
@@ -221,7 +271,7 @@ const ReportTable = (props) => {
const res = await axios.post(
`${localStorage.getItem(
"baseUrl"
- )}classes/${localStorage.getItem("_appName")}_Document`,
+ )}classes/contracts_Document`,
data,
{
headers: {
@@ -282,7 +332,7 @@ const ReportTable = (props) => {
}
};
- const handleActionBtn = (act, item) => {
+ const handleActionBtn = async (act, item) => {
if (act.action === "redirect") {
handleURL(item, act);
} else if (act.action === "delete") {
@@ -297,6 +347,20 @@ const ReportTable = (props) => {
setIsResendMail({ [item.objectId]: true });
} else if (act.action === "bulksend") {
handleBulkSend(item);
+ } else if (act.action === "sharewith") {
+ if (isEnableSubscription) {
+ const getIsSubscribe = await checkIsSubscribedTeam();
+ setIsSubscribe(getIsSubscribe);
+ }
+ if (item?.SharedWith && item?.SharedWith.length > 0) {
+ // below code is used to get existing sharewith departments and formated them as per react-select
+ const formatedList = item?.SharedWith.map((x) => ({
+ label: x.Name,
+ value: x.objectId
+ }));
+ setSelectedDepartments(formatedList);
+ }
+ setIsShareWith({ [item.objectId]: true });
}
};
// Get current list
@@ -915,6 +979,41 @@ const ReportTable = (props) => {
// setTimeout(() => setIsAlert(false), 1500);
// };
+ // `handleShareWith` is used to save departments in sharedWith field
+ const handleShareWith = async (e, template) => {
+ e.preventDefault();
+ e.stopPropagation();
+ setIsShareWith({});
+ setActLoader({ [template.objectId]: true });
+ try {
+ const templateCls = new Parse.Object("contracts_Template");
+ templateCls.id = template.objectId;
+ const departmentArr = selectedDepartments.map((x) => ({
+ __type: "Pointer",
+ className: "contracts_Departments",
+ objectId: x.value
+ }));
+ templateCls.set("SharedWith", departmentArr);
+ const res = await templateCls.save();
+ if (res) {
+ setIsAlert(true);
+ setAlertMsg({
+ type: "success",
+ message: "Template Shared successfully."
+ });
+ }
+ } catch (err) {
+ setIsAlert(true);
+ setAlertMsg({
+ type: "danger",
+ message: "Something went wrong, Please try again later."
+ });
+ } finally {
+ setActLoader({});
+ setTimeout(() => setIsAlert(false), 1500);
+ }
+ };
+
return (
{Object.keys(actLoader)?.length > 0 && (
@@ -1253,55 +1352,132 @@ const ReportTable = (props) => {
{props.actions?.length > 0 &&
- props.actions.map((act, index) => (
- handleActionBtn(act, item)}
- title={act.hoverLabel}
- className={
- act.action !== "option"
- ? `${
- act?.btnColor ? act.btnColor : ""
- } op-btn op-btn-sm mr-1`
- : "text-base-content focus:outline-none text-lg mr-2 relative"
- }
- >
-
- {act.btnLabel && (
-
- {act.btnLabel}
-
- )}
- {isOption[item.objectId] &&
- act.action === "option" && (
-
- {act.subaction?.map((subact) => (
- -
- handleActionBtn(subact, item)
- }
- title={subact.hoverLabel}
- >
-
-
- {subact.btnLabel && (
-
- {subact.btnLabel}
+ props.actions.map(
+ (act, index) =>
+ (item.ExtUserPtr?.objectId ===
+ extClass?.[0]?.objectId ||
+ act.btnLabel === "Use") && (
+
handleActionBtn(act, item)}
+ title={act.hoverLabel}
+ className={
+ act.action !== "option"
+ ? `${
+ act?.btnColor ? act.btnColor : ""
+ } op-btn op-btn-sm mr-1`
+ : "text-base-content focus:outline-none text-lg mr-2 relative"
+ }
+ >
+
+ {act.btnLabel && (
+
+ {act.btnLabel}
+
+ )}
+ {isOption[item.objectId] &&
+ act.action === "option" && (
+
+ {act.subaction?.map((subact) => (
+ -
+ handleActionBtn(subact, item)
+ }
+ title={subact.hoverLabel}
+ >
+
+
+ {subact.btnLabel && (
+
+ {subact.btnLabel}
+
+ )}
- )}
-
-
- ))}
-
- )}
-
- ))}
+
+ ))}
+
+ )}
+
+ )
+ )}
+ {isShareWith[item.objectId] && (
+
+
+ {isSubscribe && isEnableSubscription && (
+ <>
+
+ Share with
+
+ setIsShareWith({})}
+ >
+ ✕
+
+
+ >
+ )}
+ {!isSubscribe && isEnableSubscription && (
+ <>
+ setIsShareWith({})}
+ >
+ ✕
+
+
+ >
+ )}
+
+
+ )}
{isViewShare[item.objectId] && (
{
+const SubscribeCard = ({ plan, price }) => {
const navigate = useNavigate();
return (
- Upgrade to PRO Plan
- $29.99/month: Sign 100 docs using API. Only $0.15/doc after that.
+ Upgrade to {plan ? plan : "PRO"} Plan
+
+ ${price ? price : "29.99"}/month: Sign 100 docs using API. Only
+ $0.15/doc after that.
+
|