refactor: change name from department to team

This commit is contained in:
prafull-opensignlabs
2024-07-03 20:47:19 +05:30
parent 57b23d7f97
commit 450de195a7
13 changed files with 117 additions and 114 deletions
+2 -6
View File
@@ -18,9 +18,8 @@ import LazyPage from "./primitives/LazyPage";
import { isEnableSubscription } from "./constant/const";
import SSOVerify from "./pages/SSOVerify";
import Loader from "./primitives/Loader";
import DepartmentList from "./pages/DepartmentList";
import TeamList from "./pages/TeamList";
import UserList from "./pages/UserList";
import AddDepartment from "./components/AddDepartment";
const DebugPdf = lazy(() => import("./pages/DebugPdf"));
const ForgetPassword = lazy(() => import("./pages/ForgetPassword"));
const GuestLogin = lazy(() => import("./pages/GuestLogin"));
@@ -123,11 +122,8 @@ function App() {
</>
)}
<Route element={<HomeLayout />}>
<Route path="/departments" element={<DepartmentList />} />
<Route path="/departmentform" element={<AddDepartment />} />
<Route path="/teams" element={<TeamList />} />
<Route path="/users" element={<UserList />} />
<Route
path="/changepassword"
element={<LazyPage Page={ChangePassword} />}
@@ -56,7 +56,7 @@ const AddDepartment = (props) => {
objectId: x.objectId
}));
} else {
const AllUser = departmentList.find((x) => x.objectId === "All User");
const AllUser = departmentList.find((x) => x.objectId === "All Users");
updatedAncestors = [
AllUser,
{
@@ -107,7 +107,7 @@ const AddDepartment = (props) => {
const ParentId = departmentList.find(
(x) => x.objectId === formdata.department
);
props.handleDepartmentInfo({
props.handleTeamInfo({
objectId: newdepartmentRes.id,
Name: formdata.name,
ParentId: ParentId,
@@ -115,7 +115,7 @@ const AddDepartment = (props) => {
IsActive: true
});
} else {
props.handleDepartmentInfo({
props.handleTeamInfo({
objectId: newdepartmentRes.id,
Name: formdata.name,
ParentId: "",
@@ -197,7 +197,7 @@ const AddDepartment = (props) => {
htmlFor="phone"
className="block text-xs text-gray-700 font-semibold"
>
Department
Parent Team
</label>
<select
value={formdata.department}
+4 -3
View File
@@ -336,7 +336,7 @@ const AddUser = (props) => {
>
Password
</label>
<div className="flex justify-between items-center op-input op-input-bordered op-input-sm bg-base-200 text-base-content w-full h-full text-[13px]">
<div className="flex justify-between items-center op-input op-input-bordered op-input-sm text-base-content w-full h-full text-[13px]">
<div className="break-all">{formdata?.password}</div>
<i
onClick={() => copytoclipboard(formdata?.password)}
@@ -344,7 +344,7 @@ const AddUser = (props) => {
></i>
</div>
<div className="text-[12px] ml-2 mb-0 text-[red]">
Password will be generated one time; make sure to copy it.
Password will only be generated once; make sure to copy it.
</div>
</div>
<div className="mb-3">
@@ -358,6 +358,7 @@ const AddUser = (props) => {
<input
type="text"
name="phone"
placeholder="optional"
value={formdata.phone}
onChange={(e) => handleChange(e)}
// required
@@ -369,7 +370,7 @@ const AddUser = (props) => {
htmlFor="phone"
className="block text-xs text-gray-700 font-semibold"
>
Department
Team
</label>
<select
value={formdata.department}
+11 -13
View File
@@ -298,6 +298,17 @@ function Header({
) : isPdfRequestFiles ? (
alreadySign ? (
<div className="flex flex-row">
<button
onClick={(e) => handleToPrint(e, pdfUrl, setIsDownloading)}
type="button"
className="op-btn op-btn-neutral op-btn-sm mr-[3px] shadow"
>
<i
className="fa-light fa-print py-[3px]"
aria-hidden="true"
></i>
<span className="hidden lg:block">Print</span>
</button>
{isCompleted && (
<button
type="button"
@@ -313,19 +324,6 @@ function Header({
<span className="hidden lg:block">Certificate</span>
</button>
)}
<button
onClick={(e) => handleToPrint(e, pdfUrl, setIsDownloading)}
type="button"
className="op-btn op-btn-neutral op-btn-sm mr-[3px] shadow"
>
<i
className="fa-light fa-print py-[3px]"
aria-hidden="true"
></i>
<span className="hidden lg:block">Print</span>
</button>
<button
type="button"
className="op-btn op-btn-primary op-btn-sm mr-[3px] shadow"
@@ -50,11 +50,11 @@ const Sidebar = ({ isOpen, closeSidebar }) => {
...newItem.children,
{
icon: "fa-light fa-building-memo",
title: "Departments",
title: "Teams",
target: "_self",
pageType: "",
description: "",
objectId: "departments"
objectId: "teams"
},
{
icon: "fa-light fa-users fa-fw",
+4 -4
View File
@@ -30,7 +30,7 @@ const plans = [
planName: "OPENSIGN™ PROFESSIONAL",
currency: "$",
monthlyPrice: "29.99",
yearlyPrice: "329.99",
yearlyPrice: "10 <sup>/month/user</sup>",
subtitle: "Exclusive Access to advanced features.",
btnText: "Subscribe",
url:
@@ -57,10 +57,10 @@ const plans = [
]
},
{
planName: "OPENSIGN™ TEAM",
planName: "OPENSIGN™ TEAMS",
currency: "$",
monthlyPrice: "100.99",
yearlyPrice: "329.99",
monthlyPrice: "40",
yearlyPrice: "20 <sup>/month/user</sup>",
subtitle: "Exclusive Access to advanced features.",
btnText: "Subscribe",
url:
+13 -13
View File
@@ -1582,6 +1582,19 @@ function PdfRequestFiles() {
)}
{!isCompleted?.message && (
<div className="flex mt-4 gap-1 px-[15px]">
<button
onClick={(e) =>
handleToPrint(e, pdfUrl, setIsDownloading)
}
type="button"
className="font-[500] text-[13px] mr-[5px] op-btn op-btn-neutral"
>
<i
className="fa-light fa-print"
aria-hidden="true"
></i>
<span className="hidden lg:block">Print</span>
</button>
<button
type="button"
onClick={() =>
@@ -1600,19 +1613,6 @@ function PdfRequestFiles() {
Certificate
</span>
</button>
<button
onClick={(e) =>
handleToPrint(e, pdfUrl, setIsDownloading)
}
type="button"
className="font-[500] text-[13px] mr-[5px] op-btn op-btn-neutral"
>
<i
className="fa-light fa-print"
aria-hidden="true"
></i>
<span className="hidden lg:block">Print</span>
</button>
<button
type="button"
className="font-[500] text-[13px] mr-[5px] op-btn op-btn-primary"
+17 -4
View File
@@ -16,7 +16,7 @@ const listItemStyle = {
const PlanSubscriptions = () => {
const navigate = useNavigate();
const [yearlyVisible, setYearlyVisible] = useState(false);
const [yearlyVisible, setYearlyVisible] = useState(true);
const [isLoader, setIsLoader] = useState(true);
const extUser =
localStorage.getItem("Extand_Class") &&
@@ -132,9 +132,22 @@ const PlanSubscriptions = () => {
<div>
<span className="text-3xl">
{item.currency && <small>{item.currency}</small>}
{yearlyVisible
? item?.yearlyPrice
: item.monthlyPrice}
{yearlyVisible ? (
<>
{item?.yearlyPrice.includes("<") ? (
<div
className="inline-block"
dangerouslySetInnerHTML={{
__html: item?.yearlyPrice
}}
/>
) : (
<span>{item?.yearlyPrice}</span>
)}
</>
) : (
item.monthlyPrice
)}
</span>
<p className="font-semibold pt-2 text-sm">
{yearlyVisible ? "Billed Yearly" : "Billed Monthly"}
@@ -11,7 +11,7 @@ import { isEnableSubscription } from "../constant/const";
import { checkIsSubscribedTeam } from "../constant/Utils";
import SubscribeCard from "../primitives/SubscribeCard";
const heading = ["Sr.No", "Name", "Parent Department", "Is-Active"];
const heading = ["Sr.No", "Name", "Parent Team", "Active"];
// const actions = [
// {
// btnId: "1231",
@@ -23,9 +23,9 @@ const heading = ["Sr.No", "Name", "Parent Department", "Is-Active"];
// }
// ];
const DepartmentList = () => {
const TeamList = () => {
const recordperPage = 10;
const [departmentList, setDepartmentList] = useState([]);
const [teamList, setTeamList] = useState([]);
const [isLoader, setIsLoader] = useState(false);
const [isModal, setIsModal] = useState(false);
const location = useLocation();
@@ -41,7 +41,7 @@ const DepartmentList = () => {
const getPaginationRange = () => {
const totalPageNumbers = 7; // Adjust this value to show more/less page numbers
const pages = [];
const totalPages = Math.ceil(departmentList.length / recordperPage);
const totalPages = Math.ceil(teamList.length / recordperPage);
if (totalPages <= totalPageNumbers) {
for (let i = 1; i <= totalPages; i++) {
pages.push(i);
@@ -91,9 +91,9 @@ const DepartmentList = () => {
};
const pageNumbers = getPaginationRange();
useEffect(() => {
fetchDepartmentList();
fetchTeamList();
}, []);
async function fetchDepartmentList() {
async function fetchTeamList() {
try {
setIsLoader(true);
if (isEnableSubscription) {
@@ -101,20 +101,20 @@ const DepartmentList = () => {
setIsSubscribe(getIsSubscribe);
}
const extUser = JSON.parse(localStorage.getItem("Extand_Class"))?.[0];
const department = new Parse.Query("contracts_Departments");
department.equalTo("OrganizationId", {
const teamCls = new Parse.Query("contracts_Departments");
teamCls.equalTo("OrganizationId", {
__type: "Pointer",
className: "contracts_Organizations",
objectId: extUser.OrganizationId.objectId
});
department.descending("createdAt");
const departmentRes = await department.find();
if (departmentRes.length > 0) {
const _departmentRes = JSON.parse(JSON.stringify(departmentRes));
setDepartmentList(_departmentRes);
teamCls.descending("createdAt");
const teamRes = await teamCls.find();
if (teamCls.length > 0) {
const _teamRes = JSON.parse(JSON.stringify(teamRes));
setTeamList(_teamRes);
}
} catch (err) {
console.log("Err in fetch departmentlist", err);
console.log("Err in fetch teamlist", err);
setIsAlert({ type: "danger", msg: "Something went wrong." });
} finally {
setTimeout(() => {
@@ -129,7 +129,7 @@ const DepartmentList = () => {
// Get current list
const indexOfLastDoc = currentPage * recordperPage;
const indexOfFirstDoc = indexOfLastDoc - recordperPage;
const currentList = departmentList?.slice(indexOfFirstDoc, indexOfLastDoc);
const currentList = teamList?.slice(indexOfFirstDoc, indexOfLastDoc);
const handleClose = () => {
setIsActiveModal({});
@@ -143,40 +143,38 @@ const DepartmentList = () => {
// // setIsDeleteModal({ [item.objectId]: true });
// // }
// };
const handleToggleBtn = (department) => {
setIsActiveModal({ [department.objectId]: true });
const handleToggleBtn = (team) => {
setIsActiveModal({ [team.objectId]: true });
};
const handleToggleSubmit = async (department) => {
const index = departmentList.findIndex(
(obj) => obj.objectId === department.objectId
);
const handleToggleSubmit = async (team) => {
const index = teamList.findIndex((obj) => obj.objectId === team.objectId);
if (index !== -1) {
setIsActiveModal({});
setIsActLoader({ [department.objectId]: true });
const newArray = [...departmentList];
setIsActLoader({ [team.objectId]: true });
const newArray = [...teamList];
const IsActive = newArray[index].IsActive;
newArray[index] = { ...newArray[index], IsActive: !IsActive };
setDepartmentList(newArray);
setTeamList(newArray);
try {
const departmentCls = new Parse.Object("contracts_Departments");
departmentCls.id = department.objectId;
departmentCls.set("IsActive", !IsActive);
await departmentCls.save();
const teamCls = new Parse.Object("contracts_Departments");
teamCls.id = team.objectId;
teamCls.set("IsActive", !IsActive);
await teamCls.save();
setIsAlert({
type: "success",
msg: "Department disabled successfully."
msg: "Team disabled successfully."
});
} catch (err) {
setIsAlert({ type: "danger", msg: "something went wrong." });
console.log("err in disable department", err);
console.log("err in disable team", err);
} finally {
setIsActLoader({});
setTimeout(() => setIsAlert({ type: "success", msg: "" }), 1500);
}
}
};
const handleDepartmentInfo = (department) => {
setDepartmentList((prev) => [department, ...prev]);
const handleTeamInfo = (team) => {
setTeamList((prev) => [team, ...prev]);
};
return (
<div className="relative">
@@ -199,9 +197,9 @@ const DepartmentList = () => {
)}
<div className="flex flex-row items-center justify-between my-2 mx-3 text-[20px] md:text-[23px]">
<div className="font-light">
department list{" "}
Teams{" "}
<span className="text-xs md:text-[13px] font-normal">
<Tooltip message={"department list"} />
<Tooltip message={"Teams"} />
</span>
</div>
<div className="cursor-pointer" onClick={() => handleFormModal()}>
@@ -220,7 +218,7 @@ const DepartmentList = () => {
</tr>
</thead>
<tbody className="text-[12px]">
{departmentList?.length > 0 && (
{teamList?.length > 0 && (
<>
{currentList.map((item, index) => (
<tr className="border-y-[1px]" key={index}>
@@ -235,7 +233,7 @@ const DepartmentList = () => {
<td className="px-4 py-2 font-semibold">
{item?.ParentId?.Name || "-"}
</td>
{item?.Name !== "All User" && (
{item?.Name !== "All Users" && (
<td className="px-4 py-2 font-semibold">
<label className="cursor-pointer relative block items-center mb-0">
<input
@@ -248,13 +246,12 @@ const DepartmentList = () => {
{isActiveModal[item.objectId] && (
<ModalUi
isOpen
title={"Department status"}
title={"Team status"}
handleClose={handleClose}
>
<div className="m-[20px]">
<div className="text-lg font-normal text-black">
Are you sure you want to disable this
department?
Are you sure you want to disable this team?
</div>
<hr className="bg-[#ccc] mt-4 " />
<div className="flex items-center mt-3 gap-2 text-white">
@@ -299,7 +296,7 @@ const DepartmentList = () => {
</table>
</div>
<div className="op-join flex flex-wrap items-center p-2">
{departmentList.length > recordperPage && (
{teamList.length > recordperPage && (
<button
onClick={() => paginateBack()}
className="op-join-item op-btn op-btn-sm"
@@ -319,7 +316,7 @@ const DepartmentList = () => {
{x}
</button>
))}
{departmentList.length > recordperPage && (
{teamList.length > recordperPage && (
<button
onClick={() => paginateFront()}
className="op-join-item op-btn op-btn-sm"
@@ -328,7 +325,7 @@ const DepartmentList = () => {
</button>
)}
</div>
{departmentList?.length <= 0 && (
{teamList?.length <= 0 && (
<div
className={`${
isDashboard ? "h-[317px]" : ""
@@ -345,12 +342,12 @@ const DepartmentList = () => {
</div>
)}
<ModalUi
title={"Add Department"}
title={"Add Team"}
isOpen={isModal}
handleClose={handleFormModal}
>
<AddDepartment
handleDepartmentInfo={handleDepartmentInfo}
handleTeamInfo={handleTeamInfo}
closePopup={handleFormModal}
/>
</ModalUi>
@@ -358,11 +355,11 @@ const DepartmentList = () => {
)}
{!isSubscribe && isEnableSubscription && !isLoader && (
<div data-tut="apisubscribe">
<SubscribeCard plan={"TEAM"} />
<SubscribeCard plan={"TEAMS"} price={"20"} />
</div>
)}
</div>
);
};
export default DepartmentList;
export default TeamList;
+5 -13
View File
@@ -10,15 +10,7 @@ import AddUser from "../components/AddUser";
import SubscribeCard from "../primitives/SubscribeCard";
import { isEnableSubscription } from "../constant/const";
import { checkIsSubscribedTeam } from "../constant/Utils";
const heading = [
"Sr.No",
"Name",
"Email",
"Phone",
"Role",
"Department",
"Is-Active"
];
const heading = ["Sr.No", "Name", "Email", "Phone", "Role", "Team", "Active"];
// const actions = [];
const UserList = () => {
const [userList, setUserList] = useState([]);
@@ -165,7 +157,7 @@ const UserList = () => {
});
} catch (err) {
setIsAlert({ type: "danger", msg: "something went wrong." });
console.log("err in disable department", err);
console.log("err in disable team", err);
} finally {
setIsActLoader({});
setTimeout(() => setIsAlert({ type: "success", msg: "" }), 1500);
@@ -196,9 +188,9 @@ const UserList = () => {
)}
<div className="flex flex-row items-center justify-between my-2 mx-3 text-[20px] md:text-[23px]">
<div className="font-light">
User list{" "}
Users{" "}
<span className="text-xs md:text-[13px] font-normal">
<Tooltip message={"user list from departments"} />
<Tooltip message={"users from Teams"} />
</span>
</div>
<div className="cursor-pointer" onClick={() => handleFormModal()}>
@@ -385,7 +377,7 @@ const UserList = () => {
)}
{!isSubscribe && isEnableSubscription && !isLoader && (
<div data-tut="apisubscribe">
<SubscribeCard plan={"TEAM"} />
<SubscribeCard plan={"TEAMS"} price={"20"} />
</div>
)}
</div>
@@ -1379,7 +1379,7 @@ const ReportTable = (props) => {
)}
{isOption[item.objectId] &&
act.action === "option" && (
<ul className="absolute -right-2 top-6 z-[20] w-max op-dropdown-content op-menu shadow bg-base-100 text-base-content rounded-box">
<ul className="fixed right-14 top-auto z-[70] w-max op-dropdown-content op-menu shadow bg-base-100 text-base-content rounded-box">
{act.subaction?.map((subact) => (
<li
key={subact.btnId}
@@ -1431,7 +1431,7 @@ const ReportTable = (props) => {
options={departmentList}
value={selectedDepartments}
onChange={onChange}
closeMenuOnSelect={false}
closeMenuOnSelect
required={true}
noOptionsMessage={() =>
"Departments not found"
@@ -1469,7 +1469,10 @@ const ReportTable = (props) => {
>
</div>
<SubscribeCard plan={"TEAM"} />
<SubscribeCard
plan={"TEAMS"}
price={"20"}
/>
</>
)}
</div>
@@ -1,13 +1,16 @@
import React from "react";
import { useNavigate } from "react-router-dom";
const SubscribeCard = ({ plan }) => {
const SubscribeCard = ({ plan, price }) => {
const navigate = useNavigate();
return (
<div className="op-card op-bg-primary text-primary-content w-full shadow-lg">
<div className="op-card-body">
<h2 className="op-card-title">Upgrade to {plan ? plan : "PRO"} Plan</h2>
<p>$29.99/month: Sign 100 docs using API. Only $0.15/doc after that.</p>
<p>
${price ? price : "29.99"}/month: Sign 100 docs using API. Only
$0.15/doc after that.
</p>
<div className="op-card-actions justify-end">
<button
onClick={() => navigate("/subscription")}
@@ -5,7 +5,7 @@ async function addDepartmentAndOrg(extUser) {
orgCls.set('IsActive', true);
const orgRes = await orgCls.save(null, { useMasterKey: true });
const departmentCls = new Parse.Object('contracts_Departments');
departmentCls.set('Name', 'All User');
departmentCls.set('Name', 'All Users');
departmentCls.set('OrganizationId', {
__type: 'Pointer',
className: 'contracts_Organizations',