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
0b900d0a
Commit
0b900d0a
authored
Dec 10, 2022
by
Евгений Положенцев
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
#94
added UserReducer setup on fetch users all fields
parent
6516920b
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
37 additions
and
3 deletions
+37
-3
ProfileBlock.js
...r-front/src/components/Menus/ProfileBlock/ProfileBlock.js
+1
-0
userActionTypes.js
planner-front/src/store/actionTypes/userActionTypes.js
+5
-1
usersActions.js
planner-front/src/store/actions/usersActions.js
+27
-1
usersReducer.js
planner-front/src/store/reducers/usersReducer.js
+4
-1
No files found.
planner-front/src/components/Menus/ProfileBlock/ProfileBlock.js
View file @
0b900d0a
...
...
@@ -37,6 +37,7 @@ const ProfileBlock = () => {
>
<
MenuItem
component
=
{
NavLink
}
to
=
"/profile/test"
color
=
"inherit"
onClick
=
{
handleClose
}
>
Profile
<
/MenuItem
>
<
MenuItem
onClick
=
{()
=>
{
logout
()}}
>
Поменять
юзера
<
/MenuItem
>
<
MenuItem
onClick
=
{()
=>
{
logout
()}}
>
Logout
<
/MenuItem
>
<
/Menu
>
<
/
>
...
...
planner-front/src/store/actionTypes/userActionTypes.js
View file @
0b900d0a
...
...
@@ -11,3 +11,7 @@ export const LOGOUT_USER_FAILURE = "LOGOUT_USER_FAILURE";
export
const
FETCH_USERS_REQUEST
=
"FETCH_USERS_REQUEST"
;
export
const
FETCH_USERS_SUCCESS
=
"FETCH_USERS_SUCCESS"
;
export
const
FETCH_USERS_FAILURE
=
"FETCH_USERS_FAILURE"
;
export
const
FETCH_USERS_ALL_FIELDS_REQUEST
=
"FETCH_USERS_ALL_FIELDS_REQUEST"
;
export
const
FETCH_USERS_ALL_FIELDS_SUCCESS
=
"FETCH_USERS_ALL_FIELDS_SUCCESS"
;
export
const
FETCH_USERS_ALL_FIELDS_FAILURE
=
"FETCH_USERS_ALL_FIELDS_FAILURE"
;
\ No newline at end of file
planner-front/src/store/actions/usersActions.js
View file @
0b900d0a
import
axios
from
"../../axiosPlanner"
;
import
{
FETCH_USERS_FAILURE
,
FETCH_USERS_REQUEST
,
FETCH_USERS_SUCCESS
,
LOGIN_USER_FAILURE
,
LOGIN_USER_SUCCESS
,
LOGOUT_USER_FAILURE
,
LOGOUT_USER_SUCCESS
,
REGISTER_USER_FAILURE
,
REGISTER_USER_REQUEST
,
REGISTER_USER_SUCCESS
}
from
"../actionTypes/userActionTypes"
import
{
FETCH_USERS_FAILURE
,
FETCH_USERS_REQUEST
,
FETCH_USERS_SUCCESS
,
LOGIN_USER_FAILURE
,
LOGIN_USER_SUCCESS
,
LOGOUT_USER_FAILURE
,
LOGOUT_USER_SUCCESS
,
REGISTER_USER_FAILURE
,
REGISTER_USER_REQUEST
,
REGISTER_USER_SUCCESS
,
FETCH_USERS_ALL_FIELDS_REQUEST
,
FETCH_USERS_ALL_FIELDS_SUCCESS
,
FETCH_USERS_ALL_FIELDS_FAILURE
,
}
from
"../actionTypes/userActionTypes"
import
{
showNotification
}
from
"./commonActions"
;
const
registerUserRequest
=
()
=>
{
...
...
@@ -24,6 +26,16 @@ const fetchUsersFailure = () => {
return
{
type
:
FETCH_USERS_FAILURE
}
};
const
fetchUsersAllFieldsRequest
=
()
=>
{
return
{
type
:
FETCH_USERS_ALL_FIELDS_REQUEST
}
};
const
fetchUsersAllFieldsSuccess
=
(
users
)
=>
{
return
{
type
:
FETCH_USERS_ALL_FIELDS_SUCCESS
,
users
}
};
const
fetchUsersAllFieldsFailure
=
()
=>
{
return
{
type
:
FETCH_USERS_ALL_FIELDS_FAILURE
}
};
export
const
registerUser
=
(
userData
,
navigate
)
=>
{
return
async
(
dispatch
)
=>
{
dispatch
(
registerUserRequest
());
...
...
@@ -110,3 +122,17 @@ export const fetchUsers = () => {
}
}
};
export
const
fetchUsersAllFields
=
()
=>
{
return
async
dispatch
=>
{
dispatch
(
fetchUsersAllFieldsRequest
());
try
{
const
response
=
await
axios
.
get
(
"/users/all-fields/"
);
dispatch
(
fetchUsersAllFieldsSuccess
(
response
.
data
.
users
));
console
.
log
(
"users/all-fields/ "
,
response
.
data
.
users
)
}
catch
(
e
)
{
dispatch
(
fetchUsersAllFieldsFailure
(
e
));
}
}
};
\ No newline at end of file
planner-front/src/store/reducers/usersReducer.js
View file @
0b900d0a
import
{
REGISTER_USER_REQUEST
,
REGISTER_USER_SUCCESS
,
REGISTER_USER_FAILURE
,
LOGIN_USER_SUCCESS
,
LOGIN_USER_FAILURE
,
LOGOUT_USER_SUCCESS
,
FETCH_USERS_SUCCESS
}
from
"../actionTypes/userActionTypes"
;
import
{
REGISTER_USER_REQUEST
,
REGISTER_USER_SUCCESS
,
REGISTER_USER_FAILURE
,
LOGIN_USER_SUCCESS
,
LOGIN_USER_FAILURE
,
LOGOUT_USER_SUCCESS
,
FETCH_USERS_SUCCESS
,
FETCH_USERS_ALL_FIELDS_SUCCESS
}
from
"../actionTypes/userActionTypes"
;
const
initialState
=
{
user
:
null
,
users
:
[],
usersAllFields
:[],
registerError
:
null
,
loginError
:
null
,
loading
:
false
...
...
@@ -27,6 +28,8 @@ const usersReducer = (state = initialState, action) => {
return
{...
state
,
user
:
null
};
case
FETCH_USERS_SUCCESS
:
return
{...
state
,
loading
:
false
,
users
:
action
.
users
};
case
FETCH_USERS_ALL_FIELDS_SUCCESS
:
return
{...
state
,
loading
:
false
,
usersAllFields
:
action
.
users
};
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