Skip to content

Commit 8a7f982

Browse files
fix(user): correct user login and user set role names
1 parent 549b721 commit 8a7f982

File tree

7 files changed

+15
-15
lines changed

7 files changed

+15
-15
lines changed

src/actions/user.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ export function* userLogIn({ username, password }) {
4646
*/
4747
export function* userLogOut() {
4848
yield put({
49-
type: USER_LOG_OUT
49+
type: `${USER_LOG_OUT}_SUCCESS`
5050
});
5151
}
5252

@@ -57,7 +57,7 @@ export function* userLogOut() {
5757
*/
5858
export function* userSetRole(role) {
5959
yield put({
60-
type: USER_SET_ROLE,
60+
type: `${USER_SET_ROLE}_SUCCESS`,
6161
payload: {
6262
role
6363
}

src/actions/user.test.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ describe('actions->user', () => {
5959
testSaga(userLogOut)
6060
.next()
6161
.put({
62-
type: USER_LOG_OUT
62+
type: `${USER_LOG_OUT}_SUCCESS`
6363
})
6464
.next()
6565
.isDone();
@@ -69,7 +69,7 @@ describe('actions->user', () => {
6969
testSaga(userSetRole, USER_ROLE_EDITOR)
7070
.next()
7171
.put({
72-
type: USER_SET_ROLE,
72+
type: `${USER_SET_ROLE}_SUCCESS`,
7373
payload: {
7474
role: USER_ROLE_EDITOR
7575
}

src/components/App/App.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,13 @@ const App = () => (
2222
redirectTo="/dashboard"
2323
component={Login}
2424
/>
25+
<PrivateRoute exact path="/logout" redirectTo="/" component={Logout} />
2526
<PrivateRoute
2627
exact
2728
path="/dashboard"
2829
redirectTo="/login"
2930
component={Dashboard}
3031
/>
31-
<PrivateRoute exact path="/logout" redirectTo="/" component={Logout} />
3232
</Switch>
3333
</Router>
3434
</Fragment>

src/pages/Logout/Logout.container.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,6 @@ const mapDispatchToProps = dispatch => ({
1010
dispatch
1111
});
1212

13-
const mapState = () => ({});
13+
const mapState = ({ user }) => ({ user });
1414

1515
export default connect(mapState, mapDispatchToProps)(Logout);

src/reducers/__snapshots__/user.test.js.snap

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ Object {
5151
}
5252
`;
5353

54-
exports[`reducers->user Should handle USER_LOG_OUT 1`] = `
54+
exports[`reducers->user Should handle USER_LOG_OUT_SUCCESS 1`] = `
5555
Object {
5656
"authentication": Object {
5757
"accessToken": null,
@@ -68,7 +68,7 @@ Object {
6868
}
6969
`;
7070

71-
exports[`reducers->user Should handle USER_SET_ROLE 1`] = `
71+
exports[`reducers->user Should handle USER_SET_ROLE_SUCCESS 1`] = `
7272
Object {
7373
"authentication": Object {
7474
"accessToken": null,

src/reducers/user.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -91,14 +91,14 @@ export default function user(state = defaultState, action) {
9191
/**
9292
* Reducer that handles user logout actions.
9393
*/
94-
case USER_LOG_OUT: {
95-
return { ...defaultState };
94+
case `${USER_LOG_OUT}_SUCCESS`: {
95+
return defaultState;
9696
}
9797

9898
/**
9999
* Reducer that handles setting a user's role.
100100
*/
101-
case USER_SET_ROLE: {
101+
case `${USER_SET_ROLE}_SUCCESS`: {
102102
const { role } = action.payload;
103103
return { ...state, authentication: { ...state.authentication, role } };
104104
}

src/reducers/user.test.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -61,18 +61,18 @@ describe('reducers->user', () => {
6161
).toMatchSnapshot();
6262
});
6363

64-
it(`Should handle ${USER_LOG_OUT}`, () => {
64+
it(`Should handle ${USER_LOG_OUT}_SUCCESS`, () => {
6565
expect(
6666
reducer(undefined, {
67-
type: USER_LOG_OUT
67+
type: `${USER_LOG_OUT}_SUCCESS`
6868
})
6969
).toMatchSnapshot();
7070
});
7171

72-
it(`Should handle ${USER_SET_ROLE}`, () => {
72+
it(`Should handle ${USER_SET_ROLE}_SUCCESS`, () => {
7373
expect(
7474
reducer(undefined, {
75-
type: USER_SET_ROLE,
75+
type: `${USER_SET_ROLE}_SUCCESS`,
7676
payload: {
7777
role: USER_ROLE_EDITOR
7878
}

0 commit comments

Comments
 (0)