fleet/frontend/redux/nodes/entities/users/reducer.js
Zachary Wasserman 77e4f3d936 Refactor require password reset into separate endpoint (#725)
- Remove require password reset from ModifyUser and
  RequestPasswordReset methods, and UserPayload struct
- Add new RequirePasswordReset method
- Refactor JS for new separate method
2017-01-06 14:38:39 -08:00

35 lines
823 B
JavaScript

import {
REQUIRE_PASSWORD_RESET_FAILURE,
REQUIRE_PASSWORD_RESET_REQUEST,
REQUIRE_PASSWORD_RESET_SUCCESS,
} from './actions';
import config, { initialState } from './config';
export default (state = initialState, { type, payload }) => {
switch (type) {
case REQUIRE_PASSWORD_RESET_REQUEST:
return {
...state,
errors: {},
loading: true,
};
case REQUIRE_PASSWORD_RESET_SUCCESS:
return {
...state,
errors: {},
loading: false,
data: {
...state.data,
[payload.user.id]: payload.user,
},
};
case REQUIRE_PASSWORD_RESET_FAILURE:
return {
...state,
loading: false,
errors: payload.errors,
};
default:
return config.reducer(state, { type, payload });
}
};