Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
P
planner-team-one
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
21
Issues
21
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Евгений Положенцев
planner-team-one
Commits
354ab632
Commit
354ab632
authored
Nov 14, 2022
by
Евгений Положенцев
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'task-27-fixing_bags_page_my_tasks' into 'development'
Task 27 fixing bags page my tasks See merge request
!23
parents
fa05180f
e2fdc5e2
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
440 additions
and
450 deletions
+440
-450
CustomTableCell.js
...front/src/components/MyTasksCompoments/CustomTableCell.js
+26
-47
DateTimePicker.js
...onents/MyTasksCompoments/DateTimePicker/DateTimePicker.js
+29
-0
TaskModal.js
...t/src/components/MyTasksCompoments/TaskModal/TaskModal.js
+43
-68
DateTimePicker.js
...-front/src/components/UI/DateTimePicker/DateTimePicker.js
+0
-56
Select.js
planner-front/src/components/UI/Select/Select.js
+29
-0
MyTasks.js
planner-front/src/containers/MyTasks/MyTasks.js
+272
-262
MyTasksHeader.js
...ont/src/containers/MyTasks/MyTasksHeader/MyTasksHeader.js
+9
-10
tasksTypes.js
planner-front/src/store/actionTypes/tasksTypes.js
+2
-0
tasksActions.js
planner-front/src/store/actions/tasksActions.js
+25
-5
tasksReducer.js
planner-front/src/store/reducers/tasksReducer.js
+5
-2
No files found.
planner-front/src/components/MyTasksCompoments/CustomTableCell.js
View file @
354ab632
import
*
as
React
from
'react'
;
import
TableCell
from
'@mui/material/TableCell'
;
import
IconButton
from
'@mui/material/IconButton'
;
import
Input
from
'@mui/material/Input'
;
import
{
Done
,
CalendarToday
}
from
'@mui/icons-material'
;
import
MaterialUIPickers
from
'../UI/DateTimePicker/DateTimePicker'
;
import
*
as
React
from
"react"
;
import
TableCell
from
"@mui/material/TableCell"
;
import
Input
from
"@mui/material/Input"
;
const
CustomTableCell
=
({
task
,
name
,
value
,
onChange
,
onModalOpen
})
=>
{
const
styles
=
{
width
:
"auto"
,
height
:
"10px"
};
const
CustomTableCell
=
({
task
,
name
,
onChange
,
onModalOpen
})
=>
{
const
styles
=
{
width
:
"auto"
,
height
:
"40px"
};
return
(
<>
{
task
.
isEditMode
&&
name
===
"title"
?
(
<
TableCell
onClick
=
{(
e
)
=>
onModalOpen
(
e
,
task
)}
align
=
"left"
style
=
{
styles
}
>
<
Input
value
=
{
task
[
name
]}
name
=
{
name
}
onChange
=
{(
e
)
=>
onChange
(
e
,
task
)}
if
(
task
)
{
return
(
<>
<
TableCell
onClick
=
{(
e
)
=>
(
onModalOpen
?
onModalOpen
(
e
,
task
)
:
null
)}
align
=
"left"
style
=
{
styles
}
/
>
<
/TableCell
>
)
:
task
.
isEditMode
&&
name
!==
"title"
?
(
<
TableCell
align
=
"left"
style
=
{
styles
}
>
<
Input
value
=
{
task
[
name
]}
name
=
{
name
}
onChange
=
{(
e
)
=>
onChange
(
e
,
task
)}
style
=
{
styles
}
/
>
<
/TableCell
>
)
:
onModalOpen
?
(
<
TableCell
align
=
"left"
style
=
{
styles
}
onClick
=
{(
e
)
=>
onModalOpen
(
e
,
task
)}
>
<
span
style
=
{{
width
:
"100%"
}}
>
{
task
[
name
]}
<
/span
>
>
{
task
.
isEditMode
&&
onChange
?
(
<
Input
value
=
{
value
}
name
=
{
name
}
onChange
=
{(
e
)
=>
onChange
(
e
,
task
)}
style
=
{
styles
}
/
>
)
:
(
<
span
>
{
value
}
<
/span
>
)}
<
/TableCell
>
)
:
(
<
TableCell
align
=
"left"
style
=
{
styles
}
>
{
task
[
name
]}
<
/TableCell
>
)}
<
/
>
);
<
/
>
);
}
};
export
default
CustomTableCell
;
\ No newline at end of file
export
default
CustomTableCell
;
planner-front/src/components/MyTasksCompoments/DateTimePicker/DateTimePicker.js
0 → 100644
View file @
354ab632
import
*
as
React
from
"react"
;
import
TextField
from
"@mui/material/TextField"
;
import
{
LocalizationProvider
}
from
"@mui/x-date-pickers/LocalizationProvider"
;
import
{
DateTimePicker
}
from
"@mui/x-date-pickers/DateTimePicker"
;
import
{
AdapterMoment
}
from
"@mui/x-date-pickers/AdapterMoment"
;
export
default
function
MaterialUIPickers
(
props
)
{
return
(
<
LocalizationProvider
dateAdapter
=
{
AdapterMoment
}
sx
=
{{
width
:
"auto"
,
fontSize
:
5
,
fontWeight
:
"200"
}}
>
<
DateTimePicker
disabled
=
{
props
.
task
.
readOnly
}
renderInput
=
{(
params
)
=>
(
<
TextField
{...
params
}
sx
=
{{
width
:
"auto"
,
fontWeight
:
"200"
,
fontSize
:
5
}}
name
=
{
props
.
name
}
/
>
)}
value
=
{
props
.
task
[
props
.
name
]}
onChange
=
{(
newValue
)
=>
{
props
.
onChange
(
props
.
task
.
id
,
newValue
,
props
.
name
);
}}
/
>
<
/LocalizationProvider
>
);
}
planner-front/src/components/MyTasksCompoments/TaskModal/TaskModal.js
View file @
354ab632
import
{
Modal
,
IconButton
}
from
'@mui/material'
;
import
'./TaskModal.css'
;
import
{
Done
}
from
'@mui/icons-material'
;
import
Input
from
'@mui/material/Input'
;
import
{
useState
,
useEffect
}
from
"react"
;
import
{
Modal
,
IconButton
}
from
"@mui/material"
;
import
"./TaskModal.css"
;
import
{
Done
}
from
"@mui/icons-material"
;
import
Input
from
"@mui/material/Input"
;
const
TaskModal
=
(
props
)
=>
{
const
[
taskContent
,
setTaskContent
]
=
useState
();
useEffect
(()
=>
{
if
(
props
.
task
!==
null
)
{
setTaskContent
({
title
:
props
.
task
.
title
,
description
:
props
.
task
.
description
,
});
}
},
[
props
.
task
]);
const
inputChangeHandler
=
(
e
)
=>
{
const
{
name
,
value
}
=
e
.
target
;
setTaskContent
((
prevState
)
=>
{
return
{
...
prevState
,
[
name
]:
value
};
});
props
.
onChange
(
e
,
props
.
task
);
};
const
saveModalData
=
()
=>
{
props
.
handleClose
()
};
return
(
<
Modal
aria
-
labelledby
=
"transition-modal-title"
aria
-
describedby
=
"transition-modal-description"
className
=
{
"modal"
}
closeAfterTransition
onClose
=
{
props
.
handleClose
}
open
=
{
props
.
open
}
>
{
props
?.
task
?.
isEditMode
?
return
(
<
Modal
aria
-
labelledby
=
"transition-modal-title"
aria
-
describedby
=
"transition-modal-description"
className
=
{
"modal"
}
closeAfterTransition
onClose
=
{
props
.
handleClose
}
open
=
{
props
.
open
}
>
{
props
?.
task
?.
isEditMode
?
(
<
div
className
=
"modalBox"
>
<
Input
value
=
{
taskContent
?.
title
}
name
=
{
"title"
}
onChange
=
{
inputChangeHandler
}
style
=
{{
width
:
"auto"
,
fontSize
:
"12px"
,
color
:
"white"
,
fontWeight
:
"600"
}}
/
>
<
Input
value
=
{
taskContent
?.
description
}
name
=
{
"description"
}
onChange
=
{
inputChangeHandler
}
style
=
{{
width
:
"auto"
,
fontSize
:
"12px"
,
color
:
"white"
}}
/>
<
IconButton
aria
-
label
=
"done"
onClick
=
{
saveModalData
}
>
<
Done
/>
<
/IconButton>
<
/div>
:
value
=
{
props
.
task
.
title
}
name
=
"title"
onChange
=
{(
e
)
=>
props
.
onChange
(
e
,
props
.
task
)}
style
=
{{
width
:
"auto"
,
fontSize
:
"12px"
,
color
:
"white"
,
fontWeight
:
"600"
,
}}
/
>
<
Input
value
=
{
props
.
task
.
description
}
name
=
"description"
onChange
=
{(
e
)
=>
props
.
onChange
(
e
,
props
.
task
)}
style
=
{{
width
:
"auto"
,
fontSize
:
"12px"
,
color
:
"white"
}}
/
>
<
IconButton
aria
-
label
=
"done"
onClick
=
{
props
.
handleClose
}
>
<
Done
/>
<
/IconButton
>
<
/div
>
)
:
(
<
div
className
=
"modalBox"
>
{
props
.
task
&&
props
.
task
.
title
&&
(
{
props
.
task
&&
props
.
task
.
title
&&
(
<
div
style
=
{{
width
:
"200px"
,
height
:
"200px"
,
color
:
"white"
,
fontWeight
:
"600"
fontWeight
:
"600"
,
}}
>
{
props
.
task
.
title
}
...
...
@@ -88,9 +63,9 @@ const TaskModal = (props) => {
X
<
/IconButton
>
<
/div
>
}
<
/Modal
>
);
};
export
default
TaskModal
;
\ No newline at end of file
)}
<
/Modal
>
);
};
export
default
TaskModal
;
planner-front/src/components/UI/DateTimePicker/DateTimePicker.js
deleted
100644 → 0
View file @
fa05180f
import
*
as
React
from
'react'
;
import
TextField
from
'@mui/material/TextField'
;
import
{
LocalizationProvider
}
from
'@mui/x-date-pickers/LocalizationProvider'
;
import
{
AdapterDayjs
}
from
'@mui/x-date-pickers/AdapterDayjs'
;
import
{
DateTimePicker
}
from
'@mui/x-date-pickers/DateTimePicker'
;
import
{
useState
,
useEffect
}
from
"react"
;
import
dayjs
from
'dayjs'
;
import
{
AdapterMoment
}
from
"@mui/x-date-pickers/AdapterMoment"
;
export
default
function
MaterialUIPickers
(
props
)
{
console
.
log
(
props
)
if
(
props
.
task
.
dateTimeStart
!==
undefined
)
return
(
<
LocalizationProvider
dateAdapter
=
{
AdapterMoment
}
>
<
DateTimePicker
renderInput
=
{(
params
)
=>
(
<
TextField
{...
params
}
name
=
"dateCreated"
/>
)}
value
=
{
props
.
newStartedDate
&&
props
.
newStartedDate
.
id
===
props
.
task
.
id
?
props
.
newStartedDate
.
date
:
props
.
task
.
dateTimeStart
}
onChange
=
{(
newValue
)
=>
{
props
.
setNewStartedDate
({
id
:
props
.
task
.
id
,
date
:
newValue
,
});
}}
/
>
<
/LocalizationProvider
>
);
else
if
(
props
.
task
.
dateTimeDue
!==
undefined
)
{
return
(
<
LocalizationProvider
dateAdapter
=
{
AdapterMoment
}
>
<
DateTimePicker
renderInput
=
{(
params
)
=>
(
<
TextField
{...
params
}
name
=
"dateCreated"
/>
)}
value
=
{
props
.
newDueDate
&&
props
.
newDueDate
.
id
===
props
.
task
.
id
?
props
.
newDueDate
.
date
:
props
.
task
.
dateTimeDue
}
onChange
=
{(
newValue
)
=>
{
props
.
setNewDueDate
({
id
:
props
.
task
.
id
,
date
:
newValue
,
});
}}
/
>
<
/LocalizationProvider
>
);
}
}
\ No newline at end of file
planner-front/src/components/UI/Select/Select.js
0 → 100644
View file @
354ab632
import
*
as
React
from
"react"
;
import
Box
from
"@mui/material/Box"
;
import
InputLabel
from
"@mui/material/InputLabel"
;
import
MenuItem
from
"@mui/material/MenuItem"
;
import
FormControl
from
"@mui/material/FormControl"
;
import
Select
from
"@mui/material/Select"
;
export
default
function
BasicSelect
(
props
)
{
return
(
<
Box
sx
=
{{
minWidth
:
60
}}
>
<
FormControl
fullWidth
>
<
InputLabel
id
=
"demo-simple-select-label"
><
/InputLabel
>
<
Select
labelId
=
"demo-simple-select-label"
id
=
"demo-simple-select"
value
=
{
props
.
task
.
accomplish
}
label
=
""
name
=
{
"accomplish"
}
onChange
=
{(
e
)
=>
props
.
onChange
(
e
,
props
.
task
)}
sx
=
{{
marginTop
:
2
}}
>
{
props
.
items
.
map
((
item
)
=>
(
<
MenuItem
value
=
{
item
}
>
{
item
}
<
/MenuItem
>
))}
<
/Select
>
<
/FormControl
>
<
/Box
>
);
}
planner-front/src/containers/MyTasks/MyTasks.js
View file @
354ab632
...
...
@@ -3,29 +3,27 @@ import {
Box
,
Table
,
TableBody
,
TextField
,
TableCell
,
TableContainer
,
TablePagination
,
TableRow
,
Typography
,
Paper
,
IconButton
,
Tooltip
,
Input
,
}
from
"@mui/material"
;
import
{
useState
,
useEffect
}
from
"react"
;
import
{
Done
,
Edit
}
from
"@mui/icons-material"
;
import
{
useDispatch
,
useSelector
}
from
"react-redux"
;
import
{
Done
,
Edit
,
NavigateNextOutlined
}
from
"@mui/icons-material"
;
import
DeleteIcon
from
"@mui/icons-material/Delete"
;
import
TaskModal
from
"../../components/MyTasksCompoments/TaskModal/TaskModal"
;
import
EnhancedTableHead
from
"./MyTasksHeader/MyTasksHeader"
;
import
{
Container
}
from
"@mui/system"
;
import
{
DateTimePicker
,
LocalizationProvider
}
from
"@mui/x-date-pickers"
;
import
{
AdapterMoment
}
from
"@mui/x-date-pickers/AdapterMoment"
;
import
moment
from
"moment"
;
import
MyTaskToolBar
from
'../../components/MyTasksCompoments/MyTaskToolBar'
;
import
MyTaskToolBar
from
"../../components/MyTasksCompoments/MyTaskToolBar"
;
import
CustomTableCell
from
"../../components/MyTasksCompoments/CustomTableCell"
;
import
MaterialUIPickers
from
"../../components/UI/DateTimePicker/DateTimePicker"
;
import
MaterialUIPickers
from
"../../components/MyTasksCompoments/DateTimePicker/DateTimePicker"
;
import
BasicSelect
from
"../../components/UI/Select/Select"
;
import
{
fetchAllTasks
,
deleteTask
,
editTask
,
addTask
}
from
"../../store/actions/tasksActions"
;
function
descendingComparator
(
a
,
b
,
orderBy
)
{
if
(
b
[
orderBy
]
<
a
[
orderBy
])
{
...
...
@@ -38,14 +36,13 @@ function descendingComparator(a, b, orderBy) {
}
function
getComparator
(
order
,
orderBy
)
{
return
order
===
'desc'
return
order
===
"desc"
?
(
a
,
b
)
=>
descendingComparator
(
a
,
b
,
orderBy
)
:
(
a
,
b
)
=>
-
descendingComparator
(
a
,
b
,
orderBy
);
}
function
stableSort
(
array
,
comparator
)
{
const
stabilizedThis
=
array
.
map
((
el
,
index
)
=>
[
el
,
index
]);
const
stabilizedThis
=
array
?
.
map
((
el
,
index
)
=>
[
el
,
index
]);
stabilizedThis
.
sort
((
a
,
b
)
=>
{
const
order
=
comparator
(
a
[
0
],
b
[
0
]);
if
(
order
!==
0
)
{
...
...
@@ -56,297 +53,310 @@ function stableSort(array, comparator) {
return
stabilizedThis
.
map
((
el
)
=>
el
[
0
]);
}
export
default
function
EnhancedTable
()
{
const
dispatch
=
useDispatch
();
const
[
order
,
setOrder
]
=
React
.
useState
(
'asc'
);
const
[
orderBy
,
setOrderBy
]
=
React
.
useState
(
'id'
);
const
[
page
,
setPage
]
=
React
.
useState
(
0
);
const
[
rowsPerPage
,
setRowsPerPage
]
=
React
.
useState
(
5
);
const
[
newStartedDate
,
setNewStartedDate
]
=
React
.
useState
();
const
[
newDueDate
,
setNewDueDate
]
=
React
.
useState
();
useEffect
(()
=>
{
dispatch
(
fetchAllTasks
());
},
[]);
const
handleChange
=
(
id
,
newDate
)
=>
{
setNewStartedDate
({
id
:
id
,
date
:
newDate
});
const
tasks
=
useSelector
((
state
)
=>
state
.
tasks
.
tasks
);
console
.
log
(
tasks
)
const
[
recievedTasks
,
setRecievedTasks
]
=
useState
([]);
const
[
order
,
setOrder
]
=
React
.
useState
(
"asc"
);
const
[
orderBy
,
setOrderBy
]
=
React
.
useState
(
"id"
);
const
[
page
,
setPage
]
=
React
.
useState
(
0
);
const
[
rowsPerPage
,
setRowsPerPage
]
=
React
.
useState
(
5
);
const
handleRequestSort
=
(
event
,
property
)
=>
{
const
isAsc
=
orderBy
===
property
&&
order
===
"asc"
;
setOrder
(
isAsc
?
"desc"
:
"asc"
);
setOrderBy
(
property
);
};
const
[
tasks
,
setTasks
]
=
useState
([
{
user
:
"first"
,
title
:
"задача1"
,
description
:
"описание задачи11111"
,
priority
:
"A"
,
author
:
"Ivan"
,
executor
:
"Arman"
,
dateTimeStart
:
"2022-10-26T11:00:00"
,
dateTimeDue
:
"2022-10-27T10:30:00"
,
id
:
1
,
dateCreated
:
"26.10.2022"
},
{
user
:
"second"
,
title
:
"задача2"
,
description
:
"описание задачи222222"
,
author
:
"Ivan"
,
executor
:
"Elena"
,
priority
:
"B"
,
dateTimeStart
:
"2022-10-26T13:30:00"
,
dateTimeDue
:
"2022-10-27T12:30:00"
,
id
:
2
,
dateCreated
:
"26.10.2022"
},
{
user
:
"theird"
,
title
:
"задача3"
,
description
:
"описание задачи333333bjh,khkuhlhvilv hmgjtycikg mkgyxxkjfkkmgyhkfrdtseygdtjtuliuo8plfyvguh,bb"
,
author
:
"Artem"
,
executor
:
"Bota"
,
priority
:
"B"
,
dateTimeStart
:
"2022-10-30T09:30:00"
,
dateTimeDue
:
"2022-11-02T09:30:00"
,
id
:
3
,
dateCreated
:
"27.10.2022"
,
const
handleChangePage
=
(
event
,
newPage
)
=>
{
setPage
(
newPage
);
};
}
])
const
handleChangeRowsPerPage
=
(
event
)
=>
{
setRowsPerPage
(
parseInt
(
event
.
target
.
value
,
10
));
setPage
(
0
);
};
useEffect
(()
=>
{
if
(
newStartedDate
)
{
let
updatedTasks
=
[...
tasks
].
filter
((
t
)
=>
t
.
id
!==
newStartedDate
.
id
);
const
currentTask
=
tasks
.
find
((
t
)
=>
t
.
id
===
newStartedDate
.
id
);
delete
currentTask
.
dateTimeStart
;
console
.
log
(
newStartedDate
.
date
)
const
updatedTask
=
{
...
currentTask
,
dateTimeStart
:
moment
.
parseZone
(
newStartedDate
.
date
,
'DD/MM/YYYY'
,
true
).
format
()
};
updatedTasks
.
push
(
updatedTask
);
setTasks
(
updatedTasks
);
}
else
if
(
newDueDate
){
let
updatedTasks
=
[...
tasks
].
filter
((
t
)
=>
t
.
id
!==
newDueDate
.
id
);
const
currentTask
=
tasks
.
find
((
t
)
=>
t
.
id
===
newDueDate
.
id
);
delete
currentTask
.
dateTimeDue
;
console
.
log
(
newDueDate
.
date
)
const
updatedTask
=
{
...
currentTask
,
dateTimeDue
:
moment
.
parseZone
(
newDueDate
.
date
,
'DD/MM/YYYY'
,
true
).
format
()
};
updatedTasks
.
push
(
updatedTask
);
setTasks
(
updatedTasks
);
}
},
[
newStartedDate
||
newDueDate
]);
const
onToggleEditMode
=
id
=>
{
setTasks
(
state
=>
{
return
tasks
.
map
(
task
=>
{
if
(
task
.
id
===
id
)
{
return
{
...
task
,
isEditMode
:
!
task
.
isEditMode
};
}
return
task
;
if
(
tasks
&&
tasks
?.
length
>
0
)
{
let
currentTasks
=
[];
currentTasks
=
tasks
?.
map
((
task
)
=>
{
return
{
...
task
,
isEditMode
:
false
,
readOnly
:
true
,
authorDisplayName
:
task
.
author
.
displayName
,
};
});
});
};
setRecievedTasks
(
currentTasks
);
}
},
[
tasks
]);
const
onChange
=
(
e
,
task
)
=>
{
const
value
=
e
.
target
.
value
;
const
name
=
e
.
target
.
name
;
const
{
id
}
=
task
;
const
newTasks
=
tasks
.
map
(
task
=>
{
const
newTasks
=
recievedTasks
.
map
((
task
)
=>
{
if
(
task
.
id
===
id
)
{
return
{
...
task
,
[
name
]:
value
};
}
return
task
;
});
setTasks
(
newTasks
);
setRecievedTasks
(
newTasks
);
};
const
handleRequestSort
=
(
event
,
property
)
=>
{
const
isAsc
=
orderBy
===
property
&&
order
===
'asc'
;
setOrder
(
isAsc
?
'desc'
:
'asc'
);
setOrderBy
(
property
);
const
onAuthorChange
=
(
e
,
task
)
=>
{
const
value
=
e
.
target
.
value
;
const
{
id
}
=
task
;
const
newTasks
=
recievedTasks
.
map
((
task
)
=>
{
if
(
task
.
id
===
id
)
{
const
updated
=
{
...
task
};
updated
.
author
.
displayName
=
value
;
updated
.
authorDisplayName
=
value
;
return
updated
;
}
return
task
;
});
setRecievedTasks
(
newTasks
);
};
const
deleteTask
=
(
id
)
=>
{
console
.
log
(
id
)
let
newTasks
=
[...
tasks
]
newTasks
.
splice
(
tasks
[
id
],
1
)
setTasks
(
newTasks
)
const
onDateChange
=
(
id
,
value
,
property
)
=>
{
const
newTasks
=
recievedTasks
.
map
((
task
)
=>
{
if
(
task
.
id
===
id
)
{
return
{
...
task
,
[
property
]:
moment
.
parseZone
(
value
,
"DD/MM/YYYY"
,
true
).
format
(),
};
}
return
task
;
});
setRecievedTasks
(
newTasks
);
};
const
handleChangePage
=
(
event
,
newPage
)
=>
{
setPage
(
newPage
);
const
onToggleEditMode
=
(
id
)
=>
{
const
newTasks
=
recievedTasks
.
map
((
task
)
=>
{
if
(
task
.
id
===
id
)
{
return
{
...
task
,
isEditMode
:
true
,
readOnly
:
false
,
};
}
return
task
;
});
setRecievedTasks
(
newTasks
);
};
const
handleChangeRowsPerPage
=
(
event
)
=>
{
setRowsPerPage
(
parseInt
(
event
.
target
.
value
,
10
));
setPage
(
0
);
const
HandleEditTask
=
(
task
)
=>
{
dispatch
(
editTask
(
task
))
}
const
addTask
=
()
=>
{
// let newTasks=[...tasks]
tasks
.
unshift
({
title
:
""
,
description
:
""
,
priority
:
""
,
author
:
""
,
executor
:
""
,
dateTimeStart
:
""
,
dateTimeDue
:
""
,
id
:
4
,
createdAt
:
""
,
accomplish
:
" "
,
});
// tasks=newTasks;
};
const
[
modal
,
setModal
]
=
useState
({
const
deleteHandle
=
(
id
)
=>
{
dispatch
(
deleteTask
(
id
));
};
const
[
modal
,
setModal
]
=
useState
({
open
:
false
,
task
:
null
task
:
null
,
});
const
onModalOpen
=
(
event
,
task
)
=>
{
event
.
stopPropagation
();
setModal
({
...
modal
,
open
:
true
,
task
});
setModal
({
...
modal
,
open
:
true
,
id
:
task
.
id
});
};
const
handleClose
=
()
=>
{
setModal
({
...
modal
,
open
:
false
,
task
:
null
});
};
const
addTask
=
()
=>
{
let
newTasks
=
[...
tasks
]
newTasks
.
unshift
(
{
user
:
""
,
title
:
""
,
description
:
""
,
priority
:
""
,
author
:
""
,
executor
:
""
,
dateTimeStart
:
""
,
dateTimeDue
:
""
,
id
:
4
,
dateCreated
:
""
}
)
setTasks
(
newTasks
)
setModal
({
...
modal
,
open
:
false
,
id
:
null
});
};
return
(
<
Box
sx
=
{{
width
:
'fullwidth'
}}
>
<
Paper
sx
=
{{
width
:
'100%'
,
mb
:
2
}}
>
<
MyTaskToolBar
onClick
=
{()
=>
{
addTask
()}}
/
>
<
TableContainer
>
<
Table
sx
=
{{
minWidth
:
600
}}
aria
-
labelledby
=
"tableTitle"
>
<
EnhancedTableHead
order
=
{
order
}
orderBy
=
{
orderBy
}
onRequestSort
=
{
handleRequestSort
}
rowCount
=
{
tasks
.
length
}
/
>
<
TableBody
>
{
stableSort
(
tasks
,
getComparator
(
order
,
orderBy
))
.
slice
(
page
*
rowsPerPage
,
page
*
rowsPerPage
+
rowsPerPage
)
.
map
((
task
,
index
)
=>
{
return
(
<
TableRow
hover
key
=
{
task
.
id
}
>
<
TableCell
component
=
"th"
scope
=
"row"
padding
=
"none"
><
/TableCell>
<
CustomTableCell
{...{
task
,
name
:
"priority"
,
onChange
}}
/
>
<
CustomTableCell
{...{
task
,
name
:
"dateCreated"
,
onChange
}}
/
>
<
CustomTableCell
{...{
task
,
name
:
"title"
,
onChange
,
onModalOpen
}}
/
>
<
CustomTableCell
{...{
task
,
name
:
"author"
,
onChange
}}
/
>
{
task
.
isEditMode
?
(
<
TableCell
key
=
{
task
.
id
}
>
if
(
tasks
&&
tasks
?.
length
>
0
&&
recievedTasks
&&
recievedTasks
?.
length
>
0
)
{
return
(
<
Box
sx
=
{{
width
:
"fullwidth"
}}
>
<
Paper
sx
=
{{
width
:
"100%"
,
mb
:
2
}}
>
<
MyTaskToolBar
onClick
=
{()
=>
{
addTask
();
}}
/
>
<
TableContainer
>
<
Table
sx
=
{{
minWidth
:
600
}}
aria
-
labelledby
=
"tableTitle"
>
<
EnhancedTableHead
order
=
{
order
}
orderBy
=
{
orderBy
}
onRequestSort
=
{
handleRequestSort
}
rowCount
=
{
tasks
.
length
}
/
>
<
TableBody
>
<
TableRow
sx
=
{{
height
:
'1px'
,
margin
:
0
,
padding
:
0
}}
>
<
TableCell
align
=
"left"
>
<
Input
sx
=
{{
height
:
'1px'
,
margin
:
0
,
padding
:
0
}}
value
=
{
''
}
name
=
"order"
/>
<
/TableCell
>
<
TableCell
align
=
"left"
>
<
Input
sx
=
{{
height
:
'1px'
,
margin
:
0
,
padding
:
0
}}
value
=
{
''
}
name
=
"orderBy"
/>
<
/TableCell
>
<
/TableRow
>
{
stableSort
(
recievedTasks
,
getComparator
(
order
,
orderBy
))
.
slice
(
page
*
rowsPerPage
,
page
*
rowsPerPage
+
rowsPerPage
)
.
map
((
task
,
index
)
=>
{
return
(
<
TableRow
hover
key
=
{
task
.
id
}
>
<
TableCell
component
=
"th"
scope
=
"row"
padding
=
"none"
><
/TableCell
>
<
CustomTableCell
{...{
task
,
name
:
"priority"
,
value
:
task
.
priority
,
onChange
,
}}
/
>
<
CustomTableCell
{...{
task
,
name
:
"createdAt"
,
value
:
task
.
createdAt
,
}}
/
>
<
CustomTableCell
{...{
task
,
name
:
"title"
,
value
:
task
.
title
,
onChange
,
onModalOpen
,
}}
/
>
<
CustomTableCell
{...{
task
,
name
:
"author"
,
value
:
task
.
author
.
displayName
,
onChange
:
onAuthorChange
,
}}
/
>
<
TableCell
>
<
MaterialUIPickers
newStartedDate
=
{
newStartedDate
}
task
=
{
task
}
setNewStartedDate
=
{
setNewStartedDat
e
}
task
=
{
task
}
name
=
"dateTimeStart"
onChange
=
{
onDateChang
e
}
/
>
<
/TableCell>
)
:
<
CustomTableCell
{...{
task
,
name
:
"dateTimeStart"
,
onChange
}}
/
>
}
{
task
.
isEditMode
?
(
<
TableCell
key
=
{
task
.
id
}
>
<
MaterialUIPickers
newDueDate
=
{
newDueDate
}
<
/TableCell
>
<
TableCell
>
<
MaterialUIPickers
task
=
{
task
}
setNewDueDate
=
{
setNewDueDate
}
/
>
<
/TableCell>
)
:
<
CustomTableCell
{...{
task
,
name
:
"dateTimeDue"
,
onChange
}}
/
>
}
<
CustomTableCell
{...{
task
,
name
:
"done"
,
onChange
}}
/>
<
TableCell
>
{
task
.
isEditMode
?
(
<
IconButton
aria
-
label
=
"done"
onClick
=
{()
=>
onToggleEditMode
(
task
.
id
)}
>
<
Done
/>
<
/IconButton
>
)
:
(
<
IconButton
aria
-
label
=
"delete"
onClick
=
{()
=>
onToggleEditMode
(
task
.
id
)}
>
<
Edit
/>
<
/IconButton
>
)}
<
/TableCell
>
<
TableCell
>
<
Tooltip
title
=
"Delete"
>
<
IconButton
onClick
=
{(
id
)
=>
{
deleteTask
(
id
)}}
>
<
DeleteIcon
/>
<
/IconButton
>
<
/Tooltip
>
<
/TableCell
>
<
/TableRow
>
);
})}
<
/TableBody
>
<
/Table
>
<
/TableContainer
>
<
TablePagination
rowsPerPageOptions
=
{[
5
,
10
,
25
]}
component
=
"div"
count
=
{
tasks
.
length
}
rowsPerPage
=
{
rowsPerPage
}
page
=
{
page
}
onPageChange
=
{
handleChangePage
}
onRowsPerPageChange
=
{
handleChangeRowsPerPage
}
/
>
<
/Paper
>
name
=
"dateTimeDue"
onChange
=
{
onDateChange
}
/
>
<
/TableCell
>
{
task
.
isEditMode
?
(
<
BasicSelect
items
=
{[
"opened"
,
"done"
,
"failed"
]}
task
=
{
task
}
onChange
=
{
onChange
}
/
>
)
:
(
<
CustomTableCell
{...{
task
,
name
:
"accomplish"
,
value
:
task
.
accomplish
,
}}
/
>
)}
<
TableCell
>
{
task
.
isEditMode
?
(
<
IconButton
aria
-
label
=
"done"
onClick
=
{()
=>
{
onToggleEditMode
(
task
.
id
);
HandleEditTask
(
task
)
}}
>
<
Done
/>
<
/IconButton
>
)
:
(
<
IconButton
aria
-
label
=
"edit"
onClick
=
{()
=>
onToggleEditMode
(
task
.
id
)}
>
<
Edit
/>
<
/IconButton
>
)}
<
/TableCell
>
<
TableCell
>
<
Tooltip
title
=
"Delete"
>
<
IconButton
onClick
=
{(
id
)
=>
{
deleteHandle
(
task
.
id
);
}}
>
<
DeleteIcon
/>
<
/IconButton
>
<
/Tooltip
>
<
/TableCell
>
<
/TableRow
>
);
})}
<
/TableBody
>
<
/Table
>
<
/TableContainer
>
<
TablePagination
rowsPerPageOptions
=
{[
5
,
10
,
25
]}
component
=
"div"
count
=
{
tasks
.
length
}
rowsPerPage
=
{
rowsPerPage
}
page
=
{
page
}
onPageChange
=
{
handleChangePage
}
onRowsPerPageChange
=
{
handleChangeRowsPerPage
}
/
>
<
/Paper
>
<
TaskModal
task
=
{
modal
.
task
}
task
=
{
recievedTasks
.
find
((
task
)
=>
task
.
id
===
modal
.
id
)
}
open
=
{
modal
.
open
}
handleClose
=
{
handleClose
}
onChange
=
{(
e
)
=>
{
onChange
(
e
,
modal
.
task
)}}
onToggleEditMode
=
{
onToggleEditMode
}
tasks
=
{
tasks
}
setTasks
=
{
setTasks
}
/>
<
/Box
>
);
onChange
=
{
onChange
}
/
>
<
/Box
>
);
}
}
planner-front/src/containers/MyTasks/MyTasksHeader/MyTasksHeader.js
View file @
354ab632
...
...
@@ -22,41 +22,41 @@ const headCells = [
label
:
'Приоритет'
,
},
{
id
:
'
date
'
,
id
:
'
createdAt
'
,
numeric
:
true
,
disablePadding
:
false
,
label
:
'Дата'
,
label
:
'Дата
создания
'
,
},
{
id
:
't
ask
'
,
id
:
't
itle
'
,
numeric
:
true
,
disablePadding
:
false
,
label
:
'За
дача
'
,
label
:
'За
головок
'
,
},
{
id
:
'author'
,
id
:
'author
DisplayName
'
,
numeric
:
true
,
disablePadding
:
false
,
label
:
'Автор'
,
},
{
id
:
'
startDate
'
,
id
:
'
dateTimeStart
'
,
numeric
:
true
,
disablePadding
:
false
,
label
:
'Дата начала'
,
},
{
id
:
'
endDat
e'
,
id
:
'
dateTimeDu
e'
,
numeric
:
true
,
disablePadding
:
false
,
label
:
'Дата завершения'
,
},
{
id
:
'
done
'
,
id
:
'
accomplish
'
,
numeric
:
true
,
disablePadding
:
false
,
label
:
'
Выполнено
'
,
label
:
'
Статус
'
,
},
{
id
:
'change'
,
...
...
@@ -115,4 +115,3 @@ EnhancedTableHead.propTypes = {
orderBy
:
PropTypes
.
string
.
isRequired
,
rowCount
:
PropTypes
.
number
.
isRequired
,
};
planner-front/src/store/actionTypes/tasksTypes.js
View file @
354ab632
...
...
@@ -2,6 +2,8 @@ export const FETCH_CALENDAR_TASKS_REQUEST = "FETCH_CALENDAR_TASKS_REQUEST";
export
const
FETCH_CALENDAR_TASKS_SUCCESS
=
"FETCH_CALENDAR_TASKS_SUCCESS"
;
export
const
FETCH_CALENDAR_TASKS_FAILURE
=
"FETCH_CALENDAR_TASKS_FAILURE"
;
export
const
FETCH_ALL_TASKS_SUCCESS
=
"FETCH_ALL_TASKS_SUCCESS"
;
export
const
ADD_NEW_TASK_REQUEST
=
"ADD_NEW_TASK_REQUEST"
;
export
const
ADD_NEW_TASK_SUCCESS
=
"ADD_NEW_TASK_SUCCESS"
;
export
const
ADD_NEW_TASK_FAILURE
=
"ADD_NEW_TASK_FAILURE"
;
...
...
planner-front/src/store/actions/tasksActions.js
View file @
354ab632
...
...
@@ -10,7 +10,8 @@ import {
EDIT_TASK_SUCCESS
,
FETCH_CALENDAR_TASKS_FAILURE
,
FETCH_CALENDAR_TASKS_REQUEST
,
FETCH_CALENDAR_TASKS_SUCCESS
}
from
"../actionTypes/tasksTypes"
;
FETCH_CALENDAR_TASKS_SUCCESS
,
FETCH_ALL_TASKS_SUCCESS
}
from
"../actionTypes/tasksTypes"
;
import
axios
from
'../../axiosPlanner'
const
fetchCalendarTasksRequest
=
()
=>
{
...
...
@@ -21,6 +22,11 @@ const fetchCalendarTasksSuccess = (tasks) => {
return
{
type
:
FETCH_CALENDAR_TASKS_SUCCESS
,
tasks
}
};
const
fetchAllTasksSuccess
=
(
tasks
)
=>
{
return
{
type
:
FETCH_ALL_TASKS_SUCCESS
,
tasks
}
};
const
fetchCalendarTasksFailure
=
(
error
)
=>
{
return
{
type
:
FETCH_CALENDAR_TASKS_FAILURE
,
error
}
};
...
...
@@ -35,8 +41,18 @@ export const fetchCalendarTasks = () => {
dispatch
(
fetchCalendarTasksFailure
(
error
.
response
.
data
));
}
}
}
};
export
const
fetchAllTasks
=
()
=>
{
return
async
(
dispatch
)
=>
{
dispatch
(
fetchCalendarTasksRequest
());
try
{
const
response
=
await
axios
.
get
(
"/tasks"
);
dispatch
(
fetchAllTasksSuccess
(
response
.
data
.
tasks
))
}
catch
(
error
)
{
dispatch
(
fetchCalendarTasksFailure
(
error
.
response
.
data
));
}
}
};
const
addTaskRequest
=
()
=>
{
return
{
type
:
ADD_NEW_TASK_REQUEST
}
};
...
...
@@ -84,12 +100,15 @@ export const editTask = (task) => {
dispatch
(
editTaskRequest
());
const
token
=
getState
().
users
?.
user
?.
token
;
try
{
await
axios
.
put
(
"/tasks"
,
task
,
{
console
.
log
(
task
)
const
r
=
await
axios
.
put
(
"/tasks"
,
task
,
{
headers
:
{
'Authorization'
:
'IwGVRaksGTWtnKlOZd7zJ'
}
});
console
.
log
(
r
)
dispatch
(
editTaskSuccess
())
dispatch
(
fetchAllTasks
())
dispatch
(
fetchCalendarTasks
())
}
catch
(
error
)
{
dispatch
(
editTaskFailure
(
error
.
response
.
data
));
...
...
@@ -100,7 +119,7 @@ export const editTask = (task) => {
const
deleteTaskRequest
=
()
=>
{
return
{
type
:
DELETE_TASK_REQUEST
}
};
const
deleteTaskSuccess
=
()
=>
{
return
{
type
:
DELETE_TASK_SUCCESS
}
};
...
...
@@ -121,6 +140,7 @@ export const deleteTask = (taskId) => {
});
dispatch
(
deleteTaskSuccess
())
dispatch
(
fetchCalendarTasks
())
dispatch
(
fetchAllTasks
())
}
catch
(
error
)
{
dispatch
(
deleteTaskFailure
(
error
.
response
.
data
));
}
...
...
planner-front/src/store/reducers/tasksReducer.js
View file @
354ab632
...
...
@@ -10,7 +10,8 @@ import {
FETCH_CALENDAR_TASKS_SUCCESS
,
DELETE_TASK_SUCCESS
,
DELETE_TASK_REQUEST
,
DELETE_TASK_FAILURE
}
from
"../actionTypes/tasksTypes"
;
DELETE_TASK_FAILURE
,
FETCH_ALL_TASKS_SUCCESS
}
from
"../actionTypes/tasksTypes"
;
const
initialState
=
{
calendarTasks
:
[],
...
...
@@ -24,7 +25,7 @@ const tasksReduсer = (state = initialState, action) => {
return
{...
state
,
loading
:
true
};
case
FETCH_CALENDAR_TASKS_SUCCESS
:
const
newArr
=
[]
action
.
tasks
.
forEach
((
task
)
=>
{
action
.
tasks
.
forEach
((
task
)
=>
{
if
(
task
.
dateTimeStart
&&
task
.
dateTimeDue
)
{
if
(
new
Date
(
task
.
dateTimeDue
).
getTime
()
-
new
Date
(
task
.
dateTimeStart
).
getTime
()
<
(
10
*
3600000
))
{
const
dateStart
=
task
.
dateTimeStart
.
split
(
'T'
)[
0
]
...
...
@@ -51,6 +52,8 @@ const tasksReduсer = (state = initialState, action) => {
}
})
return
{...
state
,
loading
:
false
,
calendarTasks
:
newArr
};
case
FETCH_ALL_TASKS_SUCCESS
:
return
{...
state
,
loading
:
false
,
tasks
:
action
.
tasks
};
case
FETCH_CALENDAR_TASKS_FAILURE
:
return
{...
state
,
loading
:
false
,
error
:
action
.
error
};
case
ADD_NEW_TASK_SUCCESS
:
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment