
const initialState = {
    loading: false,
    badgeCount: 0,
    notifications: {},
    error: null,   
};

const notificationReducer = (state = initialState, action) => {
  // console.log('Action dispatched---', action); 
    switch (action.type) {
      case 'SET_LOADING':
        return { ...state, loading: action.data.loading };
      case 'SET_BADGE_COUNT':
        return { ...state, badgeCount: action.data.badgeCount};
      case 'SET_NOTIFICATIONS':
        console.log('Reducer - notifications:', action.data.notifications);
        return { ...state, notifications: action.data.notifications};
      case 'GET_NOTIFICATIONS':
        return { ...state };
      case 'FETCH_NOTIFICATIONS_FAILURE':
        return { ...state, error: action.data.error };
      default:
        return state;
    }
  };


export default notificationReducer;