Add api to fetch employee project allocation
This commit is contained in:
parent
0e8691f6d0
commit
eb735f443d
@ -1,14 +1,15 @@
|
||||
import React, { useEffect, useState } from "react";
|
||||
import EmpOverview from "./EmpOverview";
|
||||
import { useProjectsByEmployee } from "../../hooks/useProjects";
|
||||
import { useProjectsAllocationByEmployee } from "../../hooks/useProjects";
|
||||
|
||||
const EmpDashboard = ({ profile }) => {
|
||||
const {
|
||||
projectList,
|
||||
loading: selectedProjectLoding,
|
||||
refetch,
|
||||
} = useProjectsByEmployee(profile?.id);
|
||||
} = useProjectsAllocationByEmployee(profile?.id);
|
||||
|
||||
console.log(projectList);
|
||||
return (
|
||||
<>
|
||||
<div className="row">
|
||||
@ -32,16 +33,47 @@ const EmpDashboard = ({ profile }) => {
|
||||
>
|
||||
<div className="avatar flex-shrink-0 me-4">
|
||||
<span className="avatar-initial rounded bg-label-primary">
|
||||
<i className="icon-base bx bx-buildings icon-lg"></i>
|
||||
<i className="icon-base bx bx-buildings icon-lg "></i>
|
||||
</span>
|
||||
</div>
|
||||
<div className="row w-100 align-items-center">
|
||||
<div className="col-sm-8 col-lg-12 col-xxl-8 mb-1 mb-sm-0 mb-lg-1 mb-xxl-0 text-start">
|
||||
<h6 className="mb-0">{project.shortName}</h6>
|
||||
<div className="d-flex w-100 flex-wrap align-items-center justify-content-between gap-2">
|
||||
<div className="me-2">
|
||||
<div className="d-flex align-items-center">
|
||||
<h6 className="mb-0 me-2">
|
||||
{project.projectShortName}
|
||||
</h6>
|
||||
</div>
|
||||
<small>{project.projectName}</small>
|
||||
</div>
|
||||
<div className="user-progress">
|
||||
<div className="badge bg-label-secondary ">
|
||||
{project.designation}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div className="col-sm-4 col-lg-12 col-xxl-4 d-flex justify-content-xxl-end">
|
||||
<div className="label-secondary">{project.name}</div>
|
||||
<div className="col-sm-4 col-lg-12 col-xxl-4 d-flex justify-content-xxl-end mt-1">
|
||||
<div className="label-secondary">
|
||||
Assigned:{" "}
|
||||
{project.assignedDate ? (
|
||||
new Date(project.assignedDate).toLocaleDateString()
|
||||
) : (
|
||||
<em>NA</em>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
{project.removedDate && (
|
||||
<div className="col-sm-4 col-lg-12 col-xxl-4 d-flex justify-content-xxl-end mt-1">
|
||||
<div className="label-secondary">
|
||||
Unassigned:{" "}
|
||||
{project.removedDate ? (
|
||||
new Date(project.removedDate).toLocaleDateString()
|
||||
) : (
|
||||
<em>NA</em>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
</li>
|
||||
))}
|
||||
@ -49,15 +81,6 @@ const EmpDashboard = ({ profile }) => {
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{/* <div className="col col-4 pt-5">
|
||||
<div className="card">
|
||||
<div className="card-body">
|
||||
<small className="card-text text-uppercase text-body-secondary small">
|
||||
My Expences
|
||||
</small>{" "}
|
||||
</div>{" "}
|
||||
</div>
|
||||
</div> */}
|
||||
</div>
|
||||
</>
|
||||
);
|
||||
|
@ -307,6 +307,36 @@ export const useProjectsByEmployee = (employeeId) => {
|
||||
return { projectList, loading: isLoading, error, refetch };
|
||||
};
|
||||
|
||||
export const useProjectsAllocationByEmployee = (employeeId) => {
|
||||
const {
|
||||
data: projectList = [],
|
||||
isLoading,
|
||||
error,
|
||||
refetch,
|
||||
} = useQuery({
|
||||
queryKey: ["ProjectsAllocationByEmployee", employeeId],
|
||||
queryFn: async () => {
|
||||
const res = await ProjectRepository.getProjectsAllocationByEmployee(
|
||||
employeeId
|
||||
);
|
||||
const sortedProjects = [...res.data].sort((a, b) =>
|
||||
a.projectName.localeCompare(b.projectName)
|
||||
);
|
||||
return sortedProjects || res;
|
||||
|
||||
//return res.data || res;
|
||||
},
|
||||
enabled: !!employeeId,
|
||||
onError: (error) => {
|
||||
showToast(
|
||||
error.message || "Error while Fetching project Employee",
|
||||
"error"
|
||||
);
|
||||
},
|
||||
});
|
||||
return { projectList, loading: isLoading, error, refetch };
|
||||
};
|
||||
|
||||
export const useProjectName = () => {
|
||||
const {
|
||||
data = [],
|
||||
|
@ -6,32 +6,37 @@ const ProjectRepository = {
|
||||
api.get(`/api/project/details/${projetid}`),
|
||||
|
||||
getProjectAllocation: (projetid) =>
|
||||
api.get( `api/project/allocation/${ projetid }` ),
|
||||
api.get(`api/project/allocation/${projetid}`),
|
||||
|
||||
getEmployeesByProject:(projectId)=>api.get(`/api/Project/employees/get/${projectId}`),
|
||||
getEmployeesByProject: (projectId) =>
|
||||
api.get(`/api/Project/employees/get/${projectId}`),
|
||||
|
||||
manageProject: (data) => api.post("/api/project", data),
|
||||
// updateProject: (data) => api.post("/api/project/update", data),
|
||||
|
||||
manageProjectAllocation: ( data ) => api.post( "/api/project/allocation", data ),
|
||||
manageProjectAllocation: (data) => api.post("/api/project/allocation", data),
|
||||
|
||||
manageProjectInfra: (data) => api.post("/api/project/manage-infra", data),
|
||||
manageProjectTasks: ( data ) => api.post( "/api/project/task", data ),
|
||||
deleteProjectTask:(id)=> api.delete(`/api/project/task/${id}`),
|
||||
manageProjectTasks: (data) => api.post("/api/project/task", data),
|
||||
deleteProjectTask: (id) => api.delete(`/api/project/task/${id}`),
|
||||
|
||||
updateProject: (id, data) => api.put(`/api/project/update/${id}`, data),
|
||||
deleteProject: ( id ) => api.delete( `/projects/${ id }` ),
|
||||
getProjectsByEmployee: ( id ) => api.get( `/api/project/assigned-projects/${ id }` ),
|
||||
updateProjectsByEmployee:(id,data)=>api.post(`/api/project/assign-projects/${id}`,data),
|
||||
projectNameList: () => api.get( "/api/project/list/basic" ),
|
||||
deleteProject: (id) => api.delete(`/projects/${id}`),
|
||||
getProjectsByEmployee: (id) =>
|
||||
api.get(`/api/project/assigned-projects/${id}`),
|
||||
getProjectsAllocationByEmployee: (id) =>
|
||||
api.get(`/api/project/allocation-histery/${id}`),
|
||||
updateProjectsByEmployee: (id, data) =>
|
||||
api.post(`/api/project/assign-projects/${id}`, data),
|
||||
projectNameList: () => api.get("/api/project/list/basic"),
|
||||
|
||||
getProjectDetails:(id)=>api.get(`/api/project/details/${id}`),
|
||||
getProjectInfraByproject: ( id ) => api.get( `/api/project/infra-details/${ id }` ),
|
||||
getProjectTasksByWorkArea:(id)=>api.get(`/api/project/tasks/${id}`)
|
||||
getProjectDetails: (id) => api.get(`/api/project/details/${id}`),
|
||||
getProjectInfraByproject: (id) => api.get(`/api/project/infra-details/${id}`),
|
||||
getProjectTasksByWorkArea: (id) => api.get(`/api/project/tasks/${id}`),
|
||||
};
|
||||
|
||||
export const TasksRepository = {
|
||||
assignTask: ( data ) => api.post( "/api/task/assign", data ),
|
||||
assignTask: (data) => api.post("/api/task/assign", data),
|
||||
// reportTask:(data)=>api.post("/api/task/report",data)
|
||||
}
|
||||
};
|
||||
export default ProjectRepository;
|
||||
|
Loading…
x
Reference in New Issue
Block a user