/*
 * 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,
    notificationActions,
    notificationTimeout
} from './NotificationsConstants.js';

const notifications = store => next => action => {
    if (action.type === actionTypes.ADD_NOTIFICATION) {
        const { timeout, ...data } = action.payload;
        const interval = timeout || notificationTimeout;
        setTimeout(() => {
            store.dispatch(notificationActions.removeNotification(data));
        }, interval);
    }
    return next(action);
};

export default notifications;
