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
638a5a3e
Commit
638a5a3e
authored
Nov 16, 2022
by
Евгений Положенцев
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'task-53-fix/put_task_repair' into 'development'
Task 53 fix/put task repair See merge request
!30
parents
71855735
80837de7
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
248 additions
and
37 deletions
+248
-37
tasks.ts
planner-api/src/routers/tasks.ts
+3
-1
users.ts
planner-api/src/routers/users.ts
+0
-5
NewTaskForm.js
...ner-front/src/components/MyTasksCompoments/NewTaskForm.js
+197
-0
MyTasks.js
planner-front/src/containers/MyTasks/MyTasks.js
+33
-5
index.js
planner-front/src/index.js
+9
-8
tasksActions.js
planner-front/src/store/actions/tasksActions.js
+6
-18
No files found.
planner-api/src/routers/tasks.ts
View file @
638a5a3e
...
@@ -80,6 +80,7 @@ router.delete('/:taskId',async (req: Request, res: Response):Promise<Response>=>
...
@@ -80,6 +80,7 @@ router.delete('/:taskId',async (req: Request, res: Response):Promise<Response>=>
router
.
put
(
'/'
,
async
(
req
:
Request
,
res
:
Response
)
=>
{
router
.
put
(
'/'
,
async
(
req
:
Request
,
res
:
Response
)
=>
{
const
token
=
req
.
get
(
'Authorization'
);
const
token
=
req
.
get
(
'Authorization'
);
const
user
=
await
dataSource
const
user
=
await
dataSource
.
createQueryBuilder
()
.
createQueryBuilder
()
.
select
(
"user"
)
.
select
(
"user"
)
...
@@ -94,6 +95,7 @@ router.put('/',async(req:Request, res:Response)=> {
...
@@ -94,6 +95,7 @@ router.put('/',async(req:Request, res:Response)=> {
.
from
(
Task
,
"task"
)
.
from
(
Task
,
"task"
)
.
where
(
"task.id = :id"
,
{
id
})
.
where
(
"task.id = :id"
,
{
id
})
.
getOne
()
.
getOne
()
if
(
!
task
)
return
res
.
status
(
404
).
send
({
Message
:
'task not found'
})
if
(
!
task
)
return
res
.
status
(
404
).
send
({
Message
:
'task not found'
})
task
.
title
=
title
task
.
title
=
title
task
.
description
=
description
task
.
description
=
description
...
...
planner-api/src/routers/users.ts
View file @
638a5a3e
...
@@ -35,9 +35,7 @@ return res.send({users})
...
@@ -35,9 +35,7 @@ return res.send({users})
router
.
post
(
'/'
,
upload
.
single
(
"avatar"
),
async
(
req
:
Request
,
res
:
Response
):
Promise
<
object
>
=>
{
router
.
post
(
'/'
,
upload
.
single
(
"avatar"
),
async
(
req
:
Request
,
res
:
Response
):
Promise
<
object
>
=>
{
console
.
log
(
req
.
body
)
const
{
name
,
surname
,
password
,
email
,
role
}
=
req
.
body
;
const
{
name
,
surname
,
password
,
email
,
role
}
=
req
.
body
;
console
.
log
(
req
.
body
)
const
displayName
=
surname
+
' '
+
name
[
0
]
+
'.'
const
displayName
=
surname
+
' '
+
name
[
0
]
+
'.'
const
user
=
new
User
();
const
user
=
new
User
();
user
.
name
=
name
;
user
.
name
=
name
;
...
@@ -47,13 +45,10 @@ router.post('/', upload.single("avatar"), async (req : Request, res : Response):
...
@@ -47,13 +45,10 @@ router.post('/', upload.single("avatar"), async (req : Request, res : Response):
user
.
email
=
email
;
user
.
email
=
email
;
user
.
role
=
role
;
user
.
role
=
role
;
user
.
generateToken
()
user
.
generateToken
()
console
.
log
(
"user "
+
user
)
await
user
.
save
();
await
user
.
save
();
console
.
log
(
"saved"
)
const
userToFront
:
User
|
null
=
await
dataSource
.
manager
.
findOneBy
(
User
,
{
const
userToFront
:
User
|
null
=
await
dataSource
.
manager
.
findOneBy
(
User
,
{
email
:
user
.
email
email
:
user
.
email
})
})
console
.
log
(
"userToFront "
+
userToFront
)
return
res
.
send
({
userToFront
})
return
res
.
send
({
userToFront
})
})
})
...
...
planner-front/src/components/MyTasksCompoments/NewTaskForm.js
0 → 100644
View file @
638a5a3e
import
*
as
React
from
"react"
;
import
{
Box
,
Table
,
TableBody
,
TableCell
,
TableContainer
,
TableRow
,
Paper
,
IconButton
,
Tooltip
,
Input
,
}
from
"@mui/material"
;
import
{
useState
,
useEffect
}
from
"react"
;
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
moment
from
"moment"
;
import
CustomTableCell
from
"../../components/MyTasksCompoments/CustomTableCell"
;
import
MaterialUIPickers
from
"../../components/MyTasksCompoments/DateTimePicker/DateTimePicker"
;
import
BasicSelect
from
"../../components/UI/Select/Select"
;
import
{
fetchAllTasks
,
deleteTask
,
editTask
,
addTask
}
from
"../../store/actions/tasksActions"
;
export
default
function
NewTaskForm
(
props
)
{
// const onToggleEditModeDone = (id) => {
// const newTasks = recievedTasks.map((task) => {
// if (task.id === id) {
// return {
// ...task,
// isEditMode: false,
// readOnly: true,
// };
// }
// return task;
// });
// setRecievedTasks(newTasks);
// };
const
task
=
{
id
:
0
,
title
:
""
,
description
:
""
,
createdAt
:
""
,
dateTimeStart
:
null
,
dateTimeDue
:
null
,
accomplish
:
""
,
priority
:
""
,
author
:
{
name
:
""
,
},
executors
:
[
{
name
:
""
}
],
isEditMode
:
false
,
readOnly
:
true
};
const
onToggleEditMode
=
(
id
)
=>
{
console
.
log
(
task
)
return
{
...
task
,
isEditMode
:
true
,
readOnly
:
false
,
};
};
console
.
log
(
task
)
return
(
<
TableRow
hover
key
=
{
task
.
id
}
>
<
TableCell
component
=
"th"
scope
=
"row"
padding
=
"none"
><
/TableCell
>
<
CustomTableCell
{...{
task
,
name
:
"priority"
,
value
:
task
.
priority
,
onChange
:
props
.
onChange
,
}}
/
>
<
CustomTableCell
{...{
task
,
name
:
"createdAt"
,
value
:
task
.
createdAt
,
}}
/
>
<
CustomTableCell
{...{
task
,
name
:
"title"
,
value
:
task
.
title
,
onChange
:
props
.
onChange
,
onModalOpen
:
props
.
onModalOpen
,
}}
/
>
{
task
.
isEditMode
?
(
<
BasicSelect
items
=
{[
"project1"
,
"project2"
,
"project3"
]}
task
=
{
task
}
onChange
=
{
props
.
onChange
}
/
>
)
:
(
<
CustomTableCell
{...{
task
,
name
:
"project"
,
value
:
task
.
project
?.
title
,
onChange
:
props
.
onChange
,
}}
/
>
)}
<
CustomTableCell
{...{
task
,
name
:
"author"
,
value
:
task
.
author
.
displayName
,
onChange
:
props
.
onAuthorChange
,
}}
/
>
<
TableCell
>
<
MaterialUIPickers
task
=
{
task
}
name
=
"dateTimeStart"
onChange
=
{
props
.
onDateChange
}
/
>
<
/TableCell
>
<
TableCell
>
<
MaterialUIPickers
task
=
{
task
}
name
=
"dateTimeDue"
onChange
=
{
props
.
onDateChange
}
/
>
<
/TableCell
>
{
task
.
isEditMode
?
(
<
BasicSelect
items
=
{[
"opened"
,
"done"
,
"failed"
]}
task
=
{
task
}
onChange
=
{
props
.
onChange
}
/
>
)
:
(
<
CustomTableCell
{...{
task
,
name
:
"accomplish"
,
value
:
task
.
accomplish
,
}}
/
>
)}
<
TableCell
>
{
task
.
isEditMode
?
(
<
IconButton
aria
-
label
=
"done"
onClick
=
{()
=>
{
props
.
onToggleEditModeDone
(
task
.
id
);
props
.
HandleEditTask
(
task
)
}}
>
<
Done
/>
<
/IconButton
>
)
:
(
<
IconButton
aria
-
label
=
"edit"
onClick
=
{()
=>
onToggleEditMode
(
task
.
id
)}
>
<
Edit
/>
<
/IconButton
>
)}
<
/TableCell
>
<
TableCell
>
<
Tooltip
title
=
"Delete"
>
<
IconButton
onClick
=
{(
id
)
=>
{
props
.
deleteHandle
(
task
.
id
);
}}
>
<
DeleteIcon
/>
<
/IconButton
>
<
/Tooltip
>
<
/TableCell
>
<
/TableRow
>
);
}
planner-front/src/containers/MyTasks/MyTasks.js
View file @
638a5a3e
...
@@ -24,6 +24,7 @@ import CustomTableCell from "../../components/MyTasksCompoments/CustomTableCell"
...
@@ -24,6 +24,7 @@ import CustomTableCell from "../../components/MyTasksCompoments/CustomTableCell"
import
MaterialUIPickers
from
"../../components/MyTasksCompoments/DateTimePicker/DateTimePicker"
;
import
MaterialUIPickers
from
"../../components/MyTasksCompoments/DateTimePicker/DateTimePicker"
;
import
BasicSelect
from
"../../components/UI/Select/Select"
;
import
BasicSelect
from
"../../components/UI/Select/Select"
;
import
{
fetchAllTasks
,
deleteTask
,
editTask
,
addTask
}
from
"../../store/actions/tasksActions"
;
import
{
fetchAllTasks
,
deleteTask
,
editTask
,
addTask
}
from
"../../store/actions/tasksActions"
;
import
NewTaskForm
from
"../../components/MyTasksCompoments/NewTaskForm"
;
function
descendingComparator
(
a
,
b
,
orderBy
)
{
function
descendingComparator
(
a
,
b
,
orderBy
)
{
...
@@ -59,7 +60,7 @@ export default function EnhancedTable() {
...
@@ -59,7 +60,7 @@ export default function EnhancedTable() {
useEffect
(()
=>
{
useEffect
(()
=>
{
dispatch
(
fetchAllTasks
());
dispatch
(
fetchAllTasks
());
},
[]);
},
[
dispatch
]);
const
tasks
=
useSelector
((
state
)
=>
state
.
tasks
.
tasks
);
const
tasks
=
useSelector
((
state
)
=>
state
.
tasks
.
tasks
);
console
.
log
(
tasks
)
console
.
log
(
tasks
)
...
@@ -149,6 +150,7 @@ console.log(tasks)
...
@@ -149,6 +150,7 @@ console.log(tasks)
};
};
const
onToggleEditMode
=
(
id
)
=>
{
const
onToggleEditMode
=
(
id
)
=>
{
console
.
log
(
id
)
const
newTasks
=
recievedTasks
.
map
((
task
)
=>
{
const
newTasks
=
recievedTasks
.
map
((
task
)
=>
{
if
(
task
.
id
===
id
)
{
if
(
task
.
id
===
id
)
{
return
{
return
{
...
@@ -162,7 +164,21 @@ console.log(tasks)
...
@@ -162,7 +164,21 @@ console.log(tasks)
setRecievedTasks
(
newTasks
);
setRecievedTasks
(
newTasks
);
};
};
const
HandleEditTask
=
(
task
)
=>
{
const
onToggleEditModeDone
=
(
id
)
=>
{
const
newTasks
=
recievedTasks
.
map
((
task
)
=>
{
if
(
task
.
id
===
id
)
{
return
{
...
task
,
isEditMode
:
false
,
readOnly
:
true
,
};
}
return
task
;
});
setRecievedTasks
(
newTasks
);
};
const
HandleEditTask
=
(
task
)
=>
{
dispatch
(
editTask
(
task
))
dispatch
(
editTask
(
task
))
}
}
...
@@ -264,10 +280,22 @@ console.log(tasks)
...
@@ -264,10 +280,22 @@ console.log(tasks)
</TableCell>
</TableCell>
</TableRow> */
}
</TableRow> */
}
{
/* <NewTaskForm
onChange={onChange}
onModalOpen={onModalOpen}
onAuthorChange={onAuthorChange}
onDateChange={onDateChange}
onToggleEditMode={onToggleEditMode}
onToggleEditModeDone={onToggleEditModeDone}
HandleEditTask={HandleEditTask}
deleteHandle={deleteHandle}
/> */
}
{
stableSort
(
recievedTasks
,
getComparator
(
order
,
orderBy
))
{
stableSort
(
recievedTasks
,
getComparator
(
order
,
orderBy
))
.
slice
(
page
*
rowsPerPage
,
page
*
rowsPerPage
+
rowsPerPage
)
.
slice
(
page
*
rowsPerPage
,
page
*
rowsPerPage
+
rowsPerPage
)
.
map
((
task
,
index
)
=>
{
.
map
((
task
,
index
)
=>
{
return
(
return
(
<
TableRow
hover
key
=
{
task
.
id
}
>
<
TableRow
hover
key
=
{
task
.
id
}
>
<
TableCell
<
TableCell
component
=
"th"
component
=
"th"
...
@@ -311,7 +339,7 @@ console.log(tasks)
...
@@ -311,7 +339,7 @@ console.log(tasks)
{...{
{...{
task
,
task
,
name
:
"project"
,
name
:
"project"
,
value
:
task
.
project
,
value
:
task
.
project
?.
title
,
onChange
:
onChange
,
onChange
:
onChange
,
}}
}}
/
>
/
>
...
@@ -361,7 +389,7 @@ console.log(tasks)
...
@@ -361,7 +389,7 @@ console.log(tasks)
{
task
.
isEditMode
?
(
{
task
.
isEditMode
?
(
<
IconButton
<
IconButton
aria
-
label
=
"done"
aria
-
label
=
"done"
onClick
=
{()
=>
{
onToggleEditMode
(
task
.
id
);
HandleEditTask
(
task
)
}}
onClick
=
{()
=>
{
onToggleEditMode
Done
(
task
.
id
);
HandleEditTask
(
task
)
}}
>
>
<
Done
/>
<
Done
/>
<
/IconButton
>
<
/IconButton
>
...
...
planner-front/src/index.js
View file @
638a5a3e
...
@@ -6,7 +6,7 @@ import { configureStore } from '@reduxjs/toolkit';
...
@@ -6,7 +6,7 @@ import { configureStore } from '@reduxjs/toolkit';
import
{
Provider
}
from
'react-redux'
;
import
{
Provider
}
from
'react-redux'
;
import
usersReducer
from
'./store/reducers/usersReducer'
;
import
usersReducer
from
'./store/reducers/usersReducer'
;
import
tasksReducer
from
'./store/reducers/tasksReducer'
;
import
tasksReducer
from
'./store/reducers/tasksReducer'
;
import
axios
from
'
axios
'
;
import
axios
from
'
./axiosPlanner
'
;
const
localStorageMiddleware
=
({
getState
})
=>
(
next
)
=>
(
action
)
=>
{
const
localStorageMiddleware
=
({
getState
})
=>
(
next
)
=>
(
action
)
=>
{
const
result
=
next
(
action
);
const
result
=
next
(
action
);
...
@@ -21,13 +21,6 @@ const loadFromLocalStorage = () => {
...
@@ -21,13 +21,6 @@ const loadFromLocalStorage = () => {
return
undefined
;
return
undefined
;
};
};
axios
.
interceptors
.
request
.
use
(
config
=>
{
try
{
config
.
headers
[
'Authorization'
]
=
store
.
getState
().
users
.
user
.
token
;
}
catch
(
e
){
}
return
config
;
})
const
store
=
configureStore
({
const
store
=
configureStore
({
reducer
:
{
reducer
:
{
...
@@ -38,6 +31,14 @@ const store = configureStore({
...
@@ -38,6 +31,14 @@ const store = configureStore({
middleware
:
(
getDefaultMiddleware
)
=>
getDefaultMiddleware
().
concat
(
localStorageMiddleware
)
middleware
:
(
getDefaultMiddleware
)
=>
getDefaultMiddleware
().
concat
(
localStorageMiddleware
)
})
})
axios
.
interceptors
.
request
.
use
(
config
=>
{
try
{
config
.
headers
[
'Authorization'
]
=
store
.
getState
().
users
.
user
.
token
;
}
catch
(
e
){
}
return
config
;
})
const
root
=
ReactDOM
.
createRoot
(
document
.
getElementById
(
'root'
));
const
root
=
ReactDOM
.
createRoot
(
document
.
getElementById
(
'root'
));
root
.
render
(
root
.
render
(
<
Provider
store
=
{
store
}
>
<
Provider
store
=
{
store
}
>
...
...
planner-front/src/store/actions/tasksActions.js
View file @
638a5a3e
...
@@ -70,11 +70,7 @@ export const addTask = (task) => {
...
@@ -70,11 +70,7 @@ export const addTask = (task) => {
dispatch
(
addTaskRequest
());
dispatch
(
addTaskRequest
());
const
token
=
getState
().
users
?.
user
?.
token
;
const
token
=
getState
().
users
?.
user
?.
token
;
try
{
try
{
await
axios
.
post
(
"/tasks"
,
task
,
{
await
axios
.
post
(
"/tasks"
,
task
);
headers
:
{
'Authorization'
:
'IwGVRaksGTWtnKlOZd7zJ'
}
});
dispatch
(
addTaskSuccess
())
dispatch
(
addTaskSuccess
())
dispatch
(
fetchCalendarTasks
())
dispatch
(
fetchCalendarTasks
())
}
catch
(
error
)
{
}
catch
(
error
)
{
...
@@ -98,14 +94,10 @@ const editTaskFailure = (error) => {
...
@@ -98,14 +94,10 @@ const editTaskFailure = (error) => {
export
const
editTask
=
(
task
)
=>
{
export
const
editTask
=
(
task
)
=>
{
return
async
(
dispatch
,
getState
)
=>
{
return
async
(
dispatch
,
getState
)
=>
{
dispatch
(
editTaskRequest
());
dispatch
(
editTaskRequest
());
const
token
=
getState
().
users
?.
user
?.
token
;
//
const token = getState().users?.user?.token;
try
{
try
{
console
.
log
(
task
)
console
.
log
(
'task'
,
task
)
const
r
=
await
axios
.
put
(
"/tasks"
,
task
,
{
const
r
=
await
axios
.
put
(
"/tasks/"
,
task
);
headers
:
{
'Authorization'
:
'IwGVRaksGTWtnKlOZd7zJ'
}
});
console
.
log
(
r
)
console
.
log
(
r
)
dispatch
(
editTaskSuccess
())
dispatch
(
editTaskSuccess
())
dispatch
(
fetchAllTasks
())
dispatch
(
fetchAllTasks
())
...
@@ -131,13 +123,9 @@ const deleteTaskFailure = (error) => {
...
@@ -131,13 +123,9 @@ const deleteTaskFailure = (error) => {
export
const
deleteTask
=
(
taskId
)
=>
{
export
const
deleteTask
=
(
taskId
)
=>
{
return
async
(
dispatch
,
getState
)
=>
{
return
async
(
dispatch
,
getState
)
=>
{
dispatch
(
deleteTaskRequest
());
dispatch
(
deleteTaskRequest
());
const
token
=
getState
().
users
?.
user
?.
token
;
//
const token = getState().users?.user?.token;
try
{
try
{
await
axios
.
delete
(
`/tasks/
${
taskId
}
`
,
{
await
axios
.
delete
(
`/tasks/
${
taskId
}
`
);
headers
:
{
'Authorization'
:
'IwGVRaksGTWtnKlOZd7zJ'
}
});
dispatch
(
deleteTaskSuccess
())
dispatch
(
deleteTaskSuccess
())
dispatch
(
fetchCalendarTasks
())
dispatch
(
fetchCalendarTasks
())
dispatch
(
fetchAllTasks
())
dispatch
(
fetchAllTasks
())
...
...
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