#110 select project is fixed

parent c79bfce2
......@@ -62,7 +62,6 @@ router.get('/all-fields/', async (req : Request, res : Response):Promise<object>
},
}
})
console.log('all fields users ', users)
return res.send({users})
})
......
......@@ -61,11 +61,11 @@ export default function MultipleSelect({projects,projectName,onClose,setProjectN
>
{projects?.map((project) => (
<MenuItem
key={project}
value={project}
style={getStyles(project, projectName, theme)}
key={project.id}
value={project.id}
style={getStyles(project, project.title, theme)}
>
{project}
{project.title}
</MenuItem>
))}
</Select>
......
......@@ -8,12 +8,12 @@ import MultipleSelect from '../UI/MultipleSelect/MultipleSelect';
import Add from "@mui/icons-material/Add";
import Close from "@mui/icons-material/Close";
export default function MyTaskToolBar({projects,onClose,projectName,setProjectName,formStatus,onClick}) {
export default function UsersTaskToolBar({projects,onClose,projectName,setProjectName,formStatus,onClick}) {
let projectsFilter =
<></>
if (projects) {
if (Array.isArray(projects)) {
projectsFilter=
<MultipleSelect
projects={projects}
......
......@@ -11,7 +11,7 @@ import { useState, useEffect } from "react";
import { useDispatch, useSelector } from "react-redux";
import TaskModal from "../../components/UsersTasksCompoments/TaskModal/TaskModal";
import moment from "moment";
import MyTaskToolBar from "../../components/UsersTasksCompoments/UsersTaskToolBar";
import UsersTaskToolBar from "../../components/UsersTasksCompoments/UsersTaskToolBar";
import { fetchAllTasks, deleteTask,editTask, deleteDateTimeTask , fetchAllTasksByMembership} from "../../store/actions/tasksActions";
import NewTaskForm from "../../components/UsersTasksCompoments/NewTaskForm";
import TableRowTask from "../../components/UsersTasksCompoments/TableRowTask/TableRowTask";
......@@ -45,11 +45,13 @@ export default function UsersTasks() {
if (tasks && tasks?.length > 0) {
setRecievedTasks(tasks);
}
}, [dispatch, tasks?.length]);
}, [dispatch,
tasks?.length,
addTaskForm, setAddTaskForm]);
useEffect(() => {
dispatch(fetchAllTasksByMembership());
}, [addTaskForm, setAddTaskForm]);
// useEffect(() => {
// dispatch(fetchAllTasksByMembership());
// }, [addTaskForm, setAddTaskForm]);
......@@ -112,14 +114,21 @@ useEffect(() => {
const onProjectChange = (e, task) => {
const projectId = e.target.value;
const project = projects.find((uniqueProject) => uniqueProject.id === projectId);
const project = projects.length>0 ?projects.find((uniqueProject) => uniqueProject.id === projectId):null;
setCurrentProject(project)
if(project?.members){
for (let member of project.members){
setExecutors([...executors, member.user])
}
console.log('executors ', executors)
}
const { id } = task;
const newTasks = recievedTasks.map((task) => {
if (task.id === id) {
const updated = { ...task };
updated.project = project;
updated.projectName = project.title;
updated.projectName =project.title? project.title:null;
return updated;
}
return task;
......@@ -209,10 +218,12 @@ useEffect(() => {
const onClose=(projectName)=>{
console.log('projectName ', projectName)
let tasksFilteredByProject = tasks
if (projectName.length>0) {
tasksFilteredByProject = tasks.filter(task=>projectName.includes(task.project?.title))
tasksFilteredByProject = tasks.filter(task=>projectName.includes(task.project?.id))
}
console.log('tasksFilteredByProject ', tasksFilteredByProject)
setRecievedTasks(tasksFilteredByProject)
setFilterProjectTumbler(true)
}
......@@ -244,7 +255,6 @@ useEffect(() => {
return results;
}, []);
console.log('tasks', tasks)
if (
tasks &&
......@@ -255,7 +265,7 @@ console.log('tasks', tasks)
return (
<Box sx={{ width: "fullwidth" }}>
<Paper sx={{ width: "100%", mb: 2 }}>
<MyTaskToolBar
<UsersTaskToolBar
onClick={() => setAddTaskForm(!addTaskForm)}
formStatus={addTaskForm}
projects={projects}
......@@ -275,7 +285,7 @@ console.log('tasks', tasks)
<TableContainer>
<Table sx={{ minWidth: 600 }} aria-labelledby="tableTitle">
<Table sx={{ minWidth: 600 }} aria-labelledby="tableTitle" size='small'>
<UsersTasksHeader
order={order}
orderBy={orderBy}
......@@ -294,7 +304,6 @@ console.log('tasks', tasks)
task={task}
deleteHandle={deleteHandle}
handleEditTask ={handleEditTask}
handleEditDateTimeTask={handleEditDateTimeTask}
deleteDateTimeTask={deleteDateTimeTaskHandle}
onChange={onChange}
onModalOpen={onModalOpen}
......
......@@ -64,8 +64,8 @@ export const fetchAllTasks = () => {
};
//**fetch tasks for table UsersTasks, start*/
const fetchAllTasksByMembershipSuccess = (tasks) => {
return {type: FETCH_ALL_TASKS_BY_MEMBERSHIP_SUCCESS, tasks}
const fetchAllTasksByMembershipSuccess = (tasks, projects) => {
return {type: FETCH_ALL_TASKS_BY_MEMBERSHIP_SUCCESS, tasks, projects}
};
......@@ -75,7 +75,7 @@ export const fetchAllTasksByMembership = () => {
dispatch(fetchCalendarTasksRequest());
try {
const response = await axios.get("/tasks/users-tasks");
dispatch(fetchAllTasksByMembershipSuccess(response.data.tasks))
dispatch(fetchAllTasksByMembershipSuccess(response.data.tasks, response.data.projects))
} catch (error) {
dispatch(fetchCalendarTasksFailure(error.response.data));
}
......
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