added missing view_all_employee permissions

This commit is contained in:
pramod.mahajan 2025-12-12 10:31:36 +05:30
parent cdaf642eba
commit 7b1b360c78

View File

@ -74,9 +74,11 @@ const EmployeeList = () => {
const [selectedEmployee, setSelectedEmployee] = useState(null);
const [IsDeleteModalOpen, setIsDeleteModalOpen] = useState(false);
const [selectedEmpFordelete, setSelectedEmpFordelete] = useState(null);
const [showManageReportingModal, setShowManageReportingModal] = useState(false);
const [showManageReportingModal, setShowManageReportingModal] =
useState(false);
const [employeeLodaing, setemployeeLodaing] = useState(false);
const ViewTeamMember = useHasUserPermission(VIEW_TEAM_MEMBERS);
const ViewAllEmployee = useHasUserPermission(VIEW_ALL_EMPLOYEES);
const { mutate: suspendEmployee, isPending: empLodaing } = useSuspendEmployee(
{
setIsDeleteModalOpen,
@ -140,11 +142,15 @@ const EmployeeList = () => {
const tableRef = useRef(null);
const handleExport = (type) => {
handleEmployeeExport(type, employeeList, filteredData, searchText, tableRef);
handleEmployeeExport(
type,
employeeList,
filteredData,
searchText,
tableRef
);
};
const handleAllEmployeesToggle = (e) => {
const isChecked = e.target.checked;
setShowInactive(false);
@ -173,9 +179,11 @@ const EmployeeList = () => {
useEffect(() => {
if (!loading && Array.isArray(employees)) {
const sorted = [...employees].sort((a, b) => {
const nameA = `${a.firstName || ""}${a.middleName || ""}${a.lastName || ""
const nameA = `${a.firstName || ""}${a.middleName || ""}${
a.lastName || ""
}`.toLowerCase();
const nameB = `${b.firstName || ""}${b.middleName || ""}${b.lastName || ""
const nameB = `${b.firstName || ""}${b.middleName || ""}${
b.lastName || ""
}`.toLowerCase();
return nameA?.localeCompare(nameB);
});
@ -266,7 +274,8 @@ const EmployeeList = () => {
? "Suspend Employee"
: "Reactivate Employee"
}
message={`Are you sure you want to ${selectedEmpFordelete?.isActive ? "suspend" : "reactivate"
message={`Are you sure you want to ${
selectedEmpFordelete?.isActive ? "suspend" : "reactivate"
} this employee?`}
onSubmit={(id) =>
suspendEmployee({
@ -288,7 +297,7 @@ const EmployeeList = () => {
]}
></Breadcrumb>
{ViewTeamMember ? (
{ViewTeamMember || ViewAllEmployee ? (
// <div className="row">
<div className="card p-1 page-min-h">
<div className="card-datatable table-responsive pt-5 mx-5 py-10">
@ -342,8 +351,10 @@ const EmployeeList = () => {
>
<i className="bx bx-dots-vertical-rounded bx-md"></i>
</button>
<ul className="dropdown-menu dropdown-menu-end shadow-sm " style={{ minWidth: "220px" }}>
<ul
className="dropdown-menu dropdown-menu-end shadow-sm "
style={{ minWidth: "220px" }}
>
<li className="dropdown-item d-flex align-items-center justify-content-between">
<div className="form-check form-switch mb-0">
<input
@ -352,39 +363,53 @@ const EmployeeList = () => {
role="switch"
id="inactiveEmployeesCheckboxMenu"
checked={showInactive}
onChange={(e) => setShowInactive(e.target.checked)}
onChange={(e) =>
setShowInactive(e.target.checked)
}
/>
</div>
<span className="ms-0">Show Inactive Employees</span>
</li>
<li><hr className="dropdown-divider" /></li>
<li>
<hr className="dropdown-divider" />
</li>
<li>
<button className="dropdown-item" onClick={() => handleExport("print")}>
<button
className="dropdown-item"
onClick={() => handleExport("print")}
>
<i className="bx bx-printer me-2"></i> Print
</button>
</li>
<li>
<button className="dropdown-item" onClick={() => handleExport("csv")}>
<button
className="dropdown-item"
onClick={() => handleExport("csv")}
>
<i className="bx bx-file me-2"></i> CSV
</button>
</li>
<li>
<button className="dropdown-item" onClick={() => handleExport("excel")}>
<button
className="dropdown-item"
onClick={() => handleExport("excel")}
>
<i className="bx bxs-file-export me-2"></i> Excel
</button>
</li>
<li>
<button className="dropdown-item" onClick={() => handleExport("pdf")}>
<button
className="dropdown-item"
onClick={() => handleExport("pdf")}
>
<i className="bx bxs-file-pdf me-2"></i> PDF
</button>
</li>
</ul>
</div>
</div>
</div>
<table
@ -461,7 +486,8 @@ const EmployeeList = () => {
Status
</th>
<th
className={`sorting_disabled ${!Manage_Employee && "d-none"
className={`sorting_disabled ${
!Manage_Employee && "d-none"
}`}
rowSpan="1"
colSpan="1"
@ -476,29 +502,25 @@ const EmployeeList = () => {
{loading && (
<tr>
<td colSpan={8} className="text-center py-5">
<div className="d-flex justify-content-center align-items-center py-5" style={{ minHeight: "50vh" }}>
<div
className="d-flex justify-content-center align-items-center py-5"
style={{ minHeight: "50vh" }}
>
<SpinnerLoader />
</div>
</td>
</tr>
)}
{!loading &&
displayData?.length === 0 &&
(!searchText) ? (
{!loading && displayData?.length === 0 && !searchText ? (
<tr>
<td colSpan={8} className="border-0 py-3">
<div className="py-4">
No Data Found
</div>
<div className="py-4">No Data Found</div>
</td>
</tr>
) : null}
{!loading &&
displayData?.length === 0 &&
(searchText) ? (
{!loading && displayData?.length === 0 && searchText ? (
<tr>
<td colSpan={8} className="border-0 py-3">
<div className="py-4">
@ -527,7 +549,8 @@ const EmployeeList = () => {
className="text-heading text-truncate cursor-pointer"
>
<span className="fw-normal">
{capitalizeFirstLetter(item.firstName) } {capitalizeFirstLetter(item.middleName)}{" "}
{capitalizeFirstLetter(item.firstName)}{" "}
{capitalizeFirstLetter(item.middleName)}{" "}
{capitalizeFirstLetter(item.lastName)}
</span>
</a>
@ -541,7 +564,9 @@ const EmployeeList = () => {
{item.email}
</span>
) : (
<small className="d-block text-start text-muted small">-</small>
<small className="d-block text-start text-muted small">
-
</small>
)}
</td>
@ -562,7 +587,9 @@ const EmployeeList = () => {
{item.joiningDate ? (
moment(item.joiningDate).format("DD-MMM-YYYY")
) : (
<span className="d-block text-center text-muted fst-italic">NA</span>
<span className="d-block text-center text-muted fst-italic">
NA
</span>
)}
</td>