mirror of
https://github.com/OpenSignLabs/OpenSign.git
synced 2026-08-21 07:02:32 +02:00
fix: provide route to upgrade from v1 to v2 for self hosting
This commit is contained in:
File diff suppressed because one or more lines are too long
@@ -84,7 +84,7 @@ function App() {
|
||||
element={<LazyPage Page={AddAdmin} />}
|
||||
/>
|
||||
<Route
|
||||
path="/addexistadmin"
|
||||
path="/upgrade-2.1"
|
||||
element={<LazyPage Page={UpdateExistUserAdmin} />}
|
||||
/>
|
||||
</>
|
||||
@@ -136,7 +136,9 @@ function App() {
|
||||
</>
|
||||
)}
|
||||
<Route element={<HomeLayout />}>
|
||||
<Route path="/teams" element={<TeamList />} />
|
||||
{isEnableSubscription && (
|
||||
<Route path="/teams" element={<TeamList />} />
|
||||
)}
|
||||
<Route path="/users" element={<UserList />} />
|
||||
<Route
|
||||
path="/changepassword"
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import React, { useState, useEffect } from "react";
|
||||
import Parse from "parse";
|
||||
import axios from "axios";
|
||||
import Loader from "../primitives/Loader";
|
||||
|
||||
const AddSigner = (props) => {
|
||||
@@ -10,8 +9,6 @@ const AddSigner = (props) => {
|
||||
const [addYourself, setAddYourself] = useState(false);
|
||||
const [isLoader, setIsLoader] = useState(false);
|
||||
const [isUserExist, setIsUserExist] = useState(false);
|
||||
const parseBaseUrl = localStorage.getItem("baseUrl");
|
||||
const parseAppId = localStorage.getItem("parseAppId");
|
||||
|
||||
useEffect(() => {
|
||||
checkUserExist();
|
||||
@@ -85,18 +82,6 @@ const AddSigner = (props) => {
|
||||
}
|
||||
const user = await _user.save();
|
||||
if (user) {
|
||||
const roleurl = `${parseBaseUrl}functions/AddUserToRole`;
|
||||
const headers = {
|
||||
"Content-Type": "application/json",
|
||||
"X-Parse-Application-Id": parseAppId,
|
||||
sessionToken: localStorage.getItem("accesstoken")
|
||||
};
|
||||
const body = {
|
||||
appName: "contracts",
|
||||
roleName: "contracts_Guest",
|
||||
userId: user.id
|
||||
};
|
||||
await axios.post(roleurl, body, { headers: headers });
|
||||
const currentUser = Parse.User.current();
|
||||
contactQuery.set(
|
||||
"CreatedBy",
|
||||
@@ -140,18 +125,6 @@ const AddSigner = (props) => {
|
||||
if (err.code === 202) {
|
||||
const params = { email: email };
|
||||
const userRes = await Parse.Cloud.run("getUserId", params);
|
||||
const roleurl = `${parseBaseUrl}functions/AddUserToRole`;
|
||||
const headers = {
|
||||
"Content-Type": "application/json",
|
||||
"X-Parse-Application-Id": parseAppId,
|
||||
sessionToken: localStorage.getItem("accesstoken")
|
||||
};
|
||||
const body = {
|
||||
appName: "contracts",
|
||||
roleName: "contracts_Guest",
|
||||
userId: userRes.id
|
||||
};
|
||||
await axios.post(roleurl, body, { headers: headers });
|
||||
const currentUser = Parse.User.current();
|
||||
contactQuery.set(
|
||||
"CreatedBy",
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import React, { useEffect, useState } from "react";
|
||||
import Parse from "parse";
|
||||
import axios from "axios";
|
||||
import Title from "./Title";
|
||||
import Loader from "../primitives/Loader";
|
||||
import { copytoData } from "../constant/Utils";
|
||||
@@ -29,8 +28,6 @@ const AddUser = (props) => {
|
||||
const [isLoader, setIsLoader] = useState(false);
|
||||
const [teamList, setTeamList] = useState([]);
|
||||
const role = ["OrgAdmin", "Editor", "User"];
|
||||
const parseBaseUrl = localStorage.getItem("baseUrl");
|
||||
const parseAppId = localStorage.getItem("parseAppId");
|
||||
|
||||
useEffect(() => {
|
||||
getTeamList();
|
||||
@@ -132,18 +129,6 @@ const AddUser = (props) => {
|
||||
|
||||
const user = await _user.save();
|
||||
if (user) {
|
||||
const roleurl = `${parseBaseUrl}functions/AddUserToRole`;
|
||||
const headers = {
|
||||
"Content-Type": "application/json",
|
||||
"X-Parse-Application-Id": parseAppId,
|
||||
sessionToken: localStorage.getItem("accesstoken")
|
||||
};
|
||||
const body = {
|
||||
appName: "contracts",
|
||||
roleName: "contracts_" + formdata.role,
|
||||
userId: user.id
|
||||
};
|
||||
await axios.post(roleurl, body, { headers: headers });
|
||||
const currentUser = Parse.User.current();
|
||||
extUser.set(
|
||||
"CreatedBy",
|
||||
@@ -190,18 +175,6 @@ const AddUser = (props) => {
|
||||
if (err.code === 202) {
|
||||
const params = { email: formdata.email };
|
||||
const userRes = await Parse.Cloud.run("getUserId", params);
|
||||
const roleurl = `${parseBaseUrl}functions/AddUserToRole`;
|
||||
const headers = {
|
||||
"Content-Type": "application/json",
|
||||
"X-Parse-Application-Id": parseAppId,
|
||||
sessionToken: localStorage.getItem("accesstoken")
|
||||
};
|
||||
const body = {
|
||||
appName: "contracts",
|
||||
roleName: "contracts_" + formdata.role,
|
||||
userId: userRes.id
|
||||
};
|
||||
await axios.post(roleurl, body, { headers: headers });
|
||||
const currentUser = Parse.User.current();
|
||||
extUser.set(
|
||||
"CreatedBy",
|
||||
|
||||
@@ -7,6 +7,7 @@ import { useDispatch } from "react-redux";
|
||||
import { showTenant } from "../redux/reducers/ShowTenant";
|
||||
import Loader from "../primitives/Loader";
|
||||
import axios from "axios";
|
||||
import Title from "../components/Title";
|
||||
|
||||
const AddAdmin = () => {
|
||||
const navigate = useNavigate();
|
||||
@@ -152,7 +153,7 @@ const AddAdmin = () => {
|
||||
const res = await Parse.User.become(sessionToken);
|
||||
if (res) {
|
||||
const _user = JSON.parse(JSON.stringify(res));
|
||||
console.log("_user ", _user);
|
||||
// console.log("_user ", _user);
|
||||
localStorage.setItem("accesstoken", sessionToken);
|
||||
localStorage.setItem("UserInformation", JSON.stringify(_user));
|
||||
localStorage.setItem("accesstoken", _user.sessionToken);
|
||||
@@ -256,6 +257,7 @@ const AddAdmin = () => {
|
||||
};
|
||||
return (
|
||||
<div className="h-screen flex justify-center">
|
||||
<Title title={"Add admin"} />
|
||||
{state.loading ? (
|
||||
<div className="text-[grey] flex justify-center items-center text-lg md:text-2xl">
|
||||
<Loader />
|
||||
|
||||
@@ -200,9 +200,6 @@ function Login() {
|
||||
alertMsg:
|
||||
"You don't have access, please contact the admin."
|
||||
});
|
||||
setTimeout(() => {
|
||||
setState({ ...state, alertMsg: "" });
|
||||
}, 2000);
|
||||
logOutUser();
|
||||
}
|
||||
} else {
|
||||
@@ -218,27 +215,22 @@ function Login() {
|
||||
} catch (error) {
|
||||
setState({
|
||||
...state,
|
||||
loading: false,
|
||||
alertType: "danger",
|
||||
alertMsg: `${error.message}`
|
||||
});
|
||||
setTimeout(() => {
|
||||
setState({ ...state, alertMsg: "" });
|
||||
}, 2000);
|
||||
console.log(error);
|
||||
}
|
||||
}
|
||||
} catch (error) {
|
||||
setState({
|
||||
...state,
|
||||
loading: false,
|
||||
alertType: "danger",
|
||||
alertMsg: "Invalid username or password!"
|
||||
});
|
||||
setTimeout(() => {
|
||||
setState({ ...state, alertMsg: "" });
|
||||
}, 2000);
|
||||
console.error("Error while logging in user", error);
|
||||
} finally {
|
||||
setState({ ...state, loading: false });
|
||||
setTimeout(() => setState({ ...state, alertMsg: "" }), 2000);
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -325,8 +317,6 @@ function Login() {
|
||||
localStorage.setItem("PageLanding", menu.pageId);
|
||||
localStorage.setItem("defaultmenuid", menu.menuId);
|
||||
localStorage.setItem("pageType", menu.pageType);
|
||||
setThirdpartyLoader(false);
|
||||
setState({ ...state, loading: false });
|
||||
if (isEnableSubscription) {
|
||||
const res = await fetchSubscription();
|
||||
const freeplan = res.plan;
|
||||
@@ -356,41 +346,44 @@ function Login() {
|
||||
}
|
||||
}
|
||||
} else {
|
||||
setThirdpartyLoader(false);
|
||||
setState({
|
||||
...state,
|
||||
loading: false,
|
||||
alertType: "danger",
|
||||
alertMsg: "You don't have access, please contact the admin."
|
||||
});
|
||||
setTimeout(() => {
|
||||
setState({ ...state, alertMsg: "" });
|
||||
}, 2000);
|
||||
logOutUser();
|
||||
}
|
||||
} else {
|
||||
setThirdpartyLoader(false);
|
||||
setState({ ...state, loading: false });
|
||||
setState({
|
||||
...state,
|
||||
alertType: "danger",
|
||||
alertMsg: "User not found."
|
||||
});
|
||||
logOutUser();
|
||||
}
|
||||
})
|
||||
.catch((err) => {
|
||||
console.error("err in fetching extUser", err);
|
||||
setState({
|
||||
...state,
|
||||
alertType: "danger",
|
||||
alertMsg: `${err.message}`
|
||||
});
|
||||
const payload = { sessionToken: sessionToken };
|
||||
setThirdpartyLoader(false);
|
||||
handleSubmitbtn(payload);
|
||||
});
|
||||
} catch (error) {
|
||||
setThirdpartyLoader(false);
|
||||
setState({
|
||||
...state,
|
||||
loading: false,
|
||||
alertType: "danger",
|
||||
alertMsg: `${error.message}`
|
||||
});
|
||||
setTimeout(() => {
|
||||
setState({ ...state, alertMsg: "" });
|
||||
}, 2000);
|
||||
console.log(error);
|
||||
} finally {
|
||||
setThirdpartyLoader(false);
|
||||
setState({ ...state, loading: false });
|
||||
setTimeout(() => setState({ ...state, alertMsg: "" }), 2000);
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -478,16 +471,27 @@ function Login() {
|
||||
alertType: "danger",
|
||||
alertMsg: "You don't have access, please contact the admin."
|
||||
});
|
||||
setTimeout(() => {
|
||||
setState({ ...state, alertMsg: "" });
|
||||
}, 2000);
|
||||
logOutUser();
|
||||
}
|
||||
} else {
|
||||
setState({
|
||||
...state,
|
||||
alertType: "danger",
|
||||
alertMsg: "User not found."
|
||||
});
|
||||
logOutUser();
|
||||
}
|
||||
});
|
||||
} catch (error) {
|
||||
setState({ ...state, loading: false });
|
||||
setState({
|
||||
...state,
|
||||
alertType: "danger",
|
||||
alertMsg: "Something went wrong, please try again later."
|
||||
});
|
||||
console.log("err", error);
|
||||
} finally {
|
||||
setState({ ...state, loading: false });
|
||||
setTimeout(() => setState({ ...state, alertMsg: "" }), 2000);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -222,7 +222,7 @@ const SSOVerify = () => {
|
||||
setMessage("Error: User not exist.");
|
||||
});
|
||||
} catch (err) {
|
||||
console.log("err in usergroups", err);
|
||||
console.log("err in getuserdetails", err);
|
||||
}
|
||||
}
|
||||
} catch (err) {
|
||||
|
||||
+238
-202
@@ -10,6 +10,7 @@ import AddTeam from "../components/AddTeam";
|
||||
import { isEnableSubscription } from "../constant/const";
|
||||
import { checkIsSubscribedTeam } from "../constant/Utils";
|
||||
import SubscribeCard from "../primitives/SubscribeCard";
|
||||
import Title from "../components/Title";
|
||||
|
||||
const heading = ["Sr.No", "Name", "Parent Team", "Active"];
|
||||
const actions = [
|
||||
@@ -37,6 +38,7 @@ const TeamList = () => {
|
||||
const [isActLoader, setIsActLoader] = useState({});
|
||||
const [isSubscribe, setIsSubscribe] = useState(false);
|
||||
const [isEditModal, setIsEditModal] = useState({});
|
||||
const [isAdmin, setIsAdmin] = useState(false);
|
||||
const startIndex = (currentPage - 1) * recordperPage; // user per page
|
||||
|
||||
const getPaginationRange = () => {
|
||||
@@ -102,6 +104,15 @@ const TeamList = () => {
|
||||
setIsSubscribe(getIsSubscribe);
|
||||
}
|
||||
const extUser = JSON.parse(localStorage.getItem("Extand_Class"))?.[0];
|
||||
if (extUser) {
|
||||
const admin =
|
||||
extUser?.UserRole &&
|
||||
(extUser?.UserRole === "contracts_Admin" ||
|
||||
extUser?.UserRole === "contracts_OrgAdmin")
|
||||
? true
|
||||
: false;
|
||||
setIsAdmin(admin);
|
||||
}
|
||||
const teamCls = new Parse.Query("contracts_Teams");
|
||||
teamCls.equalTo("OrganizationId", {
|
||||
__type: "Pointer",
|
||||
@@ -207,6 +218,7 @@ const TeamList = () => {
|
||||
};
|
||||
return (
|
||||
<div className="relative">
|
||||
<Title title={"Teams"} />
|
||||
{isLoader && (
|
||||
<div className="absolute w-full h-[300px] md:h-[400px] flex justify-center items-center z-30 rounded-box">
|
||||
<Loader />
|
||||
@@ -218,211 +230,235 @@ const TeamList = () => {
|
||||
</div>
|
||||
)}
|
||||
{isSubscribe && isEnableSubscription && !isLoader && (
|
||||
<div className="p-2 w-full bg-base-100 text-base-content op-card shadow-lg">
|
||||
{isAlert.msg && (
|
||||
<Alert type={isAlert.type}>
|
||||
<div className="ml-3">{isAlert.msg}</div>
|
||||
</Alert>
|
||||
)}
|
||||
<div className="flex flex-row items-center justify-between my-2 mx-3 text-[20px] md:text-[23px]">
|
||||
<div className="font-light">
|
||||
Teams{" "}
|
||||
<span className="text-xs md:text-[13px] font-normal">
|
||||
<Tooltip message={"Teams"} />
|
||||
</span>
|
||||
</div>
|
||||
<div className="cursor-pointer" onClick={() => handleFormModal()}>
|
||||
<i className="fa-light fa-square-plus text-accent text-[40px]"></i>
|
||||
</div>
|
||||
</div>
|
||||
<div className={` overflow-x-auto w-full`}>
|
||||
<table className="op-table border-collapse w-full">
|
||||
<thead className="text-[14px]">
|
||||
<tr className="border-y-[1px]">
|
||||
{heading?.map((item, index) => (
|
||||
<React.Fragment key={index}>
|
||||
<th className="px-4 py-2">{item}</th>
|
||||
</React.Fragment>
|
||||
))}
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody className="text-[12px]">
|
||||
{teamList?.length > 0 && (
|
||||
<>
|
||||
{currentList.map((item, index) => (
|
||||
<tr className="border-y-[1px]" key={index}>
|
||||
{heading.includes("Sr.No") && (
|
||||
<th className="px-4 py-2">
|
||||
{startIndex + index + 1}
|
||||
</th>
|
||||
)}
|
||||
<td className="px-4 py-2 font-semibold">
|
||||
{item?.Name}
|
||||
</td>
|
||||
<td className="px-4 py-2 font-semibold">
|
||||
{item?.ParentId?.Name || "-"}
|
||||
</td>
|
||||
<td className="px-4 py-2 font-semibold">
|
||||
{item?.Name !== "All Users" && (
|
||||
<>
|
||||
<label className="cursor-pointer relative block items-center mb-0">
|
||||
<input
|
||||
type="checkbox"
|
||||
className="op-toggle transition-all op-toggle-secondary"
|
||||
checked={item?.IsActive}
|
||||
onChange={() => handleToggleBtn(item)}
|
||||
/>
|
||||
</label>
|
||||
{isActiveModal[item.objectId] && (
|
||||
<ModalUi
|
||||
isOpen
|
||||
title={"Team status"}
|
||||
handleClose={handleClose}
|
||||
>
|
||||
<div className="m-[20px]">
|
||||
<div className="text-lg font-normal text-black">
|
||||
Are you sure you want to{" "}
|
||||
{item?.IsActive ? "disable" : "enable"}{" "}
|
||||
this team?
|
||||
</div>
|
||||
<hr className="bg-[#ccc] mt-4 " />
|
||||
<div className="flex items-center mt-3 gap-2 text-white">
|
||||
<button
|
||||
onClick={() => handleToggleSubmit(item)}
|
||||
className="op-btn op-btn-primary"
|
||||
>
|
||||
Yes
|
||||
</button>
|
||||
<button
|
||||
onClick={handleClose}
|
||||
className="op-btn op-btn-secondary"
|
||||
>
|
||||
No
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</ModalUi>
|
||||
)}
|
||||
</>
|
||||
)}
|
||||
</td>
|
||||
<td className="px-3 py-2 text-white flex flex-wrap gap-1">
|
||||
{item?.Name !== "All Users" && (
|
||||
<>
|
||||
{actions?.length > 0 &&
|
||||
actions.map((act, index) => (
|
||||
<button
|
||||
key={index}
|
||||
onClick={() => handleActionBtn(act, item)}
|
||||
title={act.hoverLabel}
|
||||
className={`${
|
||||
act?.btnColor ? act.btnColor : ""
|
||||
} op-btn op-btn-sm w-[50px]`}
|
||||
>
|
||||
<i className={act.btnIcon}></i>
|
||||
</button>
|
||||
))}
|
||||
{isEditModal[item.objectId] && (
|
||||
<ModalUi
|
||||
isOpen
|
||||
title={"Edit Team"}
|
||||
handleClose={handleClose}
|
||||
>
|
||||
<form
|
||||
className="m-[20px]"
|
||||
onSubmit={(e) => updateTeamName(e, item)}
|
||||
>
|
||||
<label className="text-xs font-semibold text-base-content ml-1">
|
||||
Name of Team{" "}
|
||||
<span className="text-[red] text-[13px]">
|
||||
*
|
||||
</span>
|
||||
</label>
|
||||
<input
|
||||
className="op-input op-input-bordered op-input-sm focus:outline-none hover:border-base-content text-base-content w-full text-xs"
|
||||
value={item.Name}
|
||||
onChange={(e) =>
|
||||
handleEditChange(e, item)
|
||||
}
|
||||
required
|
||||
/>
|
||||
<button
|
||||
type="submit"
|
||||
className="op-btn op-btn-primary mt-3"
|
||||
>
|
||||
Save
|
||||
</button>
|
||||
</form>
|
||||
</ModalUi>
|
||||
)}
|
||||
</>
|
||||
)}
|
||||
</td>
|
||||
</tr>
|
||||
))}
|
||||
</>
|
||||
)}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<div className="op-join flex flex-wrap items-center p-2">
|
||||
{teamList.length > recordperPage && (
|
||||
<button
|
||||
onClick={() => paginateBack()}
|
||||
className="op-join-item op-btn op-btn-sm"
|
||||
>
|
||||
Prev
|
||||
</button>
|
||||
)}
|
||||
{pageNumbers.map((x, i) => (
|
||||
<button
|
||||
key={i}
|
||||
onClick={() => setCurrentPage(x)}
|
||||
disabled={x === "..."}
|
||||
className={`${
|
||||
x === currentPage ? "op-btn-active" : ""
|
||||
} op-join-item op-btn op-btn-sm`}
|
||||
>
|
||||
{x}
|
||||
</button>
|
||||
))}
|
||||
{teamList.length > recordperPage && (
|
||||
<button
|
||||
onClick={() => paginateFront()}
|
||||
className="op-join-item op-btn op-btn-sm"
|
||||
>
|
||||
Next
|
||||
</button>
|
||||
)}
|
||||
</div>
|
||||
{teamList?.length <= 0 && (
|
||||
<div
|
||||
className={`${
|
||||
isDashboard ? "h-[317px]" : ""
|
||||
} flex flex-col items-center justify-center w-ful bg-base-100 text-base-content rounded-xl py-4`}
|
||||
>
|
||||
<div className="w-[60px] h-[60px] overflow-hidden">
|
||||
<img
|
||||
className="w-full h-full object-contain"
|
||||
src={pad}
|
||||
alt="img"
|
||||
/>
|
||||
<>
|
||||
{isAdmin ? (
|
||||
<div className="p-2 w-full bg-base-100 text-base-content op-card shadow-lg">
|
||||
{isAlert.msg && (
|
||||
<Alert type={isAlert.type}>
|
||||
<div className="ml-3">{isAlert.msg}</div>
|
||||
</Alert>
|
||||
)}
|
||||
<div className="flex flex-row items-center justify-between my-2 mx-3 text-[20px] md:text-[23px]">
|
||||
<div className="font-light">
|
||||
Teams{" "}
|
||||
<span className="text-xs md:text-[13px] font-normal">
|
||||
<Tooltip message={"Teams"} />
|
||||
</span>
|
||||
</div>
|
||||
<div
|
||||
className="cursor-pointer"
|
||||
onClick={() => handleFormModal()}
|
||||
>
|
||||
<i className="fa-light fa-square-plus text-accent text-[40px]"></i>
|
||||
</div>
|
||||
</div>
|
||||
<div className={` overflow-x-auto w-full`}>
|
||||
<table className="op-table border-collapse w-full">
|
||||
<thead className="text-[14px]">
|
||||
<tr className="border-y-[1px]">
|
||||
{heading?.map((item, index) => (
|
||||
<React.Fragment key={index}>
|
||||
<th className="px-4 py-2">{item}</th>
|
||||
</React.Fragment>
|
||||
))}
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody className="text-[12px]">
|
||||
{teamList?.length > 0 && (
|
||||
<>
|
||||
{currentList.map((item, index) => (
|
||||
<tr className="border-y-[1px]" key={index}>
|
||||
{heading.includes("Sr.No") && (
|
||||
<th className="px-4 py-2">
|
||||
{startIndex + index + 1}
|
||||
</th>
|
||||
)}
|
||||
<td className="px-4 py-2 font-semibold">
|
||||
{item?.Name}
|
||||
</td>
|
||||
<td className="px-4 py-2 font-semibold">
|
||||
{item?.ParentId?.Name || "-"}
|
||||
</td>
|
||||
<td className="px-4 py-2 font-semibold">
|
||||
{item?.Name !== "All Users" && (
|
||||
<>
|
||||
<label className="cursor-pointer relative block items-center mb-0">
|
||||
<input
|
||||
type="checkbox"
|
||||
className="op-toggle transition-all op-toggle-secondary"
|
||||
checked={item?.IsActive}
|
||||
onChange={() => handleToggleBtn(item)}
|
||||
/>
|
||||
</label>
|
||||
{isActiveModal[item.objectId] && (
|
||||
<ModalUi
|
||||
isOpen
|
||||
title={"Team status"}
|
||||
handleClose={handleClose}
|
||||
>
|
||||
<div className="m-[20px]">
|
||||
<div className="text-lg font-normal text-black">
|
||||
Are you sure you want to{" "}
|
||||
{item?.IsActive
|
||||
? "disable"
|
||||
: "enable"}{" "}
|
||||
this team?
|
||||
</div>
|
||||
<hr className="bg-[#ccc] mt-4 " />
|
||||
<div className="flex items-center mt-3 gap-2 text-white">
|
||||
<button
|
||||
onClick={() =>
|
||||
handleToggleSubmit(item)
|
||||
}
|
||||
className="op-btn op-btn-primary"
|
||||
>
|
||||
Yes
|
||||
</button>
|
||||
<button
|
||||
onClick={handleClose}
|
||||
className="op-btn op-btn-secondary"
|
||||
>
|
||||
No
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</ModalUi>
|
||||
)}
|
||||
</>
|
||||
)}
|
||||
</td>
|
||||
<td className="px-3 py-2 text-white flex flex-wrap gap-1">
|
||||
{item?.Name !== "All Users" && (
|
||||
<>
|
||||
{actions?.length > 0 &&
|
||||
actions.map((act, index) => (
|
||||
<button
|
||||
key={index}
|
||||
onClick={() =>
|
||||
handleActionBtn(act, item)
|
||||
}
|
||||
title={act.hoverLabel}
|
||||
className={`${
|
||||
act?.btnColor ? act.btnColor : ""
|
||||
} op-btn op-btn-sm w-[50px]`}
|
||||
>
|
||||
<i className={act.btnIcon}></i>
|
||||
</button>
|
||||
))}
|
||||
{isEditModal[item.objectId] && (
|
||||
<ModalUi
|
||||
isOpen
|
||||
title={"Edit Team"}
|
||||
handleClose={handleClose}
|
||||
>
|
||||
<form
|
||||
className="m-[20px]"
|
||||
onSubmit={(e) =>
|
||||
updateTeamName(e, item)
|
||||
}
|
||||
>
|
||||
<label className="text-xs font-semibold text-base-content ml-1">
|
||||
Name of Team{" "}
|
||||
<span className="text-[red] text-[13px]">
|
||||
*
|
||||
</span>
|
||||
</label>
|
||||
<input
|
||||
className="op-input op-input-bordered op-input-sm focus:outline-none hover:border-base-content text-base-content w-full text-xs"
|
||||
value={item.Name}
|
||||
onChange={(e) =>
|
||||
handleEditChange(e, item)
|
||||
}
|
||||
required
|
||||
/>
|
||||
<button
|
||||
type="submit"
|
||||
className="op-btn op-btn-primary mt-3"
|
||||
>
|
||||
Save
|
||||
</button>
|
||||
</form>
|
||||
</ModalUi>
|
||||
)}
|
||||
</>
|
||||
)}
|
||||
</td>
|
||||
</tr>
|
||||
))}
|
||||
</>
|
||||
)}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<div className="op-join flex flex-wrap items-center p-2">
|
||||
{teamList.length > recordperPage && (
|
||||
<button
|
||||
onClick={() => paginateBack()}
|
||||
className="op-join-item op-btn op-btn-sm"
|
||||
>
|
||||
Prev
|
||||
</button>
|
||||
)}
|
||||
{pageNumbers.map((x, i) => (
|
||||
<button
|
||||
key={i}
|
||||
onClick={() => setCurrentPage(x)}
|
||||
disabled={x === "..."}
|
||||
className={`${
|
||||
x === currentPage ? "op-btn-active" : ""
|
||||
} op-join-item op-btn op-btn-sm`}
|
||||
>
|
||||
{x}
|
||||
</button>
|
||||
))}
|
||||
{teamList.length > recordperPage && (
|
||||
<button
|
||||
onClick={() => paginateFront()}
|
||||
className="op-join-item op-btn op-btn-sm"
|
||||
>
|
||||
Next
|
||||
</button>
|
||||
)}
|
||||
</div>
|
||||
{teamList?.length <= 0 && (
|
||||
<div
|
||||
className={`${
|
||||
isDashboard ? "h-[317px]" : ""
|
||||
} flex flex-col items-center justify-center w-ful bg-base-100 text-base-content rounded-xl py-4`}
|
||||
>
|
||||
<div className="w-[60px] h-[60px] overflow-hidden">
|
||||
<img
|
||||
className="w-full h-full object-contain"
|
||||
src={pad}
|
||||
alt="img"
|
||||
/>
|
||||
</div>
|
||||
<div className="text-sm font-semibold">No Data Available</div>
|
||||
</div>
|
||||
)}
|
||||
<ModalUi
|
||||
title={"Add Team"}
|
||||
isOpen={isModal}
|
||||
handleClose={handleFormModal}
|
||||
>
|
||||
<AddTeam
|
||||
setIsAlert={setIsAlert}
|
||||
handleTeamInfo={handleTeamInfo}
|
||||
closePopup={handleFormModal}
|
||||
/>
|
||||
</ModalUi>
|
||||
</div>
|
||||
) : (
|
||||
<div className="flex items-center justify-center h-screen w-full bg-base-100 text-base-content rounded-box">
|
||||
<div className="text-center">
|
||||
<h1 className="text-[60px] lg:text-[120px] font-semibold">
|
||||
404
|
||||
</h1>
|
||||
<p className="text-[30px] lg:text-[50px]">Page Not Found</p>
|
||||
</div>
|
||||
<div className="text-sm font-semibold">No Data Available</div>
|
||||
</div>
|
||||
)}
|
||||
<ModalUi
|
||||
title={"Add Team"}
|
||||
isOpen={isModal}
|
||||
handleClose={handleFormModal}
|
||||
>
|
||||
<AddTeam
|
||||
setIsAlert={setIsAlert}
|
||||
handleTeamInfo={handleTeamInfo}
|
||||
closePopup={handleFormModal}
|
||||
/>
|
||||
</ModalUi>
|
||||
</div>
|
||||
</>
|
||||
)}
|
||||
{!isSubscribe && isEnableSubscription && !isLoader && (
|
||||
<div data-tut="apisubscribe">
|
||||
|
||||
@@ -3,6 +3,7 @@ import Loader from "../primitives/Loader";
|
||||
import Parse from "parse";
|
||||
import { NavLink, useNavigate } from "react-router-dom";
|
||||
import Alert from "../primitives/Alert";
|
||||
import Title from "../components/Title";
|
||||
|
||||
const UpdateExistUserAdmin = () => {
|
||||
const navigate = useNavigate();
|
||||
@@ -38,7 +39,7 @@ const UpdateExistUserAdmin = () => {
|
||||
"updateuserasadmin",
|
||||
formdata
|
||||
);
|
||||
console.log("updateUserAsAdmin ", updateUserAsAdmin);
|
||||
// console.log("updateUserAsAdmin ", updateUserAsAdmin);
|
||||
if (updateUserAsAdmin === "admin_created") {
|
||||
setIsAlert({ type: "success", msg: "Admin created" });
|
||||
navigate("/");
|
||||
@@ -57,12 +58,13 @@ const UpdateExistUserAdmin = () => {
|
||||
} finally {
|
||||
setIsSubmitLoading(false);
|
||||
setTimeout(() => {
|
||||
setIsAlert((prev) => ({ type: "danger", msg: "" }));
|
||||
setIsAlert(() => ({ type: "danger", msg: "" }));
|
||||
}, 2000);
|
||||
}
|
||||
};
|
||||
return (
|
||||
<div className="h-screen flex justify-center">
|
||||
<Title title={"Add Admin"} />
|
||||
{isAlert.msg && (
|
||||
<Alert type={isAlert.type}>
|
||||
<div className="ml-3">{isAlert.msg}</div>
|
||||
|
||||
+185
-153
@@ -10,6 +10,7 @@ import AddUser from "../components/AddUser";
|
||||
import SubscribeCard from "../primitives/SubscribeCard";
|
||||
import { isEnableSubscription } from "../constant/const";
|
||||
import { checkIsSubscribedTeam } from "../constant/Utils";
|
||||
import Title from "../components/Title";
|
||||
const heading = ["Sr.No", "Name", "Email", "Phone", "Role", "Team", "Active"];
|
||||
// const actions = [];
|
||||
const UserList = () => {
|
||||
@@ -24,6 +25,7 @@ const UserList = () => {
|
||||
const [isActiveModal, setIsActiveModal] = useState({});
|
||||
const [isActLoader, setIsActLoader] = useState({});
|
||||
const [isSubscribe, setIsSubscribe] = useState(false);
|
||||
const [isAdmin, setIsAdmin] = useState(false);
|
||||
const recordperPage = 10;
|
||||
const startIndex = (currentPage - 1) * recordperPage; // user per page
|
||||
|
||||
@@ -92,6 +94,15 @@ const UserList = () => {
|
||||
setIsSubscribe(true);
|
||||
}
|
||||
const extUser = JSON.parse(localStorage.getItem("Extand_Class"))?.[0];
|
||||
if (extUser) {
|
||||
const admin =
|
||||
extUser?.UserRole &&
|
||||
(extUser?.UserRole === "contracts_Admin" ||
|
||||
extUser?.UserRole === "contracts_OrgAdmin")
|
||||
? true
|
||||
: false;
|
||||
setIsAdmin(admin);
|
||||
}
|
||||
const res = await Parse.Cloud.run("getuserlistbyorg", {
|
||||
organizationId: extUser.OrganizationId.objectId
|
||||
});
|
||||
@@ -171,6 +182,7 @@ const UserList = () => {
|
||||
};
|
||||
return (
|
||||
<div className="relative">
|
||||
<Title title={isAdmin ? "Users" : "Page not found"} />
|
||||
{isLoader && (
|
||||
<div className="absolute w-full h-[300px] md:h-[400px] flex justify-center items-center z-30 rounded-box">
|
||||
<Loader />
|
||||
@@ -182,98 +194,107 @@ const UserList = () => {
|
||||
</div>
|
||||
)}
|
||||
{isSubscribe && !isLoader && (
|
||||
<div className="p-2 w-full bg-base-100 text-base-content op-card shadow-lg">
|
||||
{isAlert.msg && (
|
||||
<Alert type={isAlert.type}>
|
||||
<div className="ml-3">{isAlert.msg}</div>
|
||||
</Alert>
|
||||
)}
|
||||
<div className="flex flex-row items-center justify-between my-2 mx-3 text-[20px] md:text-[23px]">
|
||||
<div className="font-light">
|
||||
Users{" "}
|
||||
<span className="text-xs md:text-[13px] font-normal">
|
||||
<Tooltip message={"users from Teams"} />
|
||||
</span>
|
||||
</div>
|
||||
<div className="cursor-pointer" onClick={() => handleFormModal()}>
|
||||
<i className="fa-light fa-square-plus text-accent text-[40px]"></i>
|
||||
</div>
|
||||
</div>
|
||||
<div className={` overflow-x-auto w-full`}>
|
||||
<table className="op-table border-collapse w-full">
|
||||
<thead className="text-[14px]">
|
||||
<tr className="border-y-[1px]">
|
||||
{heading?.map((item, index) => (
|
||||
<React.Fragment key={index}>
|
||||
<th className="px-4 py-2">{item}</th>
|
||||
</React.Fragment>
|
||||
))}
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody className="text-[12px]">
|
||||
{userList?.length > 0 && (
|
||||
<>
|
||||
{userList.map((item, index) => (
|
||||
<tr className="border-y-[1px]" key={index}>
|
||||
{heading.includes("Sr.No") && (
|
||||
<th className="px-4 py-2">
|
||||
{startIndex + index + 1}
|
||||
</th>
|
||||
)}
|
||||
<td className="px-4 py-2 font-semibold">
|
||||
{item?.Name}{" "}
|
||||
</td>
|
||||
<td className="px-4 py-2 ">{item?.Email || "-"}</td>
|
||||
<td className="px-4 py-2">{item?.Phone || "-"}</td>
|
||||
<td className="px-4 py-2">
|
||||
{item?.UserRole?.split("_").pop() || "-"}
|
||||
</td>
|
||||
<td className="px-4 py-2">{formatRow(item.TeamIds)}</td>
|
||||
{item.UserRole !== "contracts_Admin" && (
|
||||
<td className="px-4 py-2 font-semibold">
|
||||
<label className="cursor-pointer relative block items-center mb-0">
|
||||
<input
|
||||
type="checkbox"
|
||||
className="op-toggle transition-all op-toggle-secondary"
|
||||
checked={item?.IsDisabled !== true}
|
||||
onChange={() => handleToggleBtn(item)}
|
||||
/>
|
||||
</label>
|
||||
{isActiveModal[item.objectId] && (
|
||||
<ModalUi
|
||||
isOpen
|
||||
title={"User status"}
|
||||
handleClose={handleClose}
|
||||
>
|
||||
<div className="m-[20px]">
|
||||
<div className="text-lg font-normal text-black">
|
||||
Are you sure you want to{" "}
|
||||
{item?.IsDisabled
|
||||
? "activate"
|
||||
: "deactivate"}{" "}
|
||||
this user?
|
||||
</div>
|
||||
<hr className="bg-[#ccc] mt-4 " />
|
||||
<div className="flex items-center mt-3 gap-2 text-white">
|
||||
<button
|
||||
onClick={() => handleToggleSubmit(item)}
|
||||
className="op-btn op-btn-primary"
|
||||
>
|
||||
Yes
|
||||
</button>
|
||||
<button
|
||||
onClick={handleClose}
|
||||
className="op-btn op-btn-secondary"
|
||||
>
|
||||
No
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</ModalUi>
|
||||
<>
|
||||
{isAdmin ? (
|
||||
<div className="p-2 w-full bg-base-100 text-base-content op-card shadow-lg">
|
||||
{isAlert.msg && (
|
||||
<Alert type={isAlert.type}>
|
||||
<div className="ml-3">{isAlert.msg}</div>
|
||||
</Alert>
|
||||
)}
|
||||
<div className="flex flex-row items-center justify-between my-2 mx-3 text-[20px] md:text-[23px]">
|
||||
<div className="font-light">
|
||||
Users{" "}
|
||||
<span className="text-xs md:text-[13px] font-normal">
|
||||
<Tooltip message={"users from Teams"} />
|
||||
</span>
|
||||
</div>
|
||||
<div
|
||||
className="cursor-pointer"
|
||||
onClick={() => handleFormModal()}
|
||||
>
|
||||
<i className="fa-light fa-square-plus text-accent text-[40px]"></i>
|
||||
</div>
|
||||
</div>
|
||||
<div className={` overflow-x-auto w-full`}>
|
||||
<table className="op-table border-collapse w-full">
|
||||
<thead className="text-[14px]">
|
||||
<tr className="border-y-[1px]">
|
||||
{heading?.map((item, index) => (
|
||||
<React.Fragment key={index}>
|
||||
<th className="px-4 py-2">{item}</th>
|
||||
</React.Fragment>
|
||||
))}
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody className="text-[12px]">
|
||||
{userList?.length > 0 && (
|
||||
<>
|
||||
{userList.map((item, index) => (
|
||||
<tr className="border-y-[1px]" key={index}>
|
||||
{heading.includes("Sr.No") && (
|
||||
<th className="px-4 py-2">
|
||||
{startIndex + index + 1}
|
||||
</th>
|
||||
)}
|
||||
</td>
|
||||
)}
|
||||
{/* <td className="px-3 py-2 text-white grid grid-cols-2">
|
||||
<td className="px-4 py-2 font-semibold">
|
||||
{item?.Name}{" "}
|
||||
</td>
|
||||
<td className="px-4 py-2 ">{item?.Email || "-"}</td>
|
||||
<td className="px-4 py-2">{item?.Phone || "-"}</td>
|
||||
<td className="px-4 py-2">
|
||||
{item?.UserRole?.split("_").pop() || "-"}
|
||||
</td>
|
||||
<td className="px-4 py-2">
|
||||
{formatRow(item.TeamIds)}
|
||||
</td>
|
||||
{item.UserRole !== "contracts_Admin" && (
|
||||
<td className="px-4 py-2 font-semibold">
|
||||
<label className="cursor-pointer relative block items-center mb-0">
|
||||
<input
|
||||
type="checkbox"
|
||||
className="op-toggle transition-all op-toggle-secondary"
|
||||
checked={item?.IsDisabled !== true}
|
||||
onChange={() => handleToggleBtn(item)}
|
||||
/>
|
||||
</label>
|
||||
{isActiveModal[item.objectId] && (
|
||||
<ModalUi
|
||||
isOpen
|
||||
title={"User status"}
|
||||
handleClose={handleClose}
|
||||
>
|
||||
<div className="m-[20px]">
|
||||
<div className="text-lg font-normal text-black">
|
||||
Are you sure you want to{" "}
|
||||
{item?.IsDisabled
|
||||
? "activate"
|
||||
: "deactivate"}{" "}
|
||||
this user?
|
||||
</div>
|
||||
<hr className="bg-[#ccc] mt-4 " />
|
||||
<div className="flex items-center mt-3 gap-2 text-white">
|
||||
<button
|
||||
onClick={() =>
|
||||
handleToggleSubmit(item)
|
||||
}
|
||||
className="op-btn op-btn-primary"
|
||||
>
|
||||
Yes
|
||||
</button>
|
||||
<button
|
||||
onClick={handleClose}
|
||||
className="op-btn op-btn-secondary"
|
||||
>
|
||||
No
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</ModalUi>
|
||||
)}
|
||||
</td>
|
||||
)}
|
||||
{/* <td className="px-3 py-2 text-white grid grid-cols-2">
|
||||
{actions?.length > 0 &&
|
||||
actions.map((act, index) => (
|
||||
<button
|
||||
@@ -316,71 +337,82 @@ const UserList = () => {
|
||||
</ModalUi>
|
||||
)}
|
||||
</td> */}
|
||||
</tr>
|
||||
))}
|
||||
</>
|
||||
)}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<div className="op-join flex flex-wrap items-center p-2">
|
||||
{userList.length > recordperPage && (
|
||||
<button
|
||||
onClick={() => paginateBack()}
|
||||
className="op-join-item op-btn op-btn-sm"
|
||||
>
|
||||
Prev
|
||||
</button>
|
||||
)}
|
||||
{pageNumbers.map((x, i) => (
|
||||
<button
|
||||
key={i}
|
||||
onClick={() => setCurrentPage(x)}
|
||||
disabled={x === "..."}
|
||||
className={`${
|
||||
x === currentPage ? "op-btn-active" : ""
|
||||
} op-join-item op-btn op-btn-sm`}
|
||||
>
|
||||
{x}
|
||||
</button>
|
||||
))}
|
||||
{userList.length > recordperPage && (
|
||||
<button
|
||||
onClick={() => paginateFront()}
|
||||
className="op-join-item op-btn op-btn-sm"
|
||||
>
|
||||
Next
|
||||
</button>
|
||||
)}
|
||||
</div>
|
||||
{userList?.length <= 0 && (
|
||||
<div
|
||||
className={`${
|
||||
isDashboard ? "h-[317px]" : ""
|
||||
} flex flex-col items-center justify-center w-ful bg-base-100 text-base-content rounded-xl py-4`}
|
||||
>
|
||||
<div className="w-[60px] h-[60px] overflow-hidden">
|
||||
<img
|
||||
className="w-full h-full object-contain"
|
||||
src={pad}
|
||||
alt="img"
|
||||
/>
|
||||
</tr>
|
||||
))}
|
||||
</>
|
||||
)}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<div className="op-join flex flex-wrap items-center p-2">
|
||||
{userList.length > recordperPage && (
|
||||
<button
|
||||
onClick={() => paginateBack()}
|
||||
className="op-join-item op-btn op-btn-sm"
|
||||
>
|
||||
Prev
|
||||
</button>
|
||||
)}
|
||||
{pageNumbers.map((x, i) => (
|
||||
<button
|
||||
key={i}
|
||||
onClick={() => setCurrentPage(x)}
|
||||
disabled={x === "..."}
|
||||
className={`${
|
||||
x === currentPage ? "op-btn-active" : ""
|
||||
} op-join-item op-btn op-btn-sm`}
|
||||
>
|
||||
{x}
|
||||
</button>
|
||||
))}
|
||||
{userList.length > recordperPage && (
|
||||
<button
|
||||
onClick={() => paginateFront()}
|
||||
className="op-join-item op-btn op-btn-sm"
|
||||
>
|
||||
Next
|
||||
</button>
|
||||
)}
|
||||
</div>
|
||||
{userList?.length <= 0 && (
|
||||
<div
|
||||
className={`${
|
||||
isDashboard ? "h-[317px]" : ""
|
||||
} flex flex-col items-center justify-center w-ful bg-base-100 text-base-content rounded-xl py-4`}
|
||||
>
|
||||
<div className="w-[60px] h-[60px] overflow-hidden">
|
||||
<img
|
||||
className="w-full h-full object-contain"
|
||||
src={pad}
|
||||
alt="img"
|
||||
/>
|
||||
</div>
|
||||
<div className="text-sm font-semibold">No Data Available</div>
|
||||
</div>
|
||||
)}
|
||||
<ModalUi
|
||||
title={"Add User"}
|
||||
isOpen={isModal}
|
||||
handleClose={handleFormModal}
|
||||
>
|
||||
<AddUser
|
||||
setIsAlert={setIsAlert}
|
||||
handleUserData={handleUserData}
|
||||
closePopup={handleFormModal}
|
||||
/>
|
||||
</ModalUi>
|
||||
</div>
|
||||
) : (
|
||||
<div className="flex items-center justify-center h-screen w-full bg-base-100 text-base-content rounded-box">
|
||||
<div className="text-center">
|
||||
<h1 className="text-[60px] lg:text-[120px] font-semibold">
|
||||
404
|
||||
</h1>
|
||||
<p className="text-[30px] lg:text-[50px]">Page Not Found</p>
|
||||
</div>
|
||||
<div className="text-sm font-semibold">No Data Available</div>
|
||||
</div>
|
||||
)}
|
||||
<ModalUi
|
||||
title={"Add User"}
|
||||
isOpen={isModal}
|
||||
handleClose={handleFormModal}
|
||||
>
|
||||
<AddUser
|
||||
setIsAlert={setIsAlert}
|
||||
handleUserData={handleUserData}
|
||||
closePopup={handleFormModal}
|
||||
/>
|
||||
</ModalUi>
|
||||
</div>
|
||||
</>
|
||||
)}
|
||||
{!isSubscribe && isEnableSubscription && !isLoader && (
|
||||
<div data-tut="apisubscribe">
|
||||
|
||||
@@ -460,8 +460,8 @@ function UserProfile() {
|
||||
style={{
|
||||
border:
|
||||
!isSubscribe &&
|
||||
publicUserName.length > 0 &&
|
||||
publicUserName.length < 9 &&
|
||||
publicUserName?.length > 0 &&
|
||||
publicUserName?.length < 9 &&
|
||||
"solid red"
|
||||
}}
|
||||
onChange={handleOnchangeUserName}
|
||||
@@ -557,8 +557,8 @@ function UserProfile() {
|
||||
onClick={(e) => {
|
||||
if (
|
||||
!isSubscribe &&
|
||||
publicUserName.length > 0 &&
|
||||
publicUserName.length < 9
|
||||
publicUserName?.length > 0 &&
|
||||
publicUserName?.length < 9
|
||||
) {
|
||||
setIsUpgrade(true);
|
||||
} else {
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import React, { useState, useEffect } from "react";
|
||||
import Parse from "parse";
|
||||
import axios from "axios";
|
||||
import Loader from "./Loader";
|
||||
const AddContact = (props) => {
|
||||
const [name, setName] = useState("");
|
||||
@@ -9,8 +8,6 @@ const AddContact = (props) => {
|
||||
const [addYourself, setAddYourself] = useState(false);
|
||||
const [isLoader, setIsLoader] = useState(false);
|
||||
const [isUserExist, setIsUserExist] = useState(false);
|
||||
const parseBaseUrl = localStorage.getItem("baseUrl");
|
||||
const parseAppId = localStorage.getItem("parseAppId");
|
||||
useEffect(() => {
|
||||
checkUserExist();
|
||||
}, []);
|
||||
@@ -77,18 +74,6 @@ const AddContact = (props) => {
|
||||
|
||||
const user = await _user.save();
|
||||
if (user) {
|
||||
const roleurl = `${parseBaseUrl}functions/AddUserToRole`;
|
||||
const headers = {
|
||||
"Content-Type": "application/json",
|
||||
"X-Parse-Application-Id": parseAppId,
|
||||
sessionToken: localStorage.getItem("accesstoken")
|
||||
};
|
||||
const body = {
|
||||
appName: "contracts",
|
||||
roleName: "contracts_Guest",
|
||||
userId: user.id
|
||||
};
|
||||
await axios.post(roleurl, body, { headers: headers });
|
||||
const currentUser = Parse.User.current();
|
||||
contactQuery.set(
|
||||
"CreatedBy",
|
||||
@@ -124,18 +109,6 @@ const AddContact = (props) => {
|
||||
if (err.code === 202) {
|
||||
const params = { email: email };
|
||||
const userRes = await Parse.Cloud.run("getUserId", params);
|
||||
const roleurl = `${parseBaseUrl}functions/AddUserToRole`;
|
||||
const headers = {
|
||||
"Content-Type": "application/json",
|
||||
"X-Parse-Application-Id": parseAppId,
|
||||
sessionToken: localStorage.getItem("accesstoken")
|
||||
};
|
||||
const body = {
|
||||
appName: "contracts",
|
||||
roleName: "contracts_Guest",
|
||||
userId: userRes.id
|
||||
};
|
||||
await axios.post(roleurl, body, { headers: headers });
|
||||
const currentUser = Parse.User.current();
|
||||
contactQuery.set(
|
||||
"CreatedBy",
|
||||
|
||||
@@ -1,7 +1,4 @@
|
||||
import axios from 'axios';
|
||||
export default async function createContact(request, response) {
|
||||
const serverUrl = process.env.SERVER_URL;
|
||||
const appId = process.env.APP_ID;
|
||||
const name = request.body.name;
|
||||
const phone = request.body?.phone;
|
||||
const email = request.body.email;
|
||||
@@ -74,18 +71,6 @@ export default async function createContact(request, response) {
|
||||
|
||||
const user = await _user.save();
|
||||
if (user) {
|
||||
const roleurl = `${serverUrl}/functions/AddUserToRole`;
|
||||
const headers = {
|
||||
'Content-Type': 'application/json',
|
||||
'X-Parse-Application-Id': appId,
|
||||
// sessionToken: localStorage.getItem('accesstoken'),
|
||||
};
|
||||
const body = {
|
||||
appName: 'contracts',
|
||||
roleName: 'contracts_Guest',
|
||||
userId: user.id,
|
||||
};
|
||||
await axios.post(roleurl, body, { headers: headers });
|
||||
const currentUser = userPtr;
|
||||
contactQuery.set('CreatedBy', currentUser);
|
||||
contactQuery.set('UserId', user);
|
||||
@@ -120,18 +105,6 @@ export default async function createContact(request, response) {
|
||||
if (err.code === 202) {
|
||||
const params = { email: email };
|
||||
const userRes = await Parse.Cloud.run('getUserId', params);
|
||||
const roleurl = `${serverUrl}/functions/AddUserToRole`;
|
||||
const headers = {
|
||||
'Content-Type': 'application/json',
|
||||
'X-Parse-Application-Id': appId,
|
||||
// sessionToken: localStorage.getItem('accesstoken'),
|
||||
};
|
||||
const body = {
|
||||
appName: 'contracts',
|
||||
roleName: 'contracts_Guest',
|
||||
userId: userRes.objectId,
|
||||
};
|
||||
await axios.post(roleurl, body, { headers: headers });
|
||||
contactQuery.set('CreatedBy', userPtr);
|
||||
contactQuery.set('UserId', {
|
||||
__type: 'Pointer',
|
||||
|
||||
@@ -4,8 +4,6 @@ import GoogleSign from './parsefunction/GoogleSign.js';
|
||||
import ZohoDetails from './parsefunction/ZohoDetails.js';
|
||||
import usersignup from './parsefunction/usersignup.js';
|
||||
import FacebookSign from './parsefunction/FacebookSign.js';
|
||||
import { addUserToGroups } from './parsefunction/AddUserToRole.js';
|
||||
import { getUserGroups } from './parsefunction/UserGroups.js';
|
||||
import DocumentAftersave from './parsefunction/DocumentAftersave.js';
|
||||
import ContactbookAftersave from './parsefunction/ContactBookAftersave.js';
|
||||
// import ContractUsersAftersave from './parsefunction/ContractUsersAftersave.js';
|
||||
@@ -73,8 +71,6 @@ Parse.Cloud.afterFind('contracts_Signature', SignatureAfterFind);
|
||||
Parse.Cloud.afterFind('partners_Tenant', TenantAterFind);
|
||||
|
||||
// This define function creates a custom Cloud Function that can be called from the client-side, enabling custom business logic on the server.
|
||||
Parse.Cloud.define('AddUserToRole', addUserToGroups);
|
||||
Parse.Cloud.define('UserGroups', getUserGroups);
|
||||
Parse.Cloud.define('signPdf', PDF);
|
||||
Parse.Cloud.define('sendmailv3', sendmailv3);
|
||||
Parse.Cloud.define('googlesign', GoogleSign);
|
||||
|
||||
@@ -1,268 +0,0 @@
|
||||
/* --Description :cloud function to add or attach user in given role */
|
||||
|
||||
//-- Export Modules
|
||||
import 'dotenv/config.js';
|
||||
import axios from 'axios';
|
||||
const appId = process.env.APP_ID;
|
||||
const masterKey = process.env.MASTER_KEY;
|
||||
const serverUrl = process.env.SERVER_URL;
|
||||
export async function addUserToGroups(request) {
|
||||
try {
|
||||
var roleName = request.params.roleName;
|
||||
if (roleName == undefined) {
|
||||
return Promise.reject('Error:roleName not found!');
|
||||
}
|
||||
var appName = request.params.appName;
|
||||
if (appName == undefined) {
|
||||
return Promise.reject('Error:appName not found!');
|
||||
}
|
||||
var chkappName = appName + '_';
|
||||
//console.log("roleName " + roleName);
|
||||
var userId = request.params.userId;
|
||||
//console.log("userId " + userId);
|
||||
console.log('addUserToGroups');
|
||||
var response = {};
|
||||
var rolelist = {};
|
||||
var user = {
|
||||
users: {
|
||||
__op: 'AddRelation',
|
||||
objects: [{ __type: 'Pointer', className: '_User', objectId: userId }],
|
||||
},
|
||||
};
|
||||
var Role = roleName;
|
||||
var chkappnam = Role.split('_')[0];
|
||||
chkappnam = chkappnam + '_';
|
||||
// if (!chkappnam == chkappName) {
|
||||
// return Promise.reject("Error:Please check role it should belong to current appllication");
|
||||
// }
|
||||
function getAccessType(request) {
|
||||
return new Promise(function (resolve, reject) {
|
||||
const options = {
|
||||
url: serverUrl + '/classes/w_appinfo?where={"appname":"' + appName + '"}',
|
||||
method: 'get',
|
||||
headers: {
|
||||
'X-Parse-Application-Id': appId,
|
||||
'X-Parse-Master-Key': masterKey,
|
||||
},
|
||||
};
|
||||
|
||||
axios(options)
|
||||
.then(x => {
|
||||
const body = x.data;
|
||||
var accessType;
|
||||
if (body['results'].length !== 0) {
|
||||
accessType = body['results'][0]['accessType'];
|
||||
} else {
|
||||
reject('Error:app not found!');
|
||||
}
|
||||
var error = accessType == '' ? true : false;
|
||||
if (error) {
|
||||
reject('result not found!');
|
||||
} else {
|
||||
resolve(accessType);
|
||||
}
|
||||
})
|
||||
.catch(err => {
|
||||
if (err) {
|
||||
console.error(err);
|
||||
return;
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
var role = appName + 'appeditor';
|
||||
var appaccessType = await getAccessType(request);
|
||||
//console.log("appaccessType");
|
||||
//console.log(appaccessType);
|
||||
if (appaccessType == 'public') {
|
||||
adduserToRole();
|
||||
} else {
|
||||
//--function to get the userid from session token
|
||||
function getuserid(request) {
|
||||
try {
|
||||
return new Promise(function (resolve, reject) {
|
||||
const options = {
|
||||
url: serverUrl + '/users/me',
|
||||
method: 'get',
|
||||
headers: {
|
||||
'X-Parse-Application-Id': appId,
|
||||
'X-Parse-Session-Token': request.headers['sessiontoken'],
|
||||
},
|
||||
};
|
||||
|
||||
axios(options)
|
||||
.then(x => {
|
||||
const body = x.data;
|
||||
var error = body == '' ? true : false;
|
||||
if (error) {
|
||||
reject('result not found!');
|
||||
} else {
|
||||
resolve(body);
|
||||
}
|
||||
})
|
||||
.catch(err => {
|
||||
if (err) {
|
||||
console.error(err);
|
||||
return;
|
||||
}
|
||||
});
|
||||
});
|
||||
} catch (err) {
|
||||
console.log('err ', err);
|
||||
}
|
||||
}
|
||||
var userData = await getuserid(request);
|
||||
if (userData.objectId == undefined) {
|
||||
return Promise.reject('Error:user not found!');
|
||||
}
|
||||
var chkuserid = userData.objectId;
|
||||
//console.log("chkuserid "+chkuserid);
|
||||
var url =
|
||||
serverUrl +
|
||||
'/roles?where={"users":{"__type":"Pointer","className":"_User","objectId":"' +
|
||||
chkuserid +
|
||||
'"},"name": {"$regex": "' +
|
||||
chkappName +
|
||||
'"}}';
|
||||
|
||||
//-- check user role
|
||||
function getRoleList(chkuserid) {
|
||||
return new Promise(function (resolve, reject) {
|
||||
const options = {
|
||||
url: url,
|
||||
method: 'get',
|
||||
headers: {
|
||||
'X-Parse-Application-Id': appId,
|
||||
},
|
||||
};
|
||||
|
||||
axios(options)
|
||||
.then(x => {
|
||||
const body = x.data;
|
||||
if (body['results'].length == 0) {
|
||||
reject('Error:user not found');
|
||||
}
|
||||
var error = body == '' ? true : false;
|
||||
if (error) {
|
||||
reject('result not found!');
|
||||
} else {
|
||||
resolve(body);
|
||||
}
|
||||
})
|
||||
.catch(err => {
|
||||
if (err) {
|
||||
console.error(err);
|
||||
return;
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
rolelist = await getRoleList(chkuserid);
|
||||
//console.log("rolelist");
|
||||
// console.log(rolelist);
|
||||
var roleres = [];
|
||||
var result;
|
||||
for (var i = 0; i < rolelist['results'].length; i++) {
|
||||
var rolenum = rolelist['results'][i]['name'];
|
||||
var appnam = rolenum.split('_')[0];
|
||||
appnam = appnam + '_';
|
||||
if (appnam == chkappName) {
|
||||
result = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (result == true) {
|
||||
adduserToRole();
|
||||
} else {
|
||||
return Promise.reject('Error:user of this app can only add user to Role');
|
||||
}
|
||||
}
|
||||
|
||||
//--after validation call adduserToRole function
|
||||
async function adduserToRole() {
|
||||
try {
|
||||
var roleNam = roleName;
|
||||
var roleid = await getroleobjId(roleNam);
|
||||
console.log('roleid');
|
||||
console.log(roleid);
|
||||
var response = await adduserid(roleid);
|
||||
|
||||
return response;
|
||||
} catch (err) {
|
||||
console.log('err in addusertorole', err);
|
||||
}
|
||||
}
|
||||
//--function to get the role objId
|
||||
function getroleobjId(roleNam) {
|
||||
return new Promise(function (resolve, reject) {
|
||||
const options = {
|
||||
url: serverUrl + '/roles?where={"name":"' + roleNam + '"}',
|
||||
method: 'get',
|
||||
headers: {
|
||||
'X-Parse-Application-Id': appId,
|
||||
},
|
||||
};
|
||||
axios(options)
|
||||
.then(x => {
|
||||
const body = x.data;
|
||||
var roleid;
|
||||
if (body['results'].length !== 0) {
|
||||
roleid = body['results'][0]['objectId'];
|
||||
} else {
|
||||
reject('Error:Role not found!');
|
||||
}
|
||||
var error = roleid == '' ? true : false;
|
||||
if (error) {
|
||||
reject('result not found!');
|
||||
} else {
|
||||
resolve(roleid);
|
||||
}
|
||||
})
|
||||
.catch(err => {
|
||||
if (err) {
|
||||
console.error(err);
|
||||
return;
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
//--function to add the userid to role
|
||||
function adduserid(roleid) {
|
||||
return new Promise(function (resolve, reject) {
|
||||
const options = {
|
||||
url: serverUrl + '/roles/' + roleid,
|
||||
method: 'PUT',
|
||||
headers: {
|
||||
'X-Parse-Application-Id': appId,
|
||||
'X-Parse-Master-Key': masterKey,
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
data: user,
|
||||
};
|
||||
|
||||
axios(options)
|
||||
.then(x => {
|
||||
const body = x.data;
|
||||
var error = body == '' ? true : false;
|
||||
if (error) {
|
||||
reject('result not found!');
|
||||
} else {
|
||||
console.log('user added to role');
|
||||
resolve(body);
|
||||
}
|
||||
})
|
||||
.catch(err => {
|
||||
if (err) {
|
||||
console.error(err);
|
||||
return;
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
} catch (err) {
|
||||
console.log('err in AddUserToRole');
|
||||
console.log(err);
|
||||
return Promise.reject('Error:exception in query,Result not Found');
|
||||
}
|
||||
}
|
||||
@@ -1,112 +0,0 @@
|
||||
/* --Description :cloud function called to add mater key in update query */
|
||||
|
||||
//-- Export Modules
|
||||
import dotenv from 'dotenv';
|
||||
dotenv.config();
|
||||
import axios from 'axios';
|
||||
|
||||
export async function getUserGroups(request) {
|
||||
try {
|
||||
var appname = request.params.appname;
|
||||
if (appname == '') {
|
||||
return Promise.reject('Error:please provide appname');
|
||||
}
|
||||
var response = {};
|
||||
var rolelist = {};
|
||||
appname = appname + '_';
|
||||
//--function to get the userid from session token
|
||||
function getuserid(request) {
|
||||
return new Promise(function (resolve, reject) {
|
||||
const options = {
|
||||
url: process.env.SERVER_URL + '/users/me',
|
||||
method: 'get',
|
||||
headers: {
|
||||
'X-Parse-Application-Id': process.env.APP_ID,
|
||||
'X-Parse-Session-Token': request.headers['sessiontoken'],
|
||||
},
|
||||
};
|
||||
|
||||
axios(options)
|
||||
.then(x => {
|
||||
const body = x.data;
|
||||
var error = body == '' ? true : false;
|
||||
if (error) {
|
||||
reject('result not found!');
|
||||
} else {
|
||||
resolve(body);
|
||||
}
|
||||
})
|
||||
.catch(err => {
|
||||
if (err) {
|
||||
console.error(err);
|
||||
return;
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
var userData = await getuserid(request);
|
||||
var userid = userData.objectId;
|
||||
// console.log("userid " + userid);
|
||||
var url =
|
||||
process.env.SERVER_URL +
|
||||
'/roles?where={"users":{"__type":"Pointer","className":"_User","objectId":"' +
|
||||
userid +
|
||||
'"},"name": {"$regex": "' +
|
||||
appname +
|
||||
'"}}';
|
||||
|
||||
//-- check user role
|
||||
function getRoleList(userid) {
|
||||
return new Promise(function (resolve, reject) {
|
||||
const options = {
|
||||
url: url,
|
||||
method: 'get',
|
||||
headers: {
|
||||
'X-Parse-Application-Id': process.env.APP_ID,
|
||||
},
|
||||
};
|
||||
|
||||
axios(options)
|
||||
.then(x => {
|
||||
const body = x.data;
|
||||
var roleres = [];
|
||||
for (var i = 0; i < body['results'].length; i++) {
|
||||
var rolename = body['results'][i]['name'];
|
||||
//var roleprefix = rolename.split("_")[0];
|
||||
roleres.push(rolename);
|
||||
}
|
||||
var error = roleres == '' ? true : false;
|
||||
if (error) {
|
||||
reject('result not found!');
|
||||
} else {
|
||||
resolve(roleres);
|
||||
}
|
||||
})
|
||||
.catch(err => {
|
||||
if (err) {
|
||||
console.error(err);
|
||||
return;
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
rolelist = await getRoleList(request);
|
||||
// console.log(rolelist);
|
||||
//--check user roles according to appId
|
||||
var rolesInapp = [];
|
||||
for (let i = 0; i < rolelist.length; i++) {
|
||||
var str = JSON.stringify(rolelist[i]);
|
||||
var result = str.includes(appname);
|
||||
if (result == true) {
|
||||
rolesInapp.push(rolelist[i]);
|
||||
}
|
||||
}
|
||||
// console.log(rolesInapp);
|
||||
return rolesInapp;
|
||||
} catch (err) {
|
||||
console.log('err in usergroup');
|
||||
console.log(err);
|
||||
return Promise.reject('Error:Result not found');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user