This commit is contained in:
Николай Полтщук 2023-05-15 21:09:31 +03:00
parent b94ea09c54
commit 52b166e1c2

View File

@ -52,22 +52,26 @@ export const Tracker = () => {
).then((el) => { ).then((el) => {
dispatch(setAllProjects(el.projects)); dispatch(setAllProjects(el.projects));
setLoader(false); setLoader(false);
setAllCompletedTasks(el.projects.filter((project) => { // setAllCompletedTasks(el.projects.filter((project) => {
if (project.status === 10 && project.columns.length) { // if (project.status === 10 && project.columns.length) {
return project // return project
} // }
}).map((project) => { return project.columns}).reduce((acu, curr) => { // }).map((project) => { return project.columns}).reduce((acu, curr) => {
curr.forEach((item) => { // curr.forEach((item) => {
acu.push(...item.tasks) // acu.push(...item.tasks)
}) // })
return acu // return acu
}, [])) // }, []))
}); });
apiRequest( apiRequest(
`/task/get-user-tasks?user_id=${localStorage.getItem("id")}` `/task/get-user-tasks?user_id=${localStorage.getItem("id")}`
).then((el) => { ).then((el) => {
setAllTasks(el); const allTasks = el.filter((item) => item.status !== 0)
setFilteredAllTasks(el); const completedTasks = el.filter((item) => item.status === 0)
setAllTasks(allTasks);
setFilteredAllTasks(allTasks);
setAllCompletedTasks(completedTasks)
setFilterCompleteTasks(completedTasks)
}); });
}, []); }, []);
@ -94,21 +98,21 @@ export const Tracker = () => {
} }
function filterArchiveTasks(e) { function filterArchiveTasks(e) {
// setFilterCompleteTasks( setFilterCompleteTasks(
// completeTasks.filter((item) => { allCompletedTasks.filter((item) => {
// if (!e.target.value) { if (!e.target.value) {
// return item; return item;
// } }
// if ( if (
// item.name.toLowerCase().startsWith(e.target.value.toLowerCase()) || item.title.toLowerCase().startsWith(e.target.value.toLowerCase()) ||
// item.description item.description
// .toLowerCase() .toLowerCase()
// .startsWith(e.target.value.toLowerCase()) .startsWith(e.target.value.toLowerCase())
// ) { ) {
// return item; return item;
// } }
// }) })
// ); );
} }
return ( return (
@ -291,14 +295,14 @@ export const Tracker = () => {
return ( return (
<div className="archive__completeTask" key={index}> <div className="archive__completeTask" key={index}>
<div className="archive__completeTask__description"> <div className="archive__completeTask__description">
<p>{task.description}</p> <p>{task.title}</p>
<p className="date">{task.dateComplete}</p> <p className="date">{task.description}</p>
</div> </div>
<div className="archive__completeTask__info"> <div className="archive__completeTask__info">
<img src={task.avatarDo} alt="avatar" /> <img src={urlForLocal(task.user.avatar)} alt="avatar" />
<div className="archive__completeTask__info__project"> <div className="archive__completeTask__info__project">
<span>Проект</span> {/*<span>Проект</span>*/}
<p>{task.project}</p> <p>{getCorrectDate(task.updated_at)}</p>
</div> </div>
</div> </div>
</div> </div>