Commit 4c4ebe82 authored by Venkaiah Naidu Singamchetty's avatar Venkaiah Naidu Singamchetty

Merge branch 'initailSetup' into 'master'

Initail setup

See merge request !61
parents 875a403b efa2471f
...@@ -2,7 +2,7 @@ import {BrowserRouter, Routes, Route} from 'react-router-dom'; ...@@ -2,7 +2,7 @@ import {BrowserRouter, Routes, Route} from 'react-router-dom';
import Home from "./pages/home"; import Home from "./pages/home";
import Dashboard from './pages/dashboard'; import Dashboard from './pages/dashboard';
import Layout from './pages/layout'; import Layout from './pages/layout';
import Reports from './pages/reports'; import Viewreportee from './pages/viewReportee';
import './App.css'; import './App.css';
import PageNotFound from './pages/pagenotfound/PageNotFound'; import PageNotFound from './pages/pagenotfound/PageNotFound';
...@@ -12,7 +12,7 @@ function App() { ...@@ -12,7 +12,7 @@ function App() {
<Routes> <Routes>
<Route path='/' element={<Home />}/> <Route path='/' element={<Home />}/>
<Route path="/dashboard" element={<Layout><Dashboard/></Layout>}/> <Route path="/dashboard" element={<Layout><Dashboard/></Layout>}/>
<Route path="/viewreportee/:id" element={<Layout><Reports/></Layout>}/> <Route path="/viewreportee" element={<Layout><Viewreportee/></Layout>}/>
<Route path="/*" element={<PageNotFound/>}/> <Route path="/*" element={<PageNotFound/>}/>
</Routes> </Routes>
</BrowserRouter> </BrowserRouter>
......
import React, { useEffect, useState } from "react"; import React, { useEffect, useState } from "react";
import { fetchReportees } from "../../redux/reducers/reporteesSlice"; import { fetchReportees, setViewReportee } from "../../redux/reducers/reporteesSlice";
import { Link } from "react-router-dom"; import { Link } from "react-router-dom";
import { useSelector, useDispatch } from "react-redux"; import { useSelector, useDispatch } from "react-redux";
import { useParams } from "react-router-dom"; import { useParams } from "react-router-dom";
...@@ -10,9 +10,9 @@ function LeftSidebar() { ...@@ -10,9 +10,9 @@ function LeftSidebar() {
const dispatch = useDispatch(); const dispatch = useDispatch();
const [currPage, setCurrPage] = useState(1); const [currPage, setCurrPage] = useState(1);
const [inputValue, setInputValue] = useState(''); const [inputValue, setInputValue] = useState('');
const { reportees, loading } = useSelector((state) => state.reportees); const { reportees, loading, viewReportee } = useSelector((state) => state.reportees);
const userDetails = useSelector((state) => state.userDetails); const userDetails = useSelector((state) => state.userDetails);
const { id } = useParams();
useEffect(() => { useEffect(() => {
const debounceTimeout = setTimeout(() => { const debounceTimeout = setTimeout(() => {
...@@ -51,18 +51,19 @@ function LeftSidebar() { ...@@ -51,18 +51,19 @@ function LeftSidebar() {
(loading) ? <Loading /> : (loading) ? <Loading /> :
<div className="p-2 bg-[#E9EDEE] mt-4 max-h-[80vh] overflow-auto"> <div className="p-2 bg-[#E9EDEE] mt-4 max-h-[80vh] overflow-auto">
{reportees?.map(({ empName, score, empId }) => ( {reportees?.map(({ empName, score, empId }) => (
<Link <button onClick={() => dispatch(setViewReportee(empId))}
to={`/viewreportee/${empId}`} // to={`/viewreportee`}
className={`flex items-center hover:bg-blue-400 hover:text-white hover:rounded-2xl bg-${Number(id) == empId ? "blue-400 text-white rounded-2xl" : "white" className={`flex items-center hover:bg-blue-400 hover:text-white bg-${viewReportee.empId == empId ? "blue-400 text-white rounded-2xl" : "white"
} p-2 justify-between mb-1 w-full`} } p-2 justify-between mb-1 w-full`}
key={empId} key={empId}
> >
{/* <img src="/man.png" width="18px" height="18px" /> */}
<p className="w-[80%] text-left">{empName}</p> <p className="w-[80%] text-left">{empName}</p>
<p className={`w-[30px] h-[30px] rounded-full flex items-center text-white justify-center ${scoreColor(score)}`}> <p className={`w-[30px] h-[30px] rounded-full flex items-center text-white justify-center ${scoreColor(score)}`}>
{score} {score}
</p> </p>
</Link> </button>
))} ))}
</div> </div>
} }
......
...@@ -23,7 +23,7 @@ function Table({headers, data,loading, maxHeight}) { ...@@ -23,7 +23,7 @@ function Table({headers, data,loading, maxHeight}) {
<tr key={item.id} className="bg-white hover:bg-gray-300 " > <tr key={item.id} className="bg-white hover:bg-gray-300 " >
{ {
headers?.map(({render, id}) => ( headers?.map(({render, id}) => (
<td key={`${item.id}_${id}`} className="px-6 py-2 " > <td className="px-6 py-2 " >
{render ? render(item[id]) : item[id] === "" ? "NA" : item[id] } {render ? render(item[id]) : item[id] === "" ? "NA" : item[id] }
</td> </td>
)) ))
......
import React, { useEffect, useState } from "react"; import React, { useEffect, useState } from "react";
import { Link, useNavigate } from "react-router-dom"; import { Link, useNavigate } from "react-router-dom";
import { useDispatch, useSelector } from "react-redux"; import { useDispatch, useSelector } from "react-redux";
import { fetchReportees } from "../../redux/reducers/reporteesSlice"; import { fetchReportees, setViewReportee } from "../../redux/reducers/reporteesSlice";
import Table from '../../components/table'; import Table from '../../components/table';
import RightArrowIcon from '../../assets/icons/rightArrowIcon'; import RightArrowIcon from '../../assets/icons/rightArrowIcon';
import { scoreColor } from '../../utils/commonFunctions'; import { scoreColor } from '../../utils/commonFunctions';
...@@ -101,8 +101,8 @@ function Dashboard() { ...@@ -101,8 +101,8 @@ function Dashboard() {
{ {
title: "Action", title: "Action",
id: "empId", id: "empId",
render: (value) => <Link to={`/viewreportee/${value}`}> render: (value) => <Link to={`/viewreportee`}>
<button className="bg-blue-400 text-white rounded-md px-2 py-1 flex items-center justify-center w-[40px]"> <button className="bg-blue-400 text-white rounded-md px-2 py-1 flex items-center justify-center w-[40px]" onClick={()=>dispatch(setViewReportee(value))}>
<RightArrowIcon /> <RightArrowIcon />
</button> </button>
</Link> </Link>
...@@ -117,7 +117,8 @@ function Dashboard() { ...@@ -117,7 +117,8 @@ function Dashboard() {
<div className=""> <div className="">
{reportees && ( {reportees && (
<div className="flex justify-center mt-2 "> <div className="flex justify-center mt-2">
{/* <div className="text-blue-500">Total Results: {pagesCount}</div> */}
{pagesCount >= 1 && ( {pagesCount >= 1 && (
<PaginationComponent <PaginationComponent
currentPage={currPage} currentPage={currPage}
......
...@@ -22,7 +22,6 @@ function Home() { ...@@ -22,7 +22,6 @@ function Home() {
.then((res) => { .then((res) => {
setLoading(false) setLoading(false)
dispatch(loginUser(res.data.user)) dispatch(loginUser(res.data.user))
navigate(`/dashboard`);
}) })
.catch((error)=>{ .catch((error)=>{
setLoading(false) setLoading(false)
......
...@@ -9,19 +9,20 @@ import Accordion from "../../components/accordion"; ...@@ -9,19 +9,20 @@ import Accordion from "../../components/accordion";
import {scoreColor} from '../../utils/commonFunctions'; import {scoreColor} from '../../utils/commonFunctions';
import DateRangePicker from "../../components/dateRangePicker/DateRangePicker"; import DateRangePicker from "../../components/dateRangePicker/DateRangePicker";
function Reports() { function Viewreportee() {
const dispatch = useDispatch(); const dispatch = useDispatch();
const navigate = useNavigate(); const navigate = useNavigate();
const { id } = useParams(); // const { id } = useParams();
const empId = Number(id) // const empId = Number(id)
const reportees = useSelector((state) => state.reportees.reportees); const {reportees, viewReportee } = useSelector((state) => state.reportees);
const user = useSelector((state) => state.userDetails.user) const user = useSelector((state) => state.userDetails.user)
const [empDetails, setEmpDetails] = useState(null); // const [empDetails, setEmpDetails] = useState(null);
const { reports, loading, error } = useSelector((state) => state.reports); const { reports, loading, error } = useSelector((state) => state.reports);
const [open, setOpen] = useState({ "accordianOne": false, "accordianTwo": false }); const [open, setOpen] = useState({ "accordianOne": false, "accordianTwo": false });
/*Example post data /*Example post data
{ {
"empId":41689, "empId":41689,
...@@ -34,7 +35,7 @@ function Reports() { ...@@ -34,7 +35,7 @@ function Reports() {
const filtered = Object.groupBy(reports, ({ type }) => type); const filtered = Object.groupBy(reports, ({ type }) => type);
return filtered; return filtered;
} }
}, [reports, id]); }, [reports, viewReportee]);
const handleAccordian = (value) => { const handleAccordian = (value) => {
switch (value) { switch (value) {
...@@ -63,9 +64,9 @@ function Reports() { ...@@ -63,9 +64,9 @@ function Reports() {
} }
const handleAddActivity = async (activityData) => { const handleAddActivity = async (activityData) => {
if (id) { if (viewReportee) {
let newData = { let newData = {
"empId": empId, "empId": viewReportee.empId,
"data": activityData "data": activityData
} }
await axios.post(`${base_url}/createActivity`, newData) await axios.post(`${base_url}/createActivity`, newData)
...@@ -78,31 +79,31 @@ function Reports() { ...@@ -78,31 +79,31 @@ function Reports() {
} }
useEffect(() => { useEffect(() => {
if (id !== undefined || null && reportees.length > 0) { // if (viewReportee !== undefined || null && reportees.length > 0) {
const emp = reportees?.filter((item) => item.empId === Number(id)); // const emp = reportees?.filter((item) => item.empId === Number(viewReportee.empId));
setEmpDetails(emp[0]); // setEmpDetails(emp[0]);
const data = { // const data = {
"empId": Number(id), // "empId": Number(viewReportee.empId),
"fromDate": "", // "fromDate": "",
"toDate": "" // "toDate": ""
} // }
dispatch(fetchReports(data)) // dispatch(fetchReports(data))
} // }
return (() => { // return (() => {
setEmpDetails(null) // setEmpDetails(null)
}) // })
}, [id, reportees]); }, [viewReportee, reportees]);
useEffect(() => { useEffect(() => {
if (user) { if (user) {
navigate(`/viewreportee/${id}`) navigate(`/viewreportee`)
setOpen({ "accordianOne": false, "accordianTwo": false }) setOpen({ "accordianOne": false, "accordianTwo": false })
} else { } else {
navigate("/") navigate("/")
} }
}, [id]); }, []);
if (empDetails && reportees.length) if (viewReportee && reportees.length)
return ( return (
<div className="p-4" > <div className="p-4" >
<div className="bg-white p-3 rounded-md"> <div className="bg-white p-3 rounded-md">
...@@ -110,33 +111,33 @@ function Reports() { ...@@ -110,33 +111,33 @@ function Reports() {
{/* <img src="/generic-male-avatar-rectangular.jpg" width="100px" height="100px" /> */} {/* <img src="/generic-male-avatar-rectangular.jpg" width="100px" height="100px" /> */}
<div className="my-1"> <div className="my-1">
<p> <p>
<span className="font-medium">Employee Name : </span> {empDetails?.empName} <span className="font-medium">Employee Name : </span> {viewReportee?.empName}
</p> </p>
<p> <p>
<span className="font-medium">Designation : </span> {empDetails?.designation} <span className="font-medium">Designation : </span> {viewReportee?.designation}
</p> </p>
{/* <p> {/* <p>
<span className="font-medium">Email Id: </span> {empDetails?.empEmail} <span className="font-medium">Email Id: </span> {viewReportee?.empEmail}
</p> */} </p> */}
</div> </div>
<div className="my-1"> <div className="my-1">
<p> <p>
<span className="font-medium">Role : </span> {empDetails?.techStack} <span className="font-medium">Role : </span> {viewReportee?.techStack}
</p> </p>
<p> <p>
<span className="font-medium">Employee Id: </span> {empDetails?.empId} <span className="font-medium">Employee Id: </span> {viewReportee?.empId}
</p> </p>
{/* <p> {/* <p>
<span className="font-medium">Total Score : </span> {empDetails?.score} <span className="font-medium">Total Score : </span> {viewReportee?.score}
</p> */} </p> */}
{/* <p> {/* <p>
<span className="font-medium">Allocated To : </span> {empDetails?.project} <span className="font-medium">Allocated To : </span> {viewReportee?.project}
</p> */} </p> */}
</div> </div>
<div className="flex flex-col justify-center items-center"> <div className="flex flex-col justify-center items-center">
<div className={`w-[40px] h-[40px] rounded-full flex items-center text-white justify-center ${scoreColor(empDetails?.score)}`}> <div className={`w-[40px] h-[40px] rounded-full flex items-center text-white justify-center ${scoreColor(viewReportee?.score)}`}>
<span className="text-lg font-bold">{empDetails?.score}</span> <span className="text-lg font-bold">{viewReportee?.score}</span>
</div> </div>
<div className=""> <div className="">
<span className="text-blue-400 font-semibold">Total Score</span> <span className="text-blue-400 font-semibold">Total Score</span>
...@@ -162,4 +163,4 @@ function Reports() { ...@@ -162,4 +163,4 @@ function Reports() {
} }
export default Reports; export default Viewreportee;
...@@ -4,6 +4,7 @@ import axios from "axios"; ...@@ -4,6 +4,7 @@ import axios from "axios";
const initialState = { const initialState = {
reportees: [], reportees: [],
viewReportee:null,
totalCount:0, totalCount:0,
loading: false, loading: false,
error: null, error: null,
...@@ -20,6 +21,20 @@ const reporteesSlice = createSlice({ ...@@ -20,6 +21,20 @@ const reporteesSlice = createSlice({
reducers: { reducers: {
resetReportees:() => { resetReportees:() => {
return initialState return initialState
},
setViewReportee:(state,action)=>{
const reportee=state.reportees.find((reportee)=>reportee.empId==action.payload)
if(!reportee){
return {
...state,
viewReportee: null
}
} else {
return {
...state,
viewReportee: reportee
}
}
} }
}, },
extraReducers: (builder) => { extraReducers: (builder) => {
...@@ -41,6 +56,6 @@ const reporteesSlice = createSlice({ ...@@ -41,6 +56,6 @@ const reporteesSlice = createSlice({
}, },
}); });
export const {resetReportees} = reporteesSlice.actions; export const {resetReportees,setViewReportee} = reporteesSlice.actions;
export default reporteesSlice.reducer; export default reporteesSlice.reducer;
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