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
06b02f32
Commit
06b02f32
authored
Dec 12, 2022
by
Ibadullina Inabat
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
устранена неполадка вывода данных при добавлении нового участника в проект
parent
fec54d89
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
59 additions
and
25 deletions
+59
-25
MemberForm.js
planner-front/src/components/MemberForm/MemberForm.js
+19
-20
NewMember.js
planner-front/src/containers/NewMember/NewMember.js
+1
-1
projectsActionTypes.js
planner-front/src/store/actionTypes/projectsActionTypes.js
+5
-1
projectsActions.js
planner-front/src/store/actions/projectsActions.js
+27
-2
projectsReducer.js
planner-front/src/store/reducers/projectsReducer.js
+7
-1
No files found.
planner-front/src/components/MemberForm/MemberForm.js
View file @
06b02f32
...
@@ -25,34 +25,36 @@ const MemberForm = ({ onSubmit }) => {
...
@@ -25,34 +25,36 @@ const MemberForm = ({ onSubmit }) => {
const
users
=
useSelector
(
state
=>
state
.
users
.
users
)
const
users
=
useSelector
(
state
=>
state
.
users
.
users
)
const
[
role
,
setRole
]
=
useState
([{
role
:
"user"
},
{
role
:
"admin"
},
{
role
:
"watcher"
}])
const
[
role
,
setRole
]
=
useState
([{
role
:
"user"
},
{
role
:
"admin"
},
{
role
:
"watcher"
}])
const
params
=
useParams
()
const
params
=
useParams
()
console
.
log
(
users
)
const
[
open
,
setOpen
]
=
useState
(
false
);
const
[
open
,
setOpen
]
=
useState
(
false
);
const
handleOpen
=
()
=>
setOpen
(
true
);
const
handleOpen
=
()
=>
setOpen
(
true
);
const
handleClose
=
()
=>
setOpen
(
false
);
const
handleClose
=
()
=>
setOpen
(
false
);
const
[
state
,
setState
]
=
useState
({
const
[
state
,
setState
]
=
useState
({
displayName
:
""
,
//
displayName: "",
roleProject
:
""
,
roleProject
:
""
,
user
Id
:
""
,
user
:
""
,
projectId
:
""
projectId
:
""
});
});
const
submitFormHandler
=
(
e
)
=>
{
const
submitFormHandler
=
(
e
)
=>
{
e
.
preventDefault
();
e
.
preventDefault
();
let
idOfUser
=
users
?.
map
((
user
)
=>
(
user
.
displayName
===
state
.
displayName
)
?
user
.
id
:
null
)
//
let idOfUser = users?.map((user) => (user.displayName === state.displayName) ? user.id : null)
let
idOfUser1
=
users
?.
map
((
user
)
=>
{
// let idOfUser
= users?.map((user) => {
console
.
log
(
user
)
//
console.log(user)
return
null
// return (user.id === state.displayName.id) ? user.id :
null
})
//
})
console
.
log
(
idOfUser1
)
// console.log(idOfUser
)
console
.
log
(
idOfUser
)
//
console.log(idOfUser)
console
.
log
(
"state of submit "
+
state
);
console
.
log
(
"state of submit "
+
state
);
let
members
=
{
roleProject
:
state
.
roleProject
,
projectId
:
params
.
id
,
userId
:
idOfUser
}
let
members
=
{
roleProject
:
state
.
roleProject
,
projectId
:
params
.
id
,
userId
:
state
.
user
.
id
}
console
.
log
(
members
);
console
.
log
(
members
);
onSubmit
(
members
);
onSubmit
(
members
);
setOpen
(
false
);
};
};
console
.
log
(
state
);
// console.log(user)
// const onChange = (e) => {
// const onChange = (e) => {
// const value = e.target.value;
// const value = e.target.value;
// const name = e.target.name;
// const name = e.target.name;
...
@@ -64,7 +66,7 @@ const MemberForm = ({ onSubmit }) => {
...
@@ -64,7 +66,7 @@ const MemberForm = ({ onSubmit }) => {
// };
// };
const
memberChangeHandler
=
(
e
,
value
)
=>
{
const
memberChangeHandler
=
(
e
,
value
)
=>
{
setState
(()
=>
{
return
{
...
state
,
member
:
value
,
userId
:
state
.
userI
d
}
});
setState
(()
=>
{
return
{
...
state
,
user
:
value
,
projectId
:
params
.
i
d
}
});
console
.
log
(
"memberChangeHandler"
+
value
)
console
.
log
(
"memberChangeHandler"
+
value
)
}
}
const
roleChangeHandler
=
(
e
,
value
)
=>
{
const
roleChangeHandler
=
(
e
,
value
)
=>
{
...
@@ -73,7 +75,7 @@ const MemberForm = ({ onSubmit }) => {
...
@@ -73,7 +75,7 @@ const MemberForm = ({ onSubmit }) => {
}
}
return
(
return
(
<
div
>
<
div
>
<
PersonAddIcon
onClick
=
{
handleOpen
}
style
=
{{
marginLeft
:
"30px"
,
marginTop
:
"-3px"
}}
>
Добавить
участника
<
/PersonAddIcon
>
<
PersonAddIcon
onClick
=
{
handleOpen
}
style
=
{{
marginLeft
:
"30px"
,
marginTop
:
"-3px"
,
cursor
:
'pointer'
}}
>
Добавить
участника
<
/PersonAddIcon
>
<
Modal
<
Modal
open
=
{
open
}
open
=
{
open
}
onClose
=
{
handleClose
}
onClose
=
{
handleClose
}
...
@@ -88,15 +90,13 @@ const MemberForm = ({ onSubmit }) => {
...
@@ -88,15 +90,13 @@ const MemberForm = ({ onSubmit }) => {
<
Autocomplete
<
Autocomplete
id
=
"free-solo-demo"
id
=
"free-solo-demo"
freeSolo
freeSolo
options
=
{
users
?.
map
((
user
)
=>
user
.
displayName
)}
options
=
{
users
}
getOptionLabel
=
{(
item
)
=>
item
.
displayName
||
""
}
onChange
=
{
memberChangeHandler
}
onChange
=
{
memberChangeHandler
}
name
=
{
"userId"
}
name
=
{
"userId"
}
value
=
{
state
.
user
Id
}
value
=
{
state
.
user
}
renderInput
=
{(
params
)
=>
<
TextField
renderInput
=
{(
params
)
=>
<
TextField
style
=
{{
margin
:
"5px"
}}
style
=
{{
margin
:
"5px"
}}
label
=
{
"Участник"
}
label
=
{
"Участник"
}
state
=
{
state
}
state
=
{
state
}
{...
params
}
/>
}
{...
params
}
/>
}
...
@@ -110,7 +110,6 @@ const MemberForm = ({ onSubmit }) => {
...
@@ -110,7 +110,6 @@ const MemberForm = ({ onSubmit }) => {
renderInput
=
{(
params
)
=>
<
TextField
renderInput
=
{(
params
)
=>
<
TextField
style
=
{{
margin
:
"5px"
}}
style
=
{{
margin
:
"5px"
}}
name
=
{
"roleProject"
}
name
=
{
"roleProject"
}
label
=
{
"Роль в проекте"
}
label
=
{
"Роль в проекте"
}
state
=
{
state
}
state
=
{
state
}
{...
params
}
/>
}
{...
params
}
/>
}
...
...
planner-front/src/containers/NewMember/NewMember.js
View file @
06b02f32
...
@@ -13,7 +13,7 @@ const NewMember = ({members}) => {
...
@@ -13,7 +13,7 @@ const NewMember = ({members}) => {
const
onSubmit
=
async
(
memberData
)
=>
{
const
onSubmit
=
async
(
memberData
)
=>
{
await
dispatch
(
createMember
(
memberData
,
navigate
));
await
dispatch
(
createMember
(
memberData
,
navigate
));
// navigate("/projects/" + memberData.i
d)
navigate
(
"/projects/"
+
memberData
.
projectI
d
)
console
.
log
(
"memberData "
,
memberData
)
console
.
log
(
"memberData "
,
memberData
)
};
};
...
...
planner-front/src/store/actionTypes/projectsActionTypes.js
View file @
06b02f32
...
@@ -6,3 +6,7 @@ export const FETCH_PROJECT_SUCCESS = "FETCH_PROJECT_SUCCESS";
...
@@ -6,3 +6,7 @@ export const FETCH_PROJECT_SUCCESS = "FETCH_PROJECT_SUCCESS";
export
const
CREATE_PROJECT_SUCCESS
=
"CREATE_PROJECT_SUCCESS"
;
export
const
CREATE_PROJECT_SUCCESS
=
"CREATE_PROJECT_SUCCESS"
;
export
const
CREATE_MEMBER_SUCCESS
=
"CREATE_MEMBER_SUCCESS"
;
export
const
CREATE_MEMBER_SUCCESS
=
"CREATE_MEMBER_SUCCESS"
;
export
const
DELETE_MEMBER_REQUEST
=
"DELETE_MEMBER_REQUEST"
;
export
const
DELETE_MEMBER_SUCCESS
=
"DELETE_MEMBER_SUCCESS"
;
export
const
DELETE_MEMBER_FAILURE
=
"DELETE_MEMBER_FAILURE"
;
\ No newline at end of file
planner-front/src/store/actions/projectsActions.js
View file @
06b02f32
import
axios
from
"../../axiosPlanner"
;
import
axios
from
"../../axiosPlanner"
;
import
{
CREATE_MEMBER_SUCCESS
,
CREATE_PROJECT_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
,
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"
;
import
{
showNotification
}
from
"./commonActions"
;
const
fetchProjectsRequest
=
()
=>
{
const
fetchProjectsRequest
=
()
=>
{
...
@@ -23,6 +23,31 @@ const createMemberSuccess = (member) => {
...
@@ -23,6 +23,31 @@ const createMemberSuccess = (member) => {
return
{
type
:
CREATE_MEMBER_SUCCESS
,
member
};
return
{
type
:
CREATE_MEMBER_SUCCESS
,
member
};
};
};
const
deleteMemberRequest
=
()
=>
{
return
{
type
:
DELETE_MEMBER_REQUEST
}
};
const
deleteMemberSuccess
=
()
=>
{
return
{
type
:
DELETE_MEMBER_SUCCESS
}
};
const
deleteMemberFailure
=
(
error
)
=>
{
return
{
type
:
DELETE_MEMBER_FAILURE
,
error
}
};
export
const
deleteMember
=
(
memberId
)
=>
{
return
async
(
dispatch
)
=>
{
dispatch
(
deleteMemberRequest
());
try
{
await
axios
.
delete
(
`/tasks/
${
memberId
}
`
);
dispatch
(
deleteMemberSuccess
())
dispatch
(
fetchProject
())
}
catch
(
error
)
{
dispatch
(
deleteMemberFailure
(
error
.
response
.
data
));
}
}
}
export
const
fetchProjects
=
()
=>
{
export
const
fetchProjects
=
()
=>
{
return
async
dispatch
=>
{
return
async
dispatch
=>
{
dispatch
(
fetchProjectsRequest
());
dispatch
(
fetchProjectsRequest
());
...
@@ -41,7 +66,7 @@ export const fetchProject = (id) => {
...
@@ -41,7 +66,7 @@ export const fetchProject = (id) => {
try
{
try
{
const
response
=
await
axios
.
get
(
"/projects/"
+
id
);
const
response
=
await
axios
.
get
(
"/projects/"
+
id
);
dispatch
(
fetchProjectSuccess
(
response
.
data
));
dispatch
(
fetchProjectSuccess
(
response
.
data
));
console
.
log
(
"fetch project "
+
response
.
data
)
console
.
log
(
"fetch project "
,
response
.
data
)
}
catch
(
e
)
{
}
catch
(
e
)
{
dispatch
(
fetchProjectsError
(
e
));
dispatch
(
fetchProjectsError
(
e
));
}
}
...
...
planner-front/src/store/reducers/projectsReducer.js
View file @
06b02f32
import
{
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
,
FETCH_PROJECTS_ERROR
,
FETCH_PROJECTS_REQUEST
,
FETCH_PROJECTS_SUCCESS
,
FETCH_PROJECT_SUCCESS
}
from
"../actionTypes/projectsActionTypes"
;
const
initialState
=
{
const
initialState
=
{
projects
:
[],
projects
:
[],
...
@@ -17,6 +17,12 @@ const initialState = {
...
@@ -17,6 +17,12 @@ const initialState = {
return
{...
state
,
loading
:
false
,
error
:
action
.
error
};
return
{...
state
,
loading
:
false
,
error
:
action
.
error
};
case
FETCH_PROJECT_SUCCESS
:
case
FETCH_PROJECT_SUCCESS
:
return
{...
state
,
loading
:
false
,
project
:
action
.
project
}
return
{...
state
,
loading
:
false
,
project
:
action
.
project
}
case
DELETE_MEMBER_SUCCESS
:
return
{...
state
,
loading
:
false
};
case
DELETE_MEMBER_REQUEST
:
return
{...
state
,
loading
:
true
};
case
DELETE_MEMBER_FAILURE
:
return
{...
state
,
loading
:
false
,
error
:
action
.
error
};
default
:
default
:
return
state
;
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