Home Reference Source

application/redux/reducers/snackbar-reducers.js

  1. import _ from 'lodash';
  2. import Immutable from 'immutable';
  3. import {
  4. SNACKBAR_SHOW_MESSAGE,
  5. SNACKBAR_CLOSE
  6. } from './../actions/snackbar-actions';
  7.  
  8. export function snackbar(state = null, action) {
  9. if (state === null) {
  10. state = {
  11. open: false,
  12. message: ''
  13. };
  14. }
  15.  
  16. switch (action.type) {
  17. case SNACKBAR_SHOW_MESSAGE:
  18. return Object.assign({}, state, {
  19. open: true,
  20. message: action.payload.message,
  21. duration: action.payload.duration
  22. });
  23. case SNACKBAR_CLOSE:
  24. return Object.assign({}, state, {
  25. open: false
  26. });
  27. }
  28. return state;
  29. };