Commit d858670a authored by Shiva Komirishetti's avatar Shiva Komirishetti

Role based menu changes

parent 699a1060
...@@ -19,9 +19,12 @@ ...@@ -19,9 +19,12 @@
"react": "^18.2.0", "react": "^18.2.0",
"react-datepicker": "^6.3.0", "react-datepicker": "^6.3.0",
"react-dom": "^18.2.0", "react-dom": "^18.2.0",
"react-js-loader": "^0.1.3",
"react-modal": "^3.16.1",
"react-redux": "^9.1.0", "react-redux": "^9.1.0",
"react-router-dom": "^6.22.3", "react-router-dom": "^6.22.3",
"react-scripts": "5.0.1", "react-scripts": "5.0.1",
"react-toastify": "^10.0.5",
"redux-persist": "^6.0.0", "redux-persist": "^6.0.0",
"redux-thunk": "^3.1.0", "redux-thunk": "^3.1.0",
"uuid": "^9.0.1", "uuid": "^9.0.1",
......
...@@ -155,7 +155,7 @@ app.post('/createActivity',async (req, res) => { ...@@ -155,7 +155,7 @@ app.post('/createActivity',async (req, res) => {
let { data } = req.body; let { data } = req.body;
//data validation //data validation
if (!_.get(data, "aName", "") || !_.get(data, "aId", "") || !_.get(data, "type", "") || !_.get(data, "score", "") || !_.get(data,"comments","") ||!_.get(data,"ratedBy","") ) { if (!_.get(data, "aName", "") || !_.get(data, "type", "") || !_.get(data, "score", "") || !_.get(data,"comments","") ||!_.get(data,"ratedBy","") ) {
res.status(401).json({ "error": "Invalid Activity data" }); res.status(401).json({ "error": "Invalid Activity data" });
return; return;
} }
......
...@@ -7,8 +7,7 @@ import './App.css'; ...@@ -7,8 +7,7 @@ import './App.css';
import PageNotFound from './pages/pagenotfound/PageNotFound'; import PageNotFound from './pages/pagenotfound/PageNotFound';
import Exporttable from './pages/reportexport' import Exporttable from './pages/reportexport'
import AdminProfile from './pages/adminProfile'; import AdminProfile from './pages/adminProfile';
import Adminreports from './pages/adminreports'; import ActivityList from './pages/activityList';
import Admin from './pages/admin';
function App() { function App() {
return ( return (
...@@ -24,10 +23,8 @@ function App() { ...@@ -24,10 +23,8 @@ function App() {
<Route path="/viewreportee" element={<Viewreportee/>}/> <Route path="/viewreportee" element={<Viewreportee/>}/>
{/* fetch reports */} {/* fetch reports */}
<Route path="/reportees" element={<Exporttable/>}/> <Route path="/reportees" element={<Exporttable/>}/>
{/* Admin reports */}
<Route path="/adminreportees" element={<Adminreports/>}/>
{/* Activity List */} {/* Activity List */}
<Route path="/Admin" element={<Admin/>}/> <Route path="/activityList" element={<ActivityList/>}/>
</Route> </Route>
<Route path="/*" element={<PageNotFound/>}/> <Route path="/*" element={<PageNotFound/>}/>
</Routes> </Routes>
......
import React from 'react';
import Modal from 'react-modal';
const customStyles = {
content: {
top: '50%',
left: '50%',
right: 'auto',
bottom: 'auto',
marginRight: '-50%',
transform: 'translate(-50%, -50%)',
},
};
function BaseModal({children, open}) {
return (
<Modal
isOpen={open}
style={customStyles}
>
{children}
</Modal>
);
}
export default BaseModal;
\ No newline at end of file
import React from 'react';
import BaseModal from '../baseModal';
function ConfirmPopup(props) {
const {open, header, content, handleCancel, handleConfirm} = props;
return (
<BaseModal
open={open}
>
<div className='w-[350px]'>
<h3 className='font-semibold'>{header}</h3>
{content && <p className='my-4'> {content}</p>}
<div className='flex justify-end'>
<button className="px-3 py-2 ml-5 bg-gray-500 text-white rounded-md hover:bg-gray-400" onClick={handleCancel}>Cancel</button>
<button className="px-3 py-2 ml-5 bg-blue-500 text-white rounded-md hover:bg-blue-300" onClick={handleConfirm}>Confirm</button>
</div>
</div>
</BaseModal>
)
}
export default ConfirmPopup
import React, { useEffect, useState, useCallback } from "react"; import React, { useEffect, useState, useCallback } from "react";
import axios from "axios"; import axios from "axios";
import { base_url } from "../../utils/constants"; import { base_url } from "../../utils/constants";
import { fetchData } from "../../pages/admin"; import { toast } from 'react-toastify';
const MyCreateModal = ({ setShowMyModal,handleRefresh}) => { const MyCreateModal = ({ setShowMyModal,handleRefresh}) => {
const [formData, setFormData] = useState({ const [formData, setFormData] = useState({
...@@ -48,8 +48,8 @@ const MyCreateModal = ({ setShowMyModal,handleRefresh}) => { ...@@ -48,8 +48,8 @@ const MyCreateModal = ({ setShowMyModal,handleRefresh}) => {
try { try {
// console.log(formData.atype); // console.log(formData.atype);
await axios.post(`${base_url}/addMasterActivity`, formData) await axios.post(`${base_url}/addMasterActivity`, formData)
.then((res)=>fetchData())
setShowMyModal(false); setShowMyModal(false);
toast.success("Activity created successfully.")
setFormData({ setFormData({
atype: "", atype: "",
aName: "", aName: "",
......
...@@ -86,11 +86,11 @@ export default function MyModal({ visible, onClose, type, handleAddActivity }) { ...@@ -86,11 +86,11 @@ export default function MyModal({ visible, onClose, type, handleAddActivity }) {
setActivtyType(str.charAt(0).toUpperCase() + str.slice(1).toLowerCase()) setActivtyType(str.charAt(0).toUpperCase() + str.slice(1).toLowerCase())
} }
useEffect(() => { useEffect(() => {
if (type === "duties") { // if (type === "duties") {
setDisableAppreciate(true); // setDisableAppreciate(true);
} else { // } else {
setDisableAppreciate(false); // setDisableAppreciate(false);
} // }
SentenceCase(type) SentenceCase(type)
if (visible === false) { if (visible === false) {
setActivityData({ aName: "", ratedBy: "", type: type, score: 0, comments: "" }) setActivityData({ aName: "", ratedBy: "", type: type, score: 0, comments: "" })
...@@ -107,6 +107,10 @@ export default function MyModal({ visible, onClose, type, handleAddActivity }) { ...@@ -107,6 +107,10 @@ export default function MyModal({ visible, onClose, type, handleAddActivity }) {
setActivityData({ ...activityData, aName: "" }) setActivityData({ ...activityData, aName: "" })
} }
const disableState = (value) => {
const state = activitiesList?.find((activity) => activity.aName === activityData.aName);
if(state) return state[value]
}
if (!visible) return null; if (!visible) return null;
...@@ -127,19 +131,19 @@ export default function MyModal({ visible, onClose, type, handleAddActivity }) { ...@@ -127,19 +131,19 @@ export default function MyModal({ visible, onClose, type, handleAddActivity }) {
{ {
activitiesList && activitiesList.map((activity) => <option className=" w-7/12" value={activity.aName}>{activity.aName}</option>) activitiesList && activitiesList.map((activity) => <option className=" w-7/12" value={activity.aName}>{activity.aName}</option>)
} }
<option value="custom" className={`${showCustActivity || type == "duties" && 'hidden'}`}>Add Activity</option> {/* <option value="custom" className={`${showCustActivity || type == "duties" && 'hidden'}`}>Add Activity</option> */}
</select> </select>
</div> </div>
<div className={`flex items-center ${!showCustActivity && 'hidden'}`}> <div className={`flex items-center ${!showCustActivity && 'hidden'}`}>
<label className={`font-medium mr-2`}>Activity<span className="text-[15px]">*</span>:</label> <label className={`font-medium mr-2`}>Activity<span className="text-[15px]">*</span>:</label>
<input type="text" value={activityData.aName} placeholder="Enter Activity name" name="performance" className={`border border-gray-300 rounded p-2 `} onChange={(e) => handleCustumActivity(e)} /> <input type="text" value={activityData.aName} placeholder="Enter Activity name" name="performance" className={`border border-gray-300 rounded p-2 `} onChange={(e) => handleCustumActivity(e)} />
</div> </div>
<div className="flex items-center mb-4 "> {activityData.aName && <div className="flex items-center mb-4 ">
<label htmlFor="appreciate" className="font-medium">APPRECIATION<span className="text-[15px]">*</span>:</label> <label htmlFor="appreciate" className="font-medium">APPRECIATION<span className="text-[15px]">*</span>:</label>
<input id="appreciate" disabled={disableAppreciate} type="radio" value="appreciate" name="performance" className="w-4 h-4 m-3 text-blue-600 bg-gray-100 border-gray-300 " onChange={() => handlePerformance(1)} /> <input id="appreciate" disabled={!disableState('appreciate')} type="radio" value="appreciate" name="performance" className="w-4 h-4 m-3 text-blue-600 bg-gray-100 border-gray-300 " onChange={() => handlePerformance(1)} />
<label htmlFor="depreciate" className="ms-2 font-medium ">DEPRECIATION<span className="text-[15px]">*</span>:</label> <label htmlFor="depreciate" className="ms-2 font-medium ">DEPRECIATION<span className="text-[15px]">*</span>:</label>
<input id="depreciate" type="radio" value="depreciate" name="performance" className="w-4 h-4 m-3 text-blue-600 bg-gray-100 border-gray-300 " onChange={() => handlePerformance(-1)} /> <input id="depreciate" disabled={!disableState('depreciate')} type="radio" value="depreciate" name="performance" className="w-4 h-4 m-3 text-blue-600 bg-gray-100 border-gray-300 " onChange={() => handlePerformance(-1)} />
</div> </div>}
<div className={`flex ${!showScore && 'hidden'}`}> <div className={`flex ${!showScore && 'hidden'}`}>
<span>SCORE<span className="text-[15px]">*</span>: </span> <span>SCORE<span className="text-[15px]">*</span>: </span>
<select className="border w-1/5 ms-1" onChange={(e) => handleScoreChange(e.target.value)} value={activityData.score}> <select className="border w-1/5 ms-1" onChange={(e) => handleScoreChange(e.target.value)} value={activityData.score}>
......
...@@ -4,16 +4,12 @@ import { Link, useParams, useLocation } from "react-router-dom"; ...@@ -4,16 +4,12 @@ import { Link, useParams, useLocation } from "react-router-dom";
import SetWindowSize from '../../utils/SetWindowSize'; import SetWindowSize from '../../utils/SetWindowSize';
import DashboardIcon from '../../assets/icons/dashboardIcon'; import DashboardIcon from '../../assets/icons/dashboardIcon';
import ReportsIcon from '../../assets/icons/reportsIcon'; import ReportsIcon from '../../assets/icons/reportsIcon';
import AdminProfileIcon from '../../assets/icons/adminProfileIcon'; // Assuming you have an icon for Admin Profile
import Admin from "../../pages/admin";
const menus = [ const menus = [
{ title: "Dashboard", path: '/dashboard', selectPaths: ['/dashboard'], icon: <DashboardIcon />, role:[2, 3] }, { title: "Dashboard", path: '/dashboard', selectPaths: ['/dashboard'], icon: <DashboardIcon />, role:[2, 3] },
{ title: "My Reportees", path: '/myreportees', selectPaths: ['/myreportees', '/viewreportee'], icon: <ReportsIcon />, role:[2] }, { title: "My Reportees", path: '/myreportees', selectPaths: ['/myreportees', '/viewreportee'], icon: <ReportsIcon />, role:[2] },
{ title: "Reports", path: '/reportees', selectPaths:['/reportees'], icon: <ReportsIcon />, role:[2] }, { title: "Activity List", path: '/activityList', selectPaths:['/activityList'], icon: <ReportsIcon />, role:[1] },
{ title: "Activity List", path: '/admin', selectPaths:['/admin'], icon: <ReportsIcon />, role:[1] }, { title: "Reports", path: '/reportees', selectPaths:['/reportees'], icon: <ReportsIcon />, role:[2,1] }
{ title: "Reports", path: '/adminreportees', selectPaths:['/adminreportees'], icon: <ReportsIcon />, role:[1] },
] ]
function Sidebar() { function Sidebar() {
......
...@@ -43,3 +43,7 @@ code { ...@@ -43,3 +43,7 @@ code {
transform: rotate(360deg); transform: rotate(360deg);
} }
} }
.ReactModal__Overlay {
background-color: rgb(153 150 150 / 55%) !important;
}
\ No newline at end of file
import React, { useEffect, useState } from "react"; import React, { useEffect, useState } from "react";
import { useSelector, useDispatch } from "react-redux"; // Import useDispatch import { useSelector, useDispatch } from "react-redux"; // Import useDispatch
import CreateActivityButton from '../../components/modal/createActivityButton'; import CreateActivityButton from '../../components/modal/createActivityButton.jsx';
import Table from '../../components/table'; import Table from '../../components/table/index.jsx';
import Loading from "../../components/loading Component/Loading"; import Loading from "../../components/loading Component/Loading.jsx";
import { styles } from './styles.js'; import { styles } from './styles.js';
import { convertToString } from "../../utils/commonFunctions"; import { convertToString } from "../../utils/commonFunctions.js";
import axiosApi from '../../api/axiosConfig' import axiosApi from '../../api/axiosConfig.js'
import ConfirmPopup from "../../components/confirmationPopup/index.jsx";
import { toast } from 'react-toastify';
// Define fetchData function const ActivityList = () => {
export const fetchData = async () => { const [activitiesList, setActivitiesList] = useState([]);
const { loading } = useSelector((state) => state.reportees);
const [deleteId, setDeleteId] = useState(null);
const [deleteActivity, setDeleteActivity] = useState(null)
const dispatch = useDispatch(); // Initialize useDispatch
const fetchActivityData = async () => {
try { try {
const response = await axiosApi.get(`/activities`); const response = await axiosApi.get(`/activities`);
//setActivitiesList(response.data) setActivitiesList(response.data)
return response.data;
} catch (error) { } catch (error) {
console.error('Error fetching data:', error); // console.error('Error fetching data:', error);
throw error; // Rethrow the error for handling by the caller if needed throw error; // Rethrow the error for handling by the caller if needed
} }
}; };
const Admin = () => {
const [activitiesList, setActivitiesList] = useState([]);
const [refresh,setRefresh]=useState(true)
const { loading } = useSelector((state) => state.reportees);
const dispatch = useDispatch(); // Initialize useDispatch
const handleRefresh=()=>{
setRefresh(!refresh)
}
useEffect(() => { useEffect(() => {
// Call fetchData when the component mounts fetchActivityData();
fetchData().then((res)=>setActivitiesList(res)) }, []);
}, [refresh]);
const handleDelete = async (_id) => { const handleDelete = async (_id) => {
try { try {
//console.log("Deleting activity with id:", _id); //console.log("Deleting activity with id:", _id);
await axiosApi.put(`/deleteMasterActivity`, { ObjectId: _id }); await axiosApi.put(`/deleteMasterActivity`, { ObjectId: _id });
setRefresh(!refresh) toast.success('Activity deleted successfully.')
// console.log("Deleted successfully"); fetchActivityData();
} catch (error) { } catch (error) {
// console.error("Error deleting activity:", _id); // console.error("Error deleting activity:", _id);
// console.error("Error:", error); // console.error("Error:", error);
} finally {
setDeleteId(null);
} }
}; };
...@@ -60,17 +53,10 @@ const handleRefresh=()=>{ ...@@ -60,17 +53,10 @@ const handleRefresh=()=>{
{ {
title: "Actions", title: "Actions",
id: "_id", id: "_id",
render: (id) => ( render: (id, item) => (
<button <button
className="bg-red-400 text-white rounded-md px-1 py-1 flex items-center justify-center w-[40px]" className="bg-red-400 text-white rounded-md px-1 py-1 flex items-center justify-center w-[40px]"
onClick={() => { onClick={() => {setDeleteId(id); setDeleteActivity(item.aName)}}
if (id) {
handleDelete(id);
//console.log(id)
} else {
// console.error("Item or item._id is undefined");
}
}}
> >
X X
</button> </button>
...@@ -87,12 +73,19 @@ const handleRefresh=()=>{ ...@@ -87,12 +73,19 @@ const handleRefresh=()=>{
ACTIVITY LIST ACTIVITY LIST
</div> </div>
<div className="flex" style={{ justifyContent: 'flex-end', marginBottom: "10px" }}> <div className="flex" style={{ justifyContent: 'flex-end', marginBottom: "10px" }}>
<CreateActivityButton handleRefresh={handleRefresh} /> <CreateActivityButton handleRefresh={() => fetchActivityData()} />
</div> </div>
<Table headers={headers} loading={loading} data={activitiesList} /> <Table headers={headers} loading={loading} data={activitiesList} />
</div> </div>
<ConfirmPopup
open={deleteId ? true : false}
header='Delete Activity'
content={`Are you sure want to delete ${deleteActivity} activity.`}
handleCancel={() => setDeleteId(null)}
handleConfirm={() => handleDelete(deleteId)}
/>
</div> </div>
); );
}; };
export default Admin; export default ActivityList;
export const styles = {
createActivityContainer: "overflow-auto sm:rounded-lg p-4",
textBlueHeading: "text-blue-800 py-3 pl-2 text-center fond-bold text-2xl",
};
\ No newline at end of file
export const styles = {
createActivityContainer: "overflow-auto sm:rounded-lg p-4 bg-[#E9EDEE] ",
textBlueHeading: "text-blue-800 py-3 pl-2 text-center fond-bold text-2xl",
};
\ No newline at end of file
...@@ -130,6 +130,7 @@ function Adminreports() { ...@@ -130,6 +130,7 @@ function Adminreports() {
{ {
title: "Actions", title: "Actions",
id: "_id", id: "_id",
hide: false,
render: (id) => ( render: (id) => (
<button <button
className="bg-red-400 text-white rounded-md px-1 py-1 flex items-center justify-center w-[40px]" className="bg-red-400 text-white rounded-md px-1 py-1 flex items-center justify-center w-[40px]"
......
...@@ -133,7 +133,7 @@ function Dashboard() { ...@@ -133,7 +133,7 @@ function Dashboard() {
<label>Search :</label> <label>Search :</label>
<input placeholder="Name/Id/Designation/Role" value={inputValue} onChange={handleChange} type="text" className="p-1 px-2 border rounded ml-2 placeholder:text-[14px]"/> <input placeholder="Name/Id/Designation/Role" value={inputValue} onChange={handleChange} type="text" className="p-1 px-2 border rounded ml-2 placeholder:text-[14px]"/>
</div> </div>
<Table headers={headers} data={reportees} loading={loading} handleSorting={handleSort}/> <Table headers={headers} data={reportees} loading={loading} handleSorting={handleSort} loadingRows={10} />
<div className=""> <div className="">
{reportees.length>0 && pagesCount>1 && ( {reportees.length>0 && pagesCount>1 && (
......
...@@ -45,7 +45,7 @@ function Home() { ...@@ -45,7 +45,7 @@ function Home() {
useEffect(()=>{ useEffect(()=>{
if (userDetails?.user!=null){ if (userDetails?.user!=null){
if(userDetails?.user.roleId === 1) if(userDetails?.user.roleId === 1)
navigate("/admin") navigate("/activityList")
else else
navigate("/dashboard") navigate("/dashboard")
} }
......
import React, { useEffect, useState } from "react"; import React, { useEffect, useMemo, useState } from "react";
import axiosApi from '../../api/axiosConfig'; import axiosApi from '../../api/axiosConfig';
import { useDispatch, useSelector } from "react-redux"; import { useDispatch, useSelector } from "react-redux";
import { fetchReportesActivitiesData, resetReporteesTableData, resetActivitiesData } from "../../redux/reducers/exporttableslice"; import { fetchReportesActivitiesData, resetReporteesTableData, resetActivitiesData } from "../../redux/reducers/exporttableslice";
import { fetchReportees } from "../../redux/reducers/reporteesSlice"; import { fetchReportees } from "../../redux/reducers/reporteesSlice";
import { convertUTCToLocal } from "../../utils/commonFunctions"; import { convertUTCToLocal } from "../../utils/commonFunctions";
import ConfirmPopup from "../../components/confirmationPopup/index.jsx";
import { toast } from 'react-toastify';
import Table from "../../components/table"; import Table from "../../components/table";
import DownloadIcon from '../../assets/icons/downloadIcon'; import DownloadIcon from '../../assets/icons/downloadIcon';
import jsPDF from 'jspdf'; import jsPDF from 'jspdf';
...@@ -17,13 +19,15 @@ function Exporttable() { ...@@ -17,13 +19,15 @@ function Exporttable() {
const { reportees, loading, totalCount, currPage, pagesCount } = useSelector( const { reportees, loading, totalCount, currPage, pagesCount } = useSelector(
(state) => state.reportees (state) => state.reportees
); );
const [selectedEmployee, setSelectedEmployee] = useState(0); const [selectedEmployee, setSelectedEmployee] = useState(0);
const [fromDate, setFromDate] = useState(""); const [fromDate, setFromDate] = useState("");
const [toDate, setToDate] = useState(""); const [toDate, setToDate] = useState("");
const [inputValue, setInputValue] = useState(''); const [inputValue, setInputValue] = useState('');
const [pdfLoading, setPdfLoading] = useState(false); const [pdfLoading, setPdfLoading] = useState(false);
const [selectedDate, setSelectedDate] = useState(null) const [selectedDate, setSelectedDate] = useState(null)
const [employees, setEmployees] = useState(null);
const [deleteId, setDeleteId] = useState(null);
const [deleteActivityName, setDeleteActivityName] = useState(null)
useEffect(() => { useEffect(() => {
if(selectedEmployee && fromDate && toDate) { if(selectedEmployee && fromDate && toDate) {
...@@ -66,19 +70,45 @@ function Exporttable() { ...@@ -66,19 +70,45 @@ function Exporttable() {
useEffect(() => { useEffect(() => {
if (user) { if (user) {
if(user.roleId !== 1){
let data = { let data = {
reportees: user.reportees, reportees: user.reportees,
page: 1, page: 1,
perPage: 100000000, //user.reportees.length, perPage: 100000000, //user.reportees.length,
getMasterData: true getMasterData: true
}; };
dispatch(fetchReportees(data)); dispatch(fetchReportees(data))
} else {
const getEmployees = async () => {
try {
const res = await axiosApi.get(`/employees`);
const data = res?.data.filter((emp) => emp.roleId !== 1)
setEmployees(data)
} catch (error) {
// console.error("Error:", error);
}
}
if(employees === null) getEmployees();
}
} }
return(() => { return(() => {
dispatch(resetReporteesTableData()) dispatch(resetReporteesTableData())
}) })
}, []); }, []);
const handleReportieDelete = async (id) => {
try {
await axiosApi.put(`/deleteActivity`, { ObjectId: id, empId: Number(selectedEmployee) });
toast.success('Activity deleted successfully.')
dispatch(fetchReportesActivitiesData({ empId: Number(selectedEmployee), fromDate, toDate }));
} catch (error) {
// console.error("Error deleting activity:", id);
// console.error("Error:", error);
} finally {
setDeleteId(null);
}
};
const headers = [ const headers = [
{ title: "Activity Name", id: "aName" }, { title: "Activity Name", id: "aName" },
...@@ -106,6 +136,27 @@ function Exporttable() { ...@@ -106,6 +136,27 @@ function Exporttable() {
</span> </span>
), ),
}, },
{
title: "Actions",
id: "_id",
hide: user.roleId !== 1 ? true : false,
render: (id, item) => (
<button
className="bg-red-400 text-white rounded-md px-1 py-1 flex items-center justify-center w-[40px]"
onClick={() => {
// if (id && selectedEmployee) {
// handleReportieDelete(id,selectedEmployee);
// } else {
// // console.error("Item or item._id is undefined");
// }
setDeleteId(id);
setDeleteActivityName(item.aName)
}}
>
X
</button>
)
},
]; ];
const periodOptions = ['Past 1 month', 'Past 3 months', 'Past 6 months', 'Past 1 year'] const periodOptions = ['Past 1 month', 'Past 3 months', 'Past 6 months', 'Past 1 year']
...@@ -163,9 +214,10 @@ function Exporttable() { ...@@ -163,9 +214,10 @@ function Exporttable() {
const handleSelectedName=(value)=>{ const handleSelectedName=(value)=>{
if(value!=="") if(value!=="")
setSelectedEmployee(value) setSelectedEmployee(value)
} }
const employeeList = user?.roleId === 1 ? employees : reportees;
return ( return (
<div> <div>
<div className={styles.genarateReportContainer}> <div className={styles.genarateReportContainer}>
...@@ -190,8 +242,8 @@ function Exporttable() { ...@@ -190,8 +242,8 @@ function Exporttable() {
<option id="" value=""> <option id="" value="">
Select Select
</option> </option>
{reportees && {employeeList &&
reportees.map((reportee) => ( employeeList.map((reportee) => (
<option <option
className="text-pretty" className="text-pretty"
key={reportee?.empId} key={reportee?.empId}
...@@ -246,6 +298,13 @@ function Exporttable() { ...@@ -246,6 +298,13 @@ function Exporttable() {
</div> </div>
<Table headers={headers} loading={loading} data={activitiesData} /> <Table headers={headers} loading={loading} data={activitiesData} />
</div> </div>
<ConfirmPopup
open={deleteId ? true : false}
header='Delete Activity'
content={`Are you sure want to delete ${deleteActivityName} activity.`}
handleCancel={() => setDeleteId(null)}
handleConfirm={() => handleReportieDelete(deleteId,selectedEmployee)}
/>
</div> </div>
); );
......
...@@ -83,6 +83,7 @@ function Viewreportee() { ...@@ -83,6 +83,7 @@ function Viewreportee() {
if(reporteeId) { if(reporteeId) {
fetchViewReporteeData(reporteeId) fetchViewReporteeData(reporteeId)
dispatch(fetchActivitiesAvg({empId:reporteeId, types:["duties", "initiative"]})) dispatch(fetchActivitiesAvg({empId:reporteeId, types:["duties", "initiative"]}))
setOpen({ "accordianOne": false, "accordianTwo": false });
} }
}, [reporteeId]) }, [reporteeId])
......
...@@ -49,8 +49,8 @@ const reportSlice = createSlice({ ...@@ -49,8 +49,8 @@ const reportSlice = createSlice({
}); });
builder.addCase(fetchActivitiesAvg.fulfilled, (state, action) => { builder.addCase(fetchActivitiesAvg.fulfilled, (state, action) => {
const avgScores = action.payload; const avgScores = action.payload;
const dutiesAvg = avgScores.find(({type}) => type === "duties") const dutiesAvg = avgScores.find(({_id}) => _id === "duties")
const initiatieAvg = avgScores.find(({type}) => type === "initiative") const initiatieAvg = avgScores.find(({_id}) => _id === "initiative")
return {...state,loading :false,error :"", defaultAvgScore: dutiesAvg?.avgScore.toFixed(1) || 0, initiativeAvgScore: initiatieAvg?.avgScore.toFixed(1) || 0} return {...state,loading :false,error :"", defaultAvgScore: dutiesAvg?.avgScore.toFixed(1) || 0, initiativeAvgScore: initiatieAvg?.avgScore.toFixed(1) || 0}
}); });
builder.addCase(fetchActivitiesAvg.rejected, (state, action) => { builder.addCase(fetchActivitiesAvg.rejected, (state, action) => {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment