/*
 * Copyright © 2016-2018 European Support Limited
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * 
 *      http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
import { actionTypes } from './NotificationsConstants';

export default (state = [], action) => {
    switch (action.type) {
        case actionTypes.ADD_NOTIFICATION:
            return [...state, action.payload];

        case actionTypes.REMOVE_NOTIFICATION:
            return state.filter(item => item.id !== action.payload.id);
        default:
            return state;
    }
};
