Home Reference Source

application/redux/reducers/alert-reducers.js

import _ from 'lodash';
import Immutable from 'immutable';
import {
    ALERT_SHOW_MESSAGE,
    ALERT_CLOSE
} from './../actions/alert-actions';

export function systemAlert(state = null, action) {
    if (state === null) {
        state = {
            open: false,
            message: ''
        };
    }

    switch (action.type) {
        case ALERT_SHOW_MESSAGE:
            return Object.assign({}, state, {
                open: true,
                message: action.payload.message,
                title: action.payload.title
            });
        case ALERT_CLOSE:
            return Object.assign({}, state, {
                open: false
            });
    }
    return state;
};