#138 added filtration active project button

parent eb22fe70
...@@ -7,8 +7,9 @@ import Button from '@mui/material/Button'; ...@@ -7,8 +7,9 @@ import Button from '@mui/material/Button';
import MultipleSelect from '../../components/UI/MultipleSelect/MultipleSelect'; import MultipleSelect from '../../components/UI/MultipleSelect/MultipleSelect';
import Add from "@mui/icons-material/Add"; import Add from "@mui/icons-material/Add";
import Close from "@mui/icons-material/Close"; import Close from "@mui/icons-material/Close";
// import { TaskSharp } from '@mui/icons-material';
export default function MyTaskToolBar({projects,onClose,projectIdListForTaskSelect,setProjectIdListForTaskSelect,formStatus,onClick}) { export default function MyTaskToolBar({projects,onClickActiveTasks,activeTasksOn, onCloseFilterByProjects,projectIdListForTaskSelect,setProjectIdListForTaskSelect,formStatus,onClick}) {
let projectsFilter = let projectsFilter =
<></> <></>
...@@ -17,12 +18,13 @@ export default function MyTaskToolBar({projects,onClose,projectIdListForTaskSele ...@@ -17,12 +18,13 @@ export default function MyTaskToolBar({projects,onClose,projectIdListForTaskSele
projectsFilter= projectsFilter=
<MultipleSelect <MultipleSelect
projects={projects} projects={projects}
onClose={onClose} onClose={onCloseFilterByProjects}
projectName={projectIdListForTaskSelect} projectName={projectIdListForTaskSelect}
setProjectName={setProjectIdListForTaskSelect} setProjectName={setProjectIdListForTaskSelect}
/> />
} }
return ( return (
<Box sx={{ flexGrow: 1 }}> <Box sx={{ flexGrow: 1 }}>
...@@ -31,6 +33,18 @@ export default function MyTaskToolBar({projects,onClose,projectIdListForTaskSele ...@@ -31,6 +33,18 @@ export default function MyTaskToolBar({projects,onClose,projectIdListForTaskSele
<Typography variant="h6" component="div" sx={{ flexGrow: 1 }}> <Typography variant="h6" component="div" sx={{ flexGrow: 1 }}>
Мои задачи Мои задачи
</Typography> </Typography>
<Button
color={"inherit"}
style={{
backgroundColor: activeTasksOn === true ? "red" : "inherit",
}}
onClick={onClickActiveTasks}
>
Активные задачи
</Button>
{projectsFilter} {projectsFilter}
<Button <Button
......
...@@ -34,6 +34,10 @@ export default function EnhancedTable() { ...@@ -34,6 +34,10 @@ export default function EnhancedTable() {
open: false, open: false,
task: null, task: null,
}); });
const [projectIdListForTaskSelect, setProjectIdListForTaskSelect] = React.useState([]);
// const [filterProjectTumbler, setFilterProjectTumbler] = React.useState(false);
// const[filteredActiveTasks, setActiveTasks] = React.useState([]);
const [activeTasksOn, setActiveTasksOn] = React.useState(false)
useEffect(() => { useEffect(() => {
...@@ -43,7 +47,10 @@ export default function EnhancedTable() { ...@@ -43,7 +47,10 @@ export default function EnhancedTable() {
} }
}, [ }, [
tasks?.length, tasks?.length,
addTaskForm, setAddTaskForm, dispatch]); addTaskForm, setAddTaskForm,
// onClickActiveTasks,
// activeTasksOn,
dispatch]);
// console.log('tasks ', tasks, 'projects ', projects,"recievedTasks ", recievedTasks ) // console.log('tasks ', tasks, 'projects ', projects,"recievedTasks ", recievedTasks )
...@@ -177,18 +184,35 @@ export default function EnhancedTable() { ...@@ -177,18 +184,35 @@ export default function EnhancedTable() {
}; };
// ++++++++фильтрация по проектам+++++++++++++++ // ++++++++фильтрация по проектам+++++++++++++++
const [projectIdListForTaskSelect, setProjectIdListForTaskSelect] = React.useState([]);
const [filterProjectTumbler, setFilterProjectTumbler] = React.useState(false);
const onClose=(projectIdListForTaskSelect)=>{
const onCloseFilterByProjects=(projectIdListForTaskSelect)=>{
let tasksFilteredByProject = tasks let tasksFilteredByProject = tasks
if (projectIdListForTaskSelect.length>0) { if (projectIdListForTaskSelect.length>0) {
tasksFilteredByProject = tasks.filter(task=>projectIdListForTaskSelect.includes(task.project?.id)) tasksFilteredByProject = tasks.filter(task=>projectIdListForTaskSelect.includes(task.project?.id))
} }
console.log('tasksFilteredByProject ', tasksFilteredByProject) console.log('tasksFilteredByProject ', tasksFilteredByProject)
setRecievedTasks(tasksFilteredByProject) setRecievedTasks(tasksFilteredByProject)
setFilterProjectTumbler(true) // setFilterProjectTumbler(true)
} }
const onClickActiveTasks= ()=>{
console.log('active tasts before switched to ', activeTasksOn)
setActiveTasksOn((prevState)=>{return !prevState})
console.log('active tasts after switch ', activeTasksOn)
if (activeTasksOn) {
const activeTasks= recievedTasks.filter(recievedTask=>recievedTask.accomplish==='opened' || recievedTask.accomplish==='progress' )
console.log('received tasks in switch', recievedTasks)
setRecievedTasks(activeTasks)
} else {
setRecievedTasks(tasks)
}
}
// if ( // if (
// tasks && // tasks &&
// tasks?.length > 0 // tasks?.length > 0
...@@ -203,9 +227,11 @@ export default function EnhancedTable() { ...@@ -203,9 +227,11 @@ export default function EnhancedTable() {
onClick={() => setAddTaskForm(!addTaskForm)} onClick={() => setAddTaskForm(!addTaskForm)}
formStatus={addTaskForm} formStatus={addTaskForm}
projects={projects} projects={projects}
onClose={onClose} onCloseFilterByProjects={onCloseFilterByProjects}
projectIdListForTaskSelect={projectIdListForTaskSelect} projectIdListForTaskSelect={projectIdListForTaskSelect}
setProjectIdListForTaskSelect={setProjectIdListForTaskSelect} setProjectIdListForTaskSelect={setProjectIdListForTaskSelect}
onClickActiveTasks={onClickActiveTasks}
activeTasksOn={activeTasksOn}
/> />
{addTaskForm ? ( {addTaskForm ? (
......
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