fix: provide route to upgrade from v1 to v2 for self hosting

This commit is contained in:
prafull-opensignlabs
2024-07-16 13:13:08 +05:30
parent 2604156c7f
commit 2d7a893424
16 changed files with 482 additions and 905 deletions
File diff suppressed because one or more lines are too long
+4 -2
View File
@@ -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"
-27
View File
@@ -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",
-27
View File
@@ -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",
+3 -1
View File
@@ -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 />
+33 -29
View File
@@ -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);
}
};
+1 -1
View File
@@ -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
View File
@@ -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
View File
@@ -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">
+4 -4
View File
@@ -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",