You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

reducer.ts 1.0KB

12345678910111213141516171819202122232425262728293031323334353637
  1. import ReducerRegistry from '../redux/ReducerRegistry';
  2. import { equals } from '../redux/functions';
  3. import { SET_JWT } from './actionTypes';
  4. export interface IJwtState {
  5. group?: string;
  6. jwt?: string;
  7. server?: string;
  8. }
  9. /**
  10. * Reduces redux actions which affect the JSON Web Token (JWT) stored in the
  11. * redux store.
  12. *
  13. * @param {Object} state - The current redux state.
  14. * @param {Object} action - The redux action to reduce.
  15. * @returns {Object} The next redux state which is the result of reducing the
  16. * specified {@code action}.
  17. */
  18. ReducerRegistry.register<IJwtState>(
  19. 'features/base/jwt',
  20. (state = {}, action): IJwtState => {
  21. switch (action.type) {
  22. case SET_JWT: {
  23. // eslint-disable-next-line @typescript-eslint/no-unused-vars
  24. const { type, ...payload } = action;
  25. const nextState = {
  26. ...payload
  27. };
  28. return equals(state, nextState) ? state : nextState;
  29. }
  30. }
  31. return state;
  32. });