added use-rights functionality according to users
This commit is contained in:
parent
959e4dd7dd
commit
5a7ca02952
@ -311,7 +311,7 @@ const ManageEmployee = () => {
|
||||
id="Email"
|
||||
{...register("Email")}
|
||||
className="form-control form-control-sm"
|
||||
placeholder="Email"
|
||||
placeholder="example@domain.com"
|
||||
aria-label=""
|
||||
aria-describedby="Email"
|
||||
disabled={!!currentEmployee?.email}
|
||||
@ -325,7 +325,7 @@ const ManageEmployee = () => {
|
||||
</div>
|
||||
)}
|
||||
|
||||
{/* </div> */}
|
||||
|
||||
</div>
|
||||
<div className="col-sm-6">
|
||||
<div className="form-text text-start">Phone Number</div>
|
||||
@ -335,7 +335,7 @@ const ManageEmployee = () => {
|
||||
id="PhoneNumber"
|
||||
{...register("PhoneNumber")}
|
||||
className="form-control form-control-sm"
|
||||
placeholder="000 000 0000"
|
||||
placeholder="Phone Number"
|
||||
/>
|
||||
{errors.PhoneNumber && (
|
||||
<div
|
||||
|
@ -29,7 +29,6 @@ const ManageRole = ({employeeId,onClosed}) => {
|
||||
|
||||
const buildDefaultRoles = () => {
|
||||
const defaults = {};
|
||||
|
||||
data.forEach((role) => {
|
||||
const isRoleEnabled = employeeRoles?.data?.some((empRole) => empRole.roleId === role.id);
|
||||
defaults[role.id] = isRoleEnabled;
|
||||
@ -76,10 +75,8 @@ const ManageRole = ({employeeId,onClosed}) => {
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
RolesRepository.createEmployeeRoles( result ).then( ( resp ) =>
|
||||
{
|
||||
|
||||
{
|
||||
showToast( "Role assigned successfully", "success" )
|
||||
setIsLoading(false)
|
||||
onClosed()
|
||||
@ -90,11 +87,8 @@ const ManageRole = ({employeeId,onClosed}) => {
|
||||
showToast(err.message,"error")
|
||||
})
|
||||
setIsLoading(false)
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
};
|
||||
|
||||
return (
|
||||
|
||||
<div className={`modal fade `} id="managerole-modal" tabIndex="-1" aria-hidden="true" >
|
||||
@ -118,9 +112,9 @@ const ManageRole = ({employeeId,onClosed}) => {
|
||||
|
||||
{(loading || roleLoading) && <p>Loading...</p>}
|
||||
{data && data.map((item) => (
|
||||
<>
|
||||
|
||||
|
||||
<div className="col-md-6 col-lg-4 mb-4">
|
||||
<div className="col-md-6 col-lg-4 mb-4" key={item.id}>
|
||||
<div className="form-check ms-2 text-start">
|
||||
<input
|
||||
className="form-check-input"
|
||||
@ -135,7 +129,7 @@ const ManageRole = ({employeeId,onClosed}) => {
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</>
|
||||
|
||||
))}
|
||||
|
||||
</div>
|
||||
|
@ -5,7 +5,7 @@ const Footer = () => {
|
||||
<div className="container-xxl d-flex flex-wrap justify-content-between py-2 flex-md-row flex-column">
|
||||
<div className="mb-2 mb-md-0" style={{width: "100%", textAlign: "right"}}>
|
||||
© {new Date().getFullYear()}
|
||||
, by <a href="https://marcosolutions.co.in/" target="_blank" className="font-weight-light footer-link">MARCO AIoT Softwares Pvt. Ltd.</a>
|
||||
, by <a href="https://marcosolutions.co.in/" target="_blank" className="font-weight-light footer-link">MARCO AIoT Technologies Pvt. Ltd.</a>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
@ -7,6 +7,8 @@ import ManageProjectInfo from "./ManageProjectInfo";
|
||||
import ProjectRepository from "../../repositories/ProjectRepository";
|
||||
import {cacheData, getCachedData} from "../../slices/apiDataManager";
|
||||
import showToast from "../../services/toastService";
|
||||
import {useHasUserPermission} from "../../hooks/useHasUserPermission";
|
||||
import {MANAGE_PROJECT} from "../../utils/constants";
|
||||
|
||||
|
||||
|
||||
@ -16,7 +18,8 @@ const ProjectCard = ( {projectData} ) =>
|
||||
const[projectInfo,setProjectInfo] = useState(projectData)
|
||||
const navigate = useNavigate()
|
||||
const {projects_Details, loading} = useProjectDetails( projectData.id )
|
||||
const [showModal, setShowModal] = useState(false);
|
||||
const [ showModal, setShowModal ] = useState( false );
|
||||
const ManageProject = useHasUserPermission(MANAGE_PROJECT)
|
||||
|
||||
const handleShow = () => setShowModal(true);
|
||||
const handleClose = () => setShowModal( false );
|
||||
@ -144,7 +147,7 @@ const ProjectCard = ( {projectData} ) =>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div className="ms-auto">
|
||||
<div className={`ms-auto ${!ManageProject && 'd-none'}`}>
|
||||
<div className="dropdown z-2">
|
||||
<button
|
||||
type="button"
|
||||
|
@ -7,6 +7,8 @@ import WorkAreaModel from "./WorkAreaModel";
|
||||
import TaskModel from "./TaskModel";
|
||||
import ProjectRepository from "../../repositories/ProjectRepository";
|
||||
import ProjectModal from "./ProjectModal";
|
||||
import {useHasUserPermission} from "../../hooks/useHasUserPermission";
|
||||
import {MANAGE_INFRA} from "../../utils/constants";
|
||||
// import AssignRoleModel from "./AssignRoleModel";
|
||||
|
||||
const ProjectInfra = ({ data, activityMaster, onDataChange,eachSiteEngineer }) => {
|
||||
@ -14,7 +16,8 @@ const ProjectInfra = ({ data, activityMaster, onDataChange,eachSiteEngineer }) =
|
||||
const [expandedBuildings, setExpandedBuildings] = useState([]);
|
||||
const [project, setProject] = useState(data);
|
||||
const[modalConfig,setModalConfig] = useState({type:null,data:null});
|
||||
const[isModalOpen,setIsModalOpen] = useState(false)
|
||||
const [ isModalOpen, setIsModalOpen ] = useState( false )
|
||||
const ManageInfra = useHasUserPermission(MANAGE_INFRA)
|
||||
|
||||
const [buildings, setBuildings] = useState(data.buildings);
|
||||
const [isBuildingModalOpen, setIsBuildingModalOpen] = useState(false);
|
||||
@ -515,7 +518,7 @@ const ProjectInfra = ({ data, activityMaster, onDataChange,eachSiteEngineer }) =
|
||||
<div className="card-body" style={{ padding: "0.5rem" }}>
|
||||
<div className="align-items-center">
|
||||
<div className="row">
|
||||
<div className="col-12 text-end mb-1">
|
||||
<div className="col-12 text-end mb-1" >
|
||||
<button
|
||||
type="button"
|
||||
className="link-button link-button-sm m-1"
|
||||
|
@ -6,9 +6,9 @@ const Breadcrumb = ({ data }) => {
|
||||
return (
|
||||
<nav aria-label="breadcrumb">
|
||||
<ol className="breadcrumb breadcrumb-style1">
|
||||
{data.map((item) =>
|
||||
{data.map((item,index) =>
|
||||
item.link ? (
|
||||
<li className="breadcrumb-item cursor-pointer">
|
||||
<li className="breadcrumb-item cursor-pointer" key={index}>
|
||||
<a
|
||||
aria-label="pagination link link-underline-primary "
|
||||
onClick={()=>navigate(item.link)}
|
||||
|
@ -111,8 +111,13 @@ export const useEmployeeRoles = (employeeId)=>{
|
||||
};
|
||||
|
||||
|
||||
useEffect(()=>{
|
||||
fetchData(employeeId);
|
||||
useEffect( () =>
|
||||
{
|
||||
if ( employeeId )
|
||||
{
|
||||
fetchData(employeeId);
|
||||
|
||||
}
|
||||
},[employeeId])
|
||||
|
||||
|
||||
|
@ -16,7 +16,8 @@ import { hasUserPermission } from "../../utils/authUtils";
|
||||
const AttendancePage = () =>
|
||||
{
|
||||
const loginUser = getCachedProfileData()
|
||||
const selectedProject = useSelector((store)=>store.localVariables.projectId)
|
||||
var selectedProject = useSelector( ( store ) => store.localVariables.projectId )
|
||||
selectedProject = 5;
|
||||
const {projects,loading:projectLoading} = useProjects()
|
||||
const {attendance,loading:attLoading} = useAttendace(selectedProject)
|
||||
const[attendances,setAttendances] = useState()
|
||||
|
@ -8,14 +8,16 @@ import {useEmployeesAllOrByProjectId} from "../../hooks/useEmployees";
|
||||
import { useProjects } from "../../hooks/useProjects";
|
||||
import { useProfile } from "../../hooks/useProfile";
|
||||
import {hasUserPermission} from "../../utils/authUtils";
|
||||
import {MANAGE_EMPLOYEES} from "../../utils/constants";
|
||||
import {useHasUserPermission} from "../../hooks/useHasUserPermission";
|
||||
|
||||
const EmployeeList = () =>
|
||||
{
|
||||
|
||||
|
||||
|
||||
const {profile:loginUser}= useProfile()
|
||||
const [selectedProject, setSelectedProject] = useState("");
|
||||
const {projects, loading: projectLoading} = useProjects()
|
||||
const ManageEmployee = useHasUserPermission(MANAGE_EMPLOYEES)
|
||||
|
||||
const {employees, loading,setLoading, error} = useEmployeesAllOrByProjectId( selectedProject );
|
||||
const [ projectsList, setProjectsList ] = useState(projects || [] );
|
||||
@ -45,31 +47,19 @@ const EmployeeList = () =>
|
||||
setFilteredData(results);
|
||||
};
|
||||
|
||||
// useEffect(() => {
|
||||
// if ( loginUser && projects )
|
||||
// {
|
||||
// const filteredProjects = projects.filter((project) =>
|
||||
// loginUser?.projects?.map(Number).includes(project.id)
|
||||
// );
|
||||
// setProjectsList(filteredProjects);
|
||||
// }
|
||||
// }, [ loginUser, projects ] );
|
||||
|
||||
|
||||
|
||||
useEffect(() => {
|
||||
setCurrentPage( 1 )
|
||||
|
||||
if (!loading && Array.isArray(employees)) {
|
||||
setEmployeeList(employees);
|
||||
setFilteredData(employees);
|
||||
setFilteredData( employees );
|
||||
}
|
||||
|
||||
}, [loading, employees, selectedProject]);
|
||||
|
||||
|
||||
const displayData = searchText ? filteredData : employeeList
|
||||
|
||||
const indexOfLastItem = currentPage * itemsPerPage;
|
||||
const indexOfFirstItem = indexOfLastItem - itemsPerPage;
|
||||
const currentItems = Array.isArray(displayData)
|
||||
@ -110,6 +100,7 @@ const EmployeeList = () =>
|
||||
}, [ modelConfig, isCreateModalOpen ] );
|
||||
|
||||
|
||||
console.log("employeManage : ", ManageEmployee)
|
||||
|
||||
return (
|
||||
<>
|
||||
@ -138,7 +129,6 @@ const EmployeeList = () =>
|
||||
className="dataTables_length text-start"
|
||||
id="DataTables_Table_0_length"
|
||||
>
|
||||
|
||||
<label>
|
||||
<select
|
||||
id="project-select"
|
||||
@ -237,8 +227,8 @@ const EmployeeList = () =>
|
||||
</li>
|
||||
</ul>
|
||||
<button
|
||||
className={`btn btn-sm add-new btn-primary `}
|
||||
// ${hasUserPermission("81ab8a87-8ccd-4015-a917-0627cee6a100")?"":"d-none"}
|
||||
|
||||
className={`btn btn-sm add-new btn-primary ${!ManageEmployee && 'd-none'}`}
|
||||
tabIndex="0"
|
||||
type="button"
|
||||
>
|
||||
@ -249,7 +239,7 @@ const EmployeeList = () =>
|
||||
>
|
||||
<i className="bx bx-plus-circle me-2"></i>
|
||||
<span className="d-none d-md-inline-block">
|
||||
Add New User
|
||||
Add New Employee
|
||||
</span>
|
||||
</Link>
|
||||
</span>
|
||||
@ -284,7 +274,6 @@ const EmployeeList = () =>
|
||||
aria-controls="DataTables_Table_0"
|
||||
rowSpan="1"
|
||||
colSpan="1"
|
||||
// style={{ width: "332px" }}
|
||||
aria-label="User: activate to sort column ascending"
|
||||
aria-sort="descending"
|
||||
>
|
||||
@ -296,7 +285,6 @@ const EmployeeList = () =>
|
||||
aria-controls="DataTables_Table_0"
|
||||
rowSpan="1"
|
||||
colSpan="1"
|
||||
// style={{ width: "332px" }}
|
||||
aria-label="User: activate to sort column ascending"
|
||||
aria-sort="descending"
|
||||
>
|
||||
@ -326,7 +314,7 @@ const EmployeeList = () =>
|
||||
</th>
|
||||
|
||||
<th
|
||||
className="sorting_disabled"
|
||||
className={`sorting_disabled d-none ${!ManageEmployee && 'd-none'}`}
|
||||
rowSpan="1"
|
||||
colSpan="1"
|
||||
style={{ width: "50px" }}
|
||||
@ -390,10 +378,10 @@ const EmployeeList = () =>
|
||||
Active
|
||||
</span>
|
||||
</td>
|
||||
<td className="d-flex justify-content-end justify-content-sm-center">
|
||||
<td className={`d-flex justify-content-end justify-content-sm-center ${!ManageEmployee && 'd-none'} `}>
|
||||
<div className="d-flex align-items-center ">
|
||||
<a
|
||||
className="btn btn-icon dropdown-toggle hide-arrow"
|
||||
className={`btn btn-icon dropdown-toggle hide-arrow`}
|
||||
data-bs-toggle="dropdown"
|
||||
>
|
||||
<i className="bx bx-dots-vertical-rounded bx-md"></i>
|
||||
@ -408,9 +396,7 @@ const EmployeeList = () =>
|
||||
>
|
||||
View
|
||||
</a>
|
||||
{/* <a
|
||||
|
||||
> */}
|
||||
<Link
|
||||
className={`dropdown-item `}
|
||||
// ${hasUserPermission("81ab8a87-8ccd-4015-a917-0627cee6a100")?"":"d-none"}
|
||||
@ -418,7 +404,7 @@ const EmployeeList = () =>
|
||||
>
|
||||
Edit
|
||||
</Link>
|
||||
{/* </a> */}
|
||||
|
||||
<a className="dropdown-item">
|
||||
Suspend
|
||||
</a>
|
||||
|
@ -7,13 +7,17 @@ import { changeMaster } from "../../slices/localVariablesSlice";
|
||||
import useMaster from "../../hooks/masterHook/useMaster"
|
||||
import MasterTable from "./MasterTable";
|
||||
import { getCachedData } from "../../slices/apiDataManager";
|
||||
import {useHasUserPermission} from "../../hooks/useHasUserPermission";
|
||||
import { MASTER_MANAGE } from "../../utils/constants";
|
||||
|
||||
|
||||
const MasterPage = () => {
|
||||
|
||||
const [modalConfig, setmodalConfig] = useState({modalType: "", item: null, masterType:null });
|
||||
const [searchTerm, setSearchTerm] = useState('');
|
||||
const [filteredResults, setFilteredResults] = useState([]);
|
||||
const [ filteredResults, setFilteredResults ] = useState( [] );
|
||||
const hasMasterPermission = useHasUserPermission( MASTER_MANAGE )
|
||||
console.log(hasMasterPermission)
|
||||
const dispatch = useDispatch();
|
||||
const selectedMaster = useSelector((store)=>store.localVariables.selectedMaster)
|
||||
|
||||
@ -98,7 +102,6 @@ const MasterPage = () => {
|
||||
return (
|
||||
<>
|
||||
{isCreateModalOpen && (
|
||||
|
||||
<MasterModal modaldata={modalConfig} closeModal={closeModal} />
|
||||
|
||||
)}
|
||||
@ -160,7 +163,7 @@ const MasterPage = () => {
|
||||
></input>
|
||||
</label>
|
||||
</div>
|
||||
<div className="dt-buttons btn-group flex-wrap">
|
||||
<div className={`dt-buttons btn-group flex-wrap ${!hasMasterPermission && 'd-none'}`}>
|
||||
{" "}
|
||||
<div className="input-group">
|
||||
|
||||
|
@ -48,7 +48,7 @@ const MasterTable = ( {data, columns, loading, handleModalData} ) =>
|
||||
<th></th>
|
||||
<th>Name</th>
|
||||
<th>Description</th>
|
||||
<th className={` ${hasMasterPermission? "":"d-none"}`}>Actions</th>
|
||||
<th className={` ${!hasMasterPermission && 'd-none'}`}>Actions</th>
|
||||
{/* ${hasUserPermission('660131a4-788c-4739-a082-cbbf7879cbf2') ? "":"d-none"} */}
|
||||
</tr>
|
||||
</thead>
|
||||
@ -78,7 +78,7 @@ const MasterTable = ( {data, columns, loading, handleModalData} ) =>
|
||||
|
||||
|
||||
))}
|
||||
<td >
|
||||
<td className={`${!hasMasterPermission && 'd-none'}`} >
|
||||
{/* className={` ${hasUserPermission('660131a4-788c-4739-a082-cbbf7879cbf2') ? "":"d-none"}`}> */}
|
||||
<button
|
||||
aria-label="Modify"
|
||||
|
@ -7,4 +7,8 @@ export const ASSIGN_USER_TO_PROJECT = "81ab8a87-8ccd-4015-a917-0627cee6a100";
|
||||
|
||||
export const INFRASTRUCTURE = "9666de86-d7c7-4d3d-acaa-fcd6d6b81f3c";
|
||||
|
||||
export const MANAGE_PROJECT = "53176ebf-c75d-42e5-839f-4508ffac3def"
|
||||
export const MANAGE_PROJECT = "53176ebf-c75d-42e5-839f-4508ffac3def"
|
||||
|
||||
export const MANAGE_EMPLOYEES = "81ab8a87-8ccd-4015-a917-0627cee6a100"
|
||||
|
||||
export const MANAGE_INFRA = "9666de86-d7c7-4d3d-acaa-fcd6d6b81f3c"
|
Loading…
x
Reference in New Issue
Block a user