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
083aa63c
Commit
083aa63c
authored
Nov 11, 2022
by
Ermolaev Timur
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
#30
Реализовал удаление задачи, изменил название переменных
parent
50297f52
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
108 additions
and
40 deletions
+108
-40
Task.ts
planner-api/src/models/Task.ts
+4
-3
MonthCalendarBody.js
...ont/src/components/MonthCalendarBody/MonthCalendarBody.js
+3
-2
MonthCalendarModalContent.js
...ts/MonthCalendarModalContent/MonthCalendarModalContent.js
+3
-3
MonthCalendar.js
planner-front/src/containers/MonthCalendar/MonthCalendar.js
+11
-9
tasksTypes.js
planner-front/src/store/actionTypes/tasksTypes.js
+8
-4
tasksActions.js
planner-front/src/store/actions/tasksActions.js
+55
-13
tasksReducer.js
planner-front/src/store/reducers/tasksReducer.js
+24
-6
No files found.
planner-api/src/models/Task.ts
View file @
083aa63c
...
...
@@ -22,7 +22,7 @@ import {
dateTimeStart
:
Date
|
null
;
dateTimeDue
:
Date
|
null
;
accomplish
:
taskFinishType
;
priority
:
priorityType
;
priority
:
priorityType
|
null
;
author
:
User
;
project
:
Project
|
null
;
executors
:
User
[]
...
...
@@ -54,9 +54,10 @@ import {
@
Column
({
type
:
"enum"
,
enum
:
[
"A"
,
"B"
,
"C"
],
default
:
"C"
default
:
"C"
,
nullable
:
true
})
priority
!
:
priorityType
priority
!
:
priorityType
|
null
;
...
...
planner-front/src/components/MonthCalendarBody/MonthCalendarBody.js
View file @
083aa63c
...
...
@@ -7,7 +7,7 @@ import CalendarTask from "./CalendarTask/CalendarTask";
import
ModalTask
from
"../UI/ModalTask/ModalTask"
;
import
MonthCalendarModalContent
from
"../MonthCalendarModalContent/MonthCalendarModalContent"
;
function
MonthCalendarBody
({
month
,
year
,
tasks
,
createTaskInCellHandler
,
currentTask
,
setCurrentTask
,
hourFormat
,
setHourFormat
,
onChangeCurrentTaskHandler
,
sendNewTask
})
{
function
MonthCalendarBody
({
month
,
year
,
tasks
,
createTaskInCellHandler
,
currentTask
,
setCurrentTask
,
hourFormat
,
setHourFormat
,
onChangeCurrentTaskHandler
,
sendNewTask
Handler
,
deleteTaskHandler
})
{
const
[
hoursInDay
,
setHoursInDay
]
=
useState
([
'8:00'
,
'10:00'
,
'12:00'
,
'14:00'
,
'16:00'
,
'18:00'
,
'20:00'
,
'22:00'
])
const
[
daysInMonth
,
setDaysInMonth
]
=
useState
([])
...
...
@@ -147,7 +147,8 @@ function MonthCalendarBody({month, year, tasks, createTaskInCellHandler, current
description
=
{
currentTask
.
description
}
priority
=
{
currentTask
.
priority
}
onChangeCurrentTaskHandler
=
{(
e
)
=>
{
onChangeCurrentTaskHandler
(
e
)}}
sendNewTask
=
{()
=>
{
sendNewTask
();
handleClose
()}}
sendNewTaskHandler
=
{()
=>
{
sendNewTaskHandler
();
handleClose
()}}
deleteTaskHandler
=
{()
=>
{
deleteTaskHandler
(
currentTask
.
id
);
handleClose
()}}
/
>
<
/ModalTask
>
<
/
>
...
...
planner-front/src/components/MonthCalendarModalContent/MonthCalendarModalContent.js
View file @
083aa63c
import
{
Button
,
FormControl
,
InputLabel
,
MenuItem
,
Select
,
TextField
}
from
"@mui/material"
;
function
MonthCalendarModalContent
({
title
,
onChangeCurrentTaskHandler
,
description
,
priority
,
sendNewTask
})
{
function
MonthCalendarModalContent
({
title
,
onChangeCurrentTaskHandler
,
description
,
priority
,
sendNewTask
Handler
,
deleteTaskHandler
})
{
return
(
<>
<
TextField
id
=
"task-description-title"
...
...
@@ -41,8 +41,8 @@ function MonthCalendarModalContent({title, onChangeCurrentTaskHandler, descripti
<
MenuItem
value
=
{
"C"
}
>
C
<
/MenuItem
>
<
/Select
>
<
/FormControl
>
<
Button
sx
=
{{
marginRight
:
'40px'
}}
onClick
=
{
sendNewTask
}
>
Сохранить
<
/Button
>
<
Button
>
Удалить
<
/Button
>
<
Button
sx
=
{{
marginRight
:
'40px'
}}
onClick
=
{
sendNewTask
Handler
}
>
Сохранить
<
/Button
>
<
Button
onClick
=
{
deleteTaskHandler
}
>
Удалить
<
/Button
>
<
/>
)
;
}
...
...
planner-front/src/containers/MonthCalendar/MonthCalendar.js
View file @
083aa63c
import
{
Container
}
from
'@mui/material'
;
import
{
useEffect
,
useState
}
from
'react'
;
import
{
useDispatch
,
useSelector
}
from
'react-redux'
;
import
MonthCalendarBody
from
'../../components/MonthCalendarBody/MonthCalendarBody'
;
import
MonthCalendarHeader
from
'../../components/MonthCalendarHeader/MonthCalendarHeader'
;
import
{
addTask
,
editTask
,
fetch
Tasks
}
from
'../../store/actions/tasksActions'
;
import
{
addTask
,
deleteTask
,
editTask
,
fetchCalendar
Tasks
}
from
'../../store/actions/tasksActions'
;
function
MonthCalendar
()
{
const
dispatch
=
useDispatch
();
const
{
t
asks
}
=
useSelector
(
state
=>
state
.
tasks
);
const
{
calendarT
asks
}
=
useSelector
(
state
=>
state
.
tasks
);
const
[
hourFormat
,
setHourFormat
]
=
useState
(
false
);
const
[
month
,
setMonth
]
=
useState
(
''
)
...
...
@@ -18,7 +17,7 @@ function MonthCalendar() {
useEffect
(()
=>
{
setMonth
(
new
Date
().
getMonth
())
setYear
(
new
Date
().
getFullYear
())
dispatch
(
fetchTasks
())
dispatch
(
fetch
Calendar
Tasks
())
},
[
dispatch
])
const
onChangeWorkerHandler
=
(
event
)
=>
{
...
...
@@ -89,13 +88,12 @@ function MonthCalendar() {
setCurrentTask
((
newTask
))
}
const
sendNewTask
=
async
()
=>
{
const
sendNewTask
Handler
=
async
()
=>
{
if
(
currentTask
.
id
)
{
setCurrentTask
(()
=>
{
return
{
...
currentTask
,
priority
:
currentTask
.
priority
?
currentTask
.
priority
:
'C'
}}
)
delete
currentTask
.
infoForCell
...
...
@@ -104,7 +102,6 @@ function MonthCalendar() {
setCurrentTask
(()
=>
{
return
{
...
currentTask
,
priority
:
currentTask
.
priority
?
currentTask
.
priority
:
'C'
}}
)
delete
currentTask
.
infoForCell
...
...
@@ -112,6 +109,10 @@ function MonthCalendar() {
}
}
const
deleteTaskHandler
=
async
(
taskId
)
=>
{
dispatch
(
deleteTask
(
taskId
))
}
return
(
<>
<
MonthCalendarHeader
...
...
@@ -128,14 +129,15 @@ function MonthCalendar() {
<
MonthCalendarBody
month
=
{
month
}
year
=
{
year
}
tasks
=
{
t
asks
}
tasks
=
{
calendarT
asks
}
createTaskInCellHandler
=
{
createTaskInCellHandler
}
setCurrentTask
=
{
setCurrentTask
}
hourFormat
=
{
hourFormat
}
setHourFormat
=
{
setHourFormat
}
currentTask
=
{
currentTask
}
onChangeCurrentTaskHandler
=
{
onChangeCurrentTaskHandler
}
sendNewTask
=
{
sendNewTask
}
sendNewTaskHandler
=
{
sendNewTaskHandler
}
deleteTaskHandler
=
{
deleteTaskHandler
}
/
>
<
/
>
);
...
...
planner-front/src/store/actionTypes/tasksTypes.js
View file @
083aa63c
export
const
FETCH_
TASKS_REQUEST
=
"FETCH
_TASKS_REQUEST"
;
export
const
FETCH_
TASKS_SUCCESS
=
"FETCH
_TASKS_SUCCESS"
;
export
const
FETCH_
TASKS_FAILURE
=
"FETCH
_TASKS_FAILURE"
;
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
ADD_NEW_TASK_REQUEST
=
"ADD_NEW_TASK_REQUEST"
;
export
const
ADD_NEW_TASK_SUCCESS
=
"ADD_NEW_TASK_SUCCESS"
;
...
...
@@ -8,4 +8,8 @@ export const ADD_NEW_TASK_FAILURE = "ADD_NEW_TASK_FAILURE";
export
const
EDIT_TASK_REQUEST
=
"EDIT_TASK_REQUEST"
;
export
const
EDIT_TASK_SUCCESS
=
"EDIT_TASK_SUCCESS"
;
export
const
EDIT_TASK_FAILURE
=
"EDIT_TASK_FAILURE"
;
\ No newline at end of file
export
const
EDIT_TASK_FAILURE
=
"EDIT_TASK_FAILURE"
;
export
const
DELETE_TASK_REQUEST
=
"DELETE_TASK_REQUEST"
;
export
const
DELETE_TASK_SUCCESS
=
"DELETE_TASK_SUCCESS"
;
export
const
DELETE_TASK_FAILURE
=
"DELETE_TASK_FAILURE"
;
\ No newline at end of file
planner-front/src/store/actions/tasksActions.js
View file @
083aa63c
import
{
ADD_NEW_TASK_FAILURE
,
ADD_NEW_TASK_REQUEST
,
ADD_NEW_TASK_SUCCESS
,
EDIT_TASK_FAILURE
,
EDIT_TASK_REQUEST
,
EDIT_TASK_SUCCESS
,
FETCH_TASKS_FAILURE
,
FETCH_TASKS_REQUEST
,
FETCH_TASKS_SUCCESS
}
from
"../actionTypes/tasksTypes"
;
import
{
ADD_NEW_TASK_FAILURE
,
ADD_NEW_TASK_REQUEST
,
ADD_NEW_TASK_SUCCESS
,
DELETE_TASK_FAILURE
,
DELETE_TASK_REQUEST
,
DELETE_TASK_SUCCESS
,
EDIT_TASK_FAILURE
,
EDIT_TASK_REQUEST
,
EDIT_TASK_SUCCESS
,
FETCH_CALENDAR_TASKS_FAILURE
,
FETCH_CALENDAR_TASKS_REQUEST
,
FETCH_CALENDAR_TASKS_SUCCESS
}
from
"../actionTypes/tasksTypes"
;
import
axios
from
'../../axiosPlanner'
const
fetchTasksRequest
=
()
=>
{
return
{
type
:
FETCH
_TASKS_REQUEST
}
const
fetch
Calendar
TasksRequest
=
()
=>
{
return
{
type
:
FETCH_CALENDAR
_TASKS_REQUEST
}
};
const
fetchTasksSuccess
=
(
tasks
)
=>
{
return
{
type
:
FETCH_TASKS_SUCCESS
,
tasks
}
const
fetch
Calendar
TasksSuccess
=
(
tasks
)
=>
{
return
{
type
:
FETCH_
CALENDAR_
TASKS_SUCCESS
,
tasks
}
};
const
fetchTasksFailure
=
(
error
)
=>
{
return
{
type
:
FETCH_TASKS_FAILURE
,
error
}
const
fetch
Calendar
TasksFailure
=
(
error
)
=>
{
return
{
type
:
FETCH_
CALENDAR_
TASKS_FAILURE
,
error
}
};
export
const
fetchTasks
=
()
=>
{
export
const
fetch
Calendar
Tasks
=
()
=>
{
return
async
(
dispatch
)
=>
{
dispatch
(
fetchTasksRequest
());
dispatch
(
fetch
Calendar
TasksRequest
());
try
{
const
response
=
await
axios
.
get
(
"/tasks"
);
dispatch
(
fetchTasksSuccess
(
response
.
data
.
tasks
))
dispatch
(
fetch
Calendar
TasksSuccess
(
response
.
data
.
tasks
))
}
catch
(
error
)
{
dispatch
(
fetchTasksFailure
(
error
.
response
.
data
));
dispatch
(
fetch
Calendar
TasksFailure
(
error
.
response
.
data
));
}
}
}
...
...
@@ -48,7 +60,7 @@ export const addTask = (task) => {
}
});
dispatch
(
addTaskSuccess
())
dispatch
(
fetchTasks
())
dispatch
(
fetch
Calendar
Tasks
())
}
catch
(
error
)
{
dispatch
(
addTaskFailure
(
error
.
response
.
data
));
}
...
...
@@ -78,9 +90,39 @@ export const editTask = (task) => {
}
});
dispatch
(
editTaskSuccess
())
dispatch
(
fetchTasks
())
dispatch
(
fetch
Calendar
Tasks
())
}
catch
(
error
)
{
dispatch
(
editTaskFailure
(
error
.
response
.
data
));
}
}
}
const
deleteTaskRequest
=
()
=>
{
return
{
type
:
DELETE_TASK_REQUEST
}
};
const
deleteTaskSuccess
=
()
=>
{
return
{
type
:
DELETE_TASK_SUCCESS
}
};
const
deleteTaskFailure
=
(
error
)
=>
{
return
{
type
:
DELETE_TASK_FAILURE
,
error
}
};
export
const
deleteTask
=
(
taskId
)
=>
{
return
async
(
dispatch
,
getState
)
=>
{
dispatch
(
deleteTaskRequest
());
const
token
=
getState
().
users
?.
user
?.
token
;
try
{
await
axios
.
delete
(
`/tasks/
${
taskId
}
`
,
{
headers
:
{
'Authorization'
:
'IwGVRaksGTWtnKlOZd7zJ'
}
});
dispatch
(
deleteTaskSuccess
())
dispatch
(
fetchCalendarTasks
())
}
catch
(
error
)
{
dispatch
(
deleteTaskFailure
(
error
.
response
.
data
));
}
}
}
\ No newline at end of file
planner-front/src/store/reducers/tasksReducer.js
View file @
083aa63c
import
{
ADD_NEW_TASK_FAILURE
,
ADD_NEW_TASK_REQUEST
,
ADD_NEW_TASK_SUCCESS
,
EDIT_TASK_FAILURE
,
EDIT_TASK_REQUEST
,
EDIT_TASK_SUCCESS
,
FETCH_TASKS_FAILURE
,
FETCH_TASKS_REQUEST
,
FETCH_TASKS_SUCCESS
}
from
"../actionTypes/tasksTypes"
;
import
{
ADD_NEW_TASK_FAILURE
,
ADD_NEW_TASK_REQUEST
,
ADD_NEW_TASK_SUCCESS
,
EDIT_TASK_FAILURE
,
EDIT_TASK_REQUEST
,
EDIT_TASK_SUCCESS
,
FETCH_CALENDAR_TASKS_FAILURE
,
FETCH_CALENDAR_TASKS_REQUEST
,
FETCH_CALENDAR_TASKS_SUCCESS
,
DELETE_TASK_SUCCESS
,
DELETE_TASK_REQUEST
,
DELETE_TASK_FAILURE
}
from
"../actionTypes/tasksTypes"
;
const
initialState
=
{
t
asks
:
[],
calendarT
asks
:
[],
loading
:
false
,
error
:
null
,
};
const
tasksRedu
с
er
=
(
state
=
initialState
,
action
)
=>
{
switch
(
action
.
type
)
{
case
FETCH_TASKS_REQUEST
:
case
FETCH_
CALENDAR_
TASKS_REQUEST
:
return
{...
state
,
loading
:
true
};
case
FETCH_TASKS_SUCCESS
:
case
FETCH_
CALENDAR_
TASKS_SUCCESS
:
const
newArr
=
[]
action
.
tasks
.
forEach
((
task
)
=>
{
if
(
task
.
dateTimeStart
&&
task
.
dateTimeDue
)
{
...
...
@@ -38,8 +50,8 @@ const tasksReduсer = (state = initialState, action) => {
}
}
})
return
{...
state
,
loading
:
false
,
t
asks
:
newArr
};
case
FETCH_TASKS_FAILURE
:
return
{...
state
,
loading
:
false
,
calendarT
asks
:
newArr
};
case
FETCH_
CALENDAR_
TASKS_FAILURE
:
return
{...
state
,
loading
:
false
,
error
:
action
.
error
};
case
ADD_NEW_TASK_SUCCESS
:
return
{...
state
,
loading
:
false
};
...
...
@@ -53,6 +65,12 @@ const tasksReduсer = (state = initialState, action) => {
return
{...
state
,
loading
:
true
};
case
EDIT_TASK_FAILURE
:
return
{...
state
,
loading
:
false
,
error
:
action
.
error
};
case
DELETE_TASK_SUCCESS
:
return
{...
state
,
loading
:
false
};
case
DELETE_TASK_REQUEST
:
return
{...
state
,
loading
:
true
};
case
DELETE_TASK_FAILURE
:
return
{...
state
,
loading
:
false
,
error
:
action
.
error
};
default
:
return
state
;
}
...
...
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