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

Merge branch 'apiserver' into 'master'

getReports call updated

See merge request !64
parents ac2d1f63 abd20890
......@@ -9,12 +9,13 @@ import Loading from "../loading Component/Loading";
function LeftSidebar() {
const dispatch = useDispatch();
const [currPage, setCurrPage] = useState(1);
const [inputValue, setInputValue] = useState('');
const [inputValue, setInputValue] = useState(null);
const { reportees, loading, viewReportee } = useSelector((state) => state.reportees);
const userDetails = useSelector((state) => state.userDetails);
useEffect(() => {
if(inputValue!==null){
const debounceTimeout = setTimeout(() => {
const data = {
reportees: userDetails.user.reportees,
......@@ -24,8 +25,10 @@ function LeftSidebar() {
};
dispatch(fetchReportees(data));
}, 1000);
return () => clearTimeout(debounceTimeout);
}
}, [inputValue]);
const handleChange = (event) => {
......
......@@ -4,6 +4,7 @@ import { useParams, useNavigate } from "react-router";
import { base_url } from "../../utils/constants";
import axios from 'axios';
import { fetchReportees } from "../../redux/reducers/reporteesSlice";
import {fetchReporteeActivities} from '../../redux/reducers/viewreporteeSlice'
import Accordion from "../../components/accordion";
import {scoreColor} from '../../utils/commonFunctions';
......@@ -74,6 +75,11 @@ function Viewreportee() {
}
}
useEffect(()=>{
if(reportees.length>0 && viewReportee)
dispatch(fetchReporteeActivities({empId:viewReportee.empId}))
},[reportees])
useEffect(() => {
......
......@@ -10,7 +10,7 @@ const initialState = {
error: null,
};
export const fetchReports = createAsyncThunk("getReports", async (data) => {
export const fetchReporteeActivities = createAsyncThunk("getReports", async (data) => {
return await axios
.post(`${base_url}/getActivities`, data)
.then((response) => response.data);
......@@ -47,13 +47,13 @@ const reportSlice = createSlice({
},
extraReducers: (builder) => {
builder.addCase(fetchReports.pending, (state) => {
builder.addCase(fetchReporteeActivities.pending, (state) => {
return {...state,loading :true,error :"loading"}
});
builder.addCase(fetchReports.fulfilled, (state, action) => {
builder.addCase(fetchReporteeActivities.fulfilled, (state, action) => {
return {...state,loading :false,error :"",reports:action.payload?.activities}
});
builder.addCase(fetchReports.rejected, (state, action) => {
builder.addCase(fetchReporteeActivities.rejected, (state, action) => {
return {...state,loading :false,error :action.error || "Something went wrong!",reports:null}
});
},
......
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