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
c438735f
Commit
c438735f
authored
Dec 21, 2022
by
Ibadullina Inabat
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
реализовано удаление проекта, бэк не отрабатывает
parent
4ab57d10
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
57 additions
and
24 deletions
+57
-24
ProjectItem.js
...c/components/ProjectComponents/ProjectItem/ProjectItem.js
+13
-9
ProjectMembersItem.js
...rojectComponents/ProjectMembersItem/ProjectMembersItem.js
+0
-4
FullProject.js
planner-front/src/containers/FullProject/FullProject.js
+7
-8
projectsActionTypes.js
planner-front/src/store/actionTypes/projectsActionTypes.js
+5
-1
projectsActions.js
planner-front/src/store/actions/projectsActions.js
+25
-1
projectsReducer.js
planner-front/src/store/reducers/projectsReducer.js
+7
-1
No files found.
planner-front/src/components/ProjectComponents/ProjectItem/ProjectItem.js
View file @
c438735f
import
{
Card
,
CardActions
,
CardContent
,
Grid
,
IconButton
}
from
"@mui/material"
;
import
{
Button
,
Card
,
CardActions
,
CardContent
,
Grid
,
IconButton
}
from
"@mui/material"
;
import
{
Link
}
from
"react-router-dom"
;
import
ArrowForwardIcon
from
"@mui/icons-material/ArrowForward"
;
import
{
useDispatch
,
useSelector
}
from
"react-redux"
;
import
DeleteIcon
from
"@mui/icons-material/Delete"
;
import
{
deleteProject
}
from
"../../../store/actions/projectsActions"
;
const
ProjectItem
=
({
title
,
tasks
,
id
})
=>
{
const
user
=
useSelector
(
state
=>
state
.
users
.
user
);
const
dispatch
=
useDispatch
();
console
.
log
(
id
)
console
.
log
(
user
)
const
deleteHandle
=
(
id
)
=>
{
dispatch
(
deleteProject
(
id
))
};
return
<>
<
Grid
item
xs
=
{
12
}
sm
=
{
12
}
md
=
{
6
}
lg
=
{
4
}
>
<
Card
>
...
...
@@ -23,17 +29,15 @@ const ProjectItem = ({ title, tasks, id }) => {
<
/strong
>
<
/CardContent
>
<
CardActions
>
{
<
Button
onClick
=
{(
id
)
=>
{
deleteHandle
(
id
);
}}
variant
=
"outlined"
startIcon
=
{
<
DeleteIcon
/>
}
>
Delete
<
/Button>
}
<
IconButton
component
=
{
Link
}
to
=
{
"/projects/"
+
id
}
>
<
ArrowForwardIcon
/>
<
/IconButton
>
<
IconButton
onClick
=
{(
id
)
=>
{
// deleteHandle(userId);
}}
>
{(
title
!==
"Личные дела"
)
?
<
DeleteIcon
/>
:
null
}
<
/IconButton
>
<
/CardActions
>
<
/Card
>
<
/Grid
>
...
...
planner-front/src/components/ProjectComponents/ProjectMembersItem/ProjectMembersItem.js
View file @
c438735f
...
...
@@ -15,11 +15,7 @@ const ProjectMembersItem = ({ displayName, roleProject, id, roleProjectOfAuthor,
const
{
projects
,
project
}
=
useSelector
(
state
=>
state
.
projects
);
const
deleteHandle
=
(
userId
,
projectId
)
=>
{
if
(
members
.
length
>
1
)
{
dispatch
(
deleteMember
(
userId
,
params
.
id
))
}
else
{
alert
(
"Нельзя удалить автора проекта"
)
}
};
return
<>
...
...
planner-front/src/containers/FullProject/FullProject.js
View file @
c438735f
import
{
Card
,
CardActions
,
CardContent
,
Grid
}
from
"@mui/material"
;
import
{
Button
,
Card
,
CardActions
,
CardContent
,
Grid
,
IconButton
}
from
"@mui/material"
;
import
{
useParams
}
from
"react-router-dom"
;
import
{
useSelector
,
useDispatch
}
from
"react-redux"
;
import
{
useEffect
}
from
"react"
;
...
...
@@ -8,6 +8,7 @@ import { fetchUsers } from "../../store/actions/usersActions";
import
ProjectMembersList
from
"../../components/ProjectComponents/ProjectMembersList/ProjectMembersList"
;
import
NewMember
from
"../NewMember/NewMember"
;
const
FullProject
=
()
=>
{
const
{
projects
,
project
}
=
useSelector
(
state
=>
state
.
projects
);
...
...
@@ -34,7 +35,7 @@ const FullProject = () => {
return
<>
<
Grid
item
xs
=
{
12
}
sm
=
{
12
}
md
=
{
6
}
lg
=
{
4
}
>
<
Card
>
<
h2
>
Проект
-
{
project
?.
project
?.
title
}
<
/h2
>
<
h2
>
Проект
-
{
project
?.
project
?.
title
}
<
/h2
>
<
CardContent
>
<
strong
>
<
br
><
/br
>
...
...
@@ -54,13 +55,11 @@ const FullProject = () => {
<
/strong
>
<
strong
>
<
br
><
/br
>
<
div
style
=
{{
display
:
'flex'
,
direction
:
'column'
}}
>
<
div
style
=
{{
display
:
'flex'
,
direction
:
'column'
}}
>
Участники
проекта
:
{(
project
?.
project
?.
members
[
0
]?.
user
.
displayName
===
user
.
displayName
)
?
<
NewMember
members
=
{
project
?.
project
?.
members
}
/> : null
}
<
/div
>
<
ProjectMembersList
users
=
{
users
}
project
=
{
project
}
members
=
{
project
?.
project
?.
members
}
roleProjectOfAuthor
=
{
project
?.
project
?.
members
[
0
]?.
roleProject
}
authorOfProject
=
{
project
?.
project
?.
members
[
0
]?.
user
.
displayName
}
/
>
<
ProjectMembersList
users
=
{
users
}
project
=
{
project
}
members
=
{
project
?.
project
?.
members
}
roleProjectOfAuthor
=
{
project
?.
project
?.
members
[
0
]?.
roleProject
}
authorOfProject
=
{
project
?.
project
?.
members
[
0
]?.
user
.
displayName
}
/
>
<
/strong
>
<
strong
>
<
br
><
/br
>
...
...
planner-front/src/store/actionTypes/projectsActionTypes.js
View file @
c438735f
...
...
@@ -12,3 +12,7 @@ export const DELETE_MEMBER_SUCCESS = "DELETE_MEMBER_SUCCESS";
export
const
DELETE_MEMBER_FAILURE
=
"DELETE_MEMBER_FAILURE"
;
export
const
FETCH_ALL_USER_PROJECTS_SUCCESS
=
"FETCH_ALL_USER_PROJECTS_SUCCESS"
;
export
const
DELETE_PROJECT_REQUEST
=
"DELETE_PROJECT_REQUEST"
;
export
const
DELETE_PROJECT_SUCCESS
=
"DELETE_PROJECT_SUCCESS"
;
export
const
DELETE_PROJECT_FAILURE
=
"DELETE_PROJECT_FAILURE"
;
\ No newline at end of file
planner-front/src/store/actions/projectsActions.js
View file @
c438735f
import
axios
from
"../../axiosPlanner"
;
import
{
CREATE_MEMBER_SUCCESS
,
CREATE_PROJECT_SUCCESS
,
DELETE_MEMBER_FAILURE
,
DELETE_MEMBER_REQUEST
,
DELETE_MEMBER_SUCCESS
,
FETCH_ALL_USER_PROJECTS_SUCCESS
,
FETCH_MEMBERS_ERROR
,
FETCH_MEMBERS_REQUEST
,
FETCH_MEMBERS_SUCCESS
,
FETCH_PROJECTS_ERROR
,
FETCH_PROJECTS_REQUEST
,
FETCH_PROJECTS_SUCCESS
,
FETCH_PROJECT_SUCCESS
}
from
"../actionTypes/projectsActionTypes"
;
import
{
CREATE_MEMBER_SUCCESS
,
CREATE_PROJECT_SUCCESS
,
DELETE_MEMBER_FAILURE
,
DELETE_MEMBER_REQUEST
,
DELETE_MEMBER_SUCCESS
,
DELETE_PROJECT_FAILURE
,
DELETE_PROJECT_REQUEST
,
DELETE_PROJECT_SUCCESS
,
FETCH_ALL_USER_PROJECTS_SUCCESS
,
FETCH_MEMBERS_ERROR
,
FETCH_MEMBERS_REQUEST
,
FETCH_MEMBERS_SUCCESS
,
FETCH_PROJECTS_ERROR
,
FETCH_PROJECTS_REQUEST
,
FETCH_PROJECTS_SUCCESS
,
FETCH_PROJECT_SUCCESS
}
from
"../actionTypes/projectsActionTypes"
;
import
{
showNotification
}
from
"./commonActions"
;
const
fetchProjectsRequest
=
()
=>
{
...
...
@@ -36,6 +36,17 @@ const deleteMemberRequest = () => {
return
{
type
:
DELETE_MEMBER_FAILURE
,
error
}
};
const
deleteProjectRequest
=
()
=>
{
return
{
type
:
DELETE_PROJECT_REQUEST
}
};
const
deleteProjectSuccess
=
()
=>
{
return
{
type
:
DELETE_PROJECT_SUCCESS
}
};
const
deleteProjectFailure
=
(
error
)
=>
{
return
{
type
:
DELETE_PROJECT_FAILURE
,
error
}
};
export
const
deleteMember
=
(
memberId
,
projectId
)
=>
{
return
async
(
dispatch
)
=>
{
dispatch
(
deleteMemberRequest
());
...
...
@@ -50,6 +61,19 @@ const deleteMemberRequest = () => {
}
}
export
const
deleteProject
=
(
projectId
,
projects
)
=>
{
return
async
(
dispatch
)
=>
{
dispatch
(
deleteProjectRequest
());
try
{
const
response
=
await
axios
.
delete
(
`/projects/
${
projectId
}
`
);
console
.
log
(
"deleteMember "
,
response
.
data
)
dispatch
(
deleteProjectSuccess
())
dispatch
(
fetchProjects
(
projects
))
}
catch
(
error
)
{
dispatch
(
deleteProjectFailure
(
error
.
response
.
data
));
}
}
}
export
const
fetchProjects
=
()
=>
{
return
async
dispatch
=>
{
dispatch
(
fetchProjectsRequest
());
...
...
planner-front/src/store/reducers/projectsReducer.js
View file @
c438735f
import
{
DELETE_MEMBER_FAILURE
,
DELETE_MEMBER_REQUEST
,
DELETE_MEMBER_SUCCESS
,
FETCH_ALL_USER_PROJECTS_SUCCESS
,
FETCH_PROJECTS_ERROR
,
FETCH_PROJECTS_REQUEST
,
FETCH_PROJECTS_SUCCESS
,
FETCH_PROJECT_SUCCESS
}
from
"../actionTypes/projectsActionTypes"
;
import
{
DELETE_MEMBER_FAILURE
,
DELETE_MEMBER_REQUEST
,
DELETE_MEMBER_SUCCESS
,
DELETE_PROJECT_FAILURE
,
DELETE_PROJECT_REQUEST
,
DELETE_PROJECT_SUCCESS
,
FETCH_ALL_USER_PROJECTS_SUCCESS
,
FETCH_PROJECTS_ERROR
,
FETCH_PROJECTS_REQUEST
,
FETCH_PROJECTS_SUCCESS
,
FETCH_PROJECT_SUCCESS
}
from
"../actionTypes/projectsActionTypes"
;
const
initialState
=
{
allUserProjects
:
[],
...
...
@@ -24,6 +24,12 @@ const initialState = {
return
{...
state
,
loading
:
true
};
case
DELETE_MEMBER_FAILURE
:
return
{...
state
,
loading
:
false
,
error
:
action
.
error
};
case
DELETE_PROJECT_SUCCESS
:
return
{...
state
,
loading
:
false
};
case
DELETE_PROJECT_REQUEST
:
return
{...
state
,
loading
:
true
};
case
DELETE_PROJECT_FAILURE
:
return
{...
state
,
loading
:
false
,
error
:
action
.
error
};
case
FETCH_ALL_USER_PROJECTS_SUCCESS
:
return
{...
state
,
loading
:
false
,
allUserProjects
:
action
.
projects
}
default
:
...
...
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