Compare commits
No commits in common. "98546afc1abca0a35c72968800962251d6ee9257" and "7a5fc509fb1344a8562a2b57772f160205f636cd" have entirely different histories.
98546afc1a
...
7a5fc509fb
@ -16,7 +16,6 @@ import ManageDocument from "./ManageDocument";
|
|||||||
import ViewDocument from "./ViewDocument";
|
import ViewDocument from "./ViewDocument";
|
||||||
import DocumentViewerModal from "./DocumentViewerModal";
|
import DocumentViewerModal from "./DocumentViewerModal";
|
||||||
import { useHasUserPermission } from "../../hooks/useHasUserPermission";
|
import { useHasUserPermission } from "../../hooks/useHasUserPermission";
|
||||||
import { useProfile } from "../../hooks/useProfile";
|
|
||||||
|
|
||||||
// Context
|
// Context
|
||||||
export const DocumentContext = createContext();
|
export const DocumentContext = createContext();
|
||||||
@ -48,7 +47,6 @@ export const getDocuementsStatus = (status) => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
const Documents = ({ Document_Entity, Entity }) => {
|
const Documents = ({ Document_Entity, Entity }) => {
|
||||||
const [isSelf, setIsSelf] = useState(false);
|
|
||||||
const [searchText, setSearchText] = useState("");
|
const [searchText, setSearchText] = useState("");
|
||||||
const [isActive, setIsActive] = useState(true);
|
const [isActive, setIsActive] = useState(true);
|
||||||
const [filters, setFilter] = useState();
|
const [filters, setFilter] = useState();
|
||||||
@ -65,14 +63,8 @@ const Documents = ({ Document_Entity, Entity }) => {
|
|||||||
document: null,
|
document: null,
|
||||||
isOpen: false,
|
isOpen: false,
|
||||||
});
|
});
|
||||||
const { profile } = useProfile();
|
|
||||||
|
|
||||||
useEffect(() => {
|
const canUploadDocument = useHasUserPermission(UPLOAD_DOCUMENT)
|
||||||
if (profile?.employeeInfo?.id) {
|
|
||||||
setIsSelf(profile.employeeInfo.id === employeeId);
|
|
||||||
}
|
|
||||||
}, [profile?.employeeInfo?.id, employeeId]);
|
|
||||||
const canUploadDocument = useHasUserPermission(UPLOAD_DOCUMENT);
|
|
||||||
|
|
||||||
const { setOffcanvasContent, setShowTrigger } = useFab();
|
const { setOffcanvasContent, setShowTrigger } = useFab();
|
||||||
|
|
||||||
@ -122,16 +114,13 @@ const Documents = ({ Document_Entity, Entity }) => {
|
|||||||
<div className="row align-items-center">
|
<div className="row align-items-center">
|
||||||
{/* Search */}
|
{/* Search */}
|
||||||
<div className="d-flex col-8 col-md-8 col-lg-4 mb-md-0 align-items-center">
|
<div className="d-flex col-8 col-md-8 col-lg-4 mb-md-0 align-items-center">
|
||||||
<div className="d-flex">
|
<div className="d-flex"> <input
|
||||||
{" "}
|
type="search"
|
||||||
<input
|
value={searchText}
|
||||||
type="search"
|
onChange={(e) => setSearchText(e.target.value)}
|
||||||
value={searchText}
|
className="form-control form-control-sm"
|
||||||
onChange={(e) => setSearchText(e.target.value)}
|
placeholder="Search Document"
|
||||||
className="form-control form-control-sm"
|
/></div>
|
||||||
placeholder="Search Document"
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
<label className="switch switch-sm mx-2">
|
<label className="switch switch-sm mx-2">
|
||||||
<input
|
<input
|
||||||
type="checkbox"
|
type="checkbox"
|
||||||
@ -148,6 +137,7 @@ const Documents = ({ Document_Entity, Entity }) => {
|
|||||||
</span>
|
</span>
|
||||||
</label>
|
</label>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
{/* Actions */}
|
{/* Actions */}
|
||||||
<div className="col-6 col-md-6 col-lg-8 text-end">
|
<div className="col-6 col-md-6 col-lg-8 text-end">
|
||||||
@ -167,22 +157,21 @@ const Documents = ({ Document_Entity, Entity }) => {
|
|||||||
}`}
|
}`}
|
||||||
></i>
|
></i>
|
||||||
</span> */}
|
</span> */}
|
||||||
|
|
||||||
|
|
||||||
{(isSelf || canUploadDocument) && (
|
{canUploadDocument && (<button
|
||||||
<button
|
type="button"
|
||||||
type="button"
|
title="Add New Document"
|
||||||
title="Add New Document"
|
className="p-1 bg-primary rounded-circle cursor-pointer"
|
||||||
className="p-1 bg-primary rounded-circle cursor-pointer"
|
onClick={() =>
|
||||||
onClick={() =>
|
setManageDoc({
|
||||||
setManageDoc({
|
document: null,
|
||||||
document: null,
|
isOpen: true,
|
||||||
isOpen: true,
|
})
|
||||||
})
|
}
|
||||||
}
|
>
|
||||||
>
|
<i className="bx bx-plus fs-4 text-white"></i>
|
||||||
<i className="bx bx-plus fs-4 text-white"></i>
|
</button>)}
|
||||||
</button>
|
|
||||||
)}
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<DocumentsList
|
<DocumentsList
|
||||||
|
|||||||
@ -17,8 +17,6 @@ import Pagination from "../common/Pagination";
|
|||||||
import ConfirmModal from "../common/ConfirmModal";
|
import ConfirmModal from "../common/ConfirmModal";
|
||||||
import { isPending } from "@reduxjs/toolkit";
|
import { isPending } from "@reduxjs/toolkit";
|
||||||
import { useHasUserPermission } from "../../hooks/useHasUserPermission";
|
import { useHasUserPermission } from "../../hooks/useHasUserPermission";
|
||||||
import { useProfile } from "../../hooks/useProfile";
|
|
||||||
import { useParams } from "react-router-dom";
|
|
||||||
|
|
||||||
const DocumentsList = ({
|
const DocumentsList = ({
|
||||||
Document_Entity,
|
Document_Entity,
|
||||||
@ -29,22 +27,13 @@ const DocumentsList = ({
|
|||||||
setRefetchFn,
|
setRefetchFn,
|
||||||
isActive,
|
isActive,
|
||||||
}) => {
|
}) => {
|
||||||
const { employeeId } = useParams();
|
|
||||||
const [isSelf, setIsSelf] = useState(false);
|
|
||||||
const { profile } = useProfile();
|
|
||||||
const canDeleteDocument = useHasUserPermission(DELETE_DOCUMENT);
|
|
||||||
const canModifyDocument = useHasUserPermission(MODIFY_DOCUMENT);
|
|
||||||
useEffect(() => {
|
|
||||||
if (profile?.employeeInfo?.id && employeeId) {
|
|
||||||
setIsSelf(String(profile.employeeInfo.id) === String(employeeId));
|
|
||||||
}
|
|
||||||
}, [profile?.employeeInfo?.id, employeeId]);
|
|
||||||
const [IsDeleteModalOpen, setIsDeleteModalOpen] = useState(false);
|
const [IsDeleteModalOpen, setIsDeleteModalOpen] = useState(false);
|
||||||
const [deletingId, setDeletingId] = useState(null);
|
const [deletingId, setDeletingId] = useState(null);
|
||||||
const [restoringIds, setRestoringIds] = useState([]);
|
const [restoringIds, setRestoringIds] = useState([]);
|
||||||
const debouncedSearch = useDebounce(searchText, 500);
|
const debouncedSearch = useDebounce(searchText, 500);
|
||||||
const [currentPage, setCurrentPage] = useState(1);
|
const [currentPage, setCurrentPage] = useState(1);
|
||||||
|
const canDeleteDocument = useHasUserPermission(DELETE_DOCUMENT);
|
||||||
|
const canModifyDocument = useHasUserPermission(MODIFY_DOCUMENT);
|
||||||
const { data, isError, isLoading, error, refetch, isFetching } =
|
const { data, isError, isLoading, error, refetch, isFetching } =
|
||||||
useDocumentListByEntityId(
|
useDocumentListByEntityId(
|
||||||
Document_Entity,
|
Document_Entity,
|
||||||
@ -216,7 +205,7 @@ const DocumentsList = ({
|
|||||||
}
|
}
|
||||||
></i>
|
></i>
|
||||||
|
|
||||||
{(isSelf || canModifyDocument) && (
|
{canModifyDocument && (
|
||||||
<i
|
<i
|
||||||
className="bx bx-edit text-secondary cursor-pointer"
|
className="bx bx-edit text-secondary cursor-pointer"
|
||||||
onClick={() =>
|
onClick={() =>
|
||||||
@ -225,7 +214,7 @@ const DocumentsList = ({
|
|||||||
></i>
|
></i>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
{(isSelf || canDeleteDocument) && (
|
{canDeleteDocument && (
|
||||||
<i
|
<i
|
||||||
className="bx bx-trash text-danger cursor-pointer"
|
className="bx bx-trash text-danger cursor-pointer"
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
|
|||||||
@ -1,31 +1,19 @@
|
|||||||
import React, { useEffect, useState } from "react";
|
import React from "react";
|
||||||
import { useHasUserPermission } from "../../hooks/useHasUserPermission";
|
import { useHasUserPermission } from "../../hooks/useHasUserPermission";
|
||||||
import { VIEW_DOCUMENT } from "../../utils/constants";
|
import { VIEW_DOCUMENT } from "../../utils/constants";
|
||||||
import { useProfile } from "../../hooks/useProfile";
|
|
||||||
import { useParams } from "react-router-dom";
|
|
||||||
const EmployeeNav = ({ onPillClick, activePill }) => {
|
const EmployeeNav = ({ onPillClick, activePill }) => {
|
||||||
const { employeeId } = useParams();
|
const canViewDocuments = useHasUserPermission(VIEW_DOCUMENT)
|
||||||
const [isAbleToViewDocuments, setIsAbleToViewDocuments] = useState(false);
|
const tabs = [
|
||||||
|
|
||||||
const canViewDocuments = useHasUserPermission(VIEW_DOCUMENT);
|
|
||||||
const { profile } = useProfile();
|
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
if (profile?.employeeInfo?.id) {
|
|
||||||
setIsAbleToViewDocuments(profile.employeeInfo.id === employeeId);
|
|
||||||
}
|
|
||||||
}, [profile?.employeeInfo?.id, employeeId]);
|
|
||||||
|
|
||||||
const tabs = [
|
|
||||||
{ key: "profile", icon: "bx bx-user", label: "Profile" },
|
{ key: "profile", icon: "bx bx-user", label: "Profile" },
|
||||||
{ key: "attendance", icon: "bx bx-group", label: "Attendances" },
|
{ key: "attendance", icon: "bx bx-group", label: "Attendances" },
|
||||||
(isAbleToViewDocuments || canViewDocuments) && {
|
canViewDocuments && {
|
||||||
key: "documents",
|
key: "documents",
|
||||||
icon: "bx bx-file",
|
icon: "bx bx-file",
|
||||||
label: "Documents",
|
label: "Documents",
|
||||||
},
|
},
|
||||||
{ key: "activities", icon: "bx bx-grid-alt", label: "Activities" },
|
{ key: "activities", icon: "bx bx-grid-alt", label: "Activities" },
|
||||||
].filter(Boolean);
|
].filter(Boolean);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="col-md-12">
|
<div className="col-md-12">
|
||||||
<div className="nav-align-top">
|
<div className="nav-align-top">
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user