Proyectos de Subversion LeadersLinked - Antes de SPA

Rev

| Ultima modificación | Ver Log |

Rev Autor Línea Nro. Línea
6493 stevensc 1
import { v1 } from 'uuid'
2
import { notificationActionTypes } from './notification.types'
3
 
4
const NotificationInitialState = {
5
  notifications: []
6
}
7
 
8
const notificationReducer = (
9
  state = NotificationInitialState,
10
  { type, payload }
11
) => {
12
  switch (type) {
13
    case notificationActionTypes.ADD_NOTIFICATION:
14
      const newNotification = { ...payload, id: v1() }
15
      return {
16
        ...state,
17
        notifications: [newNotification, ...state.notifications]
18
      }
19
    case notificationActionTypes.REMOVE_NOTIFICATION:
20
      const idToFilter = payload
21
      return {
22
        ...state,
23
        notifications: state.notifications.filter(
24
          (element) => element.id !== idToFilter
25
        )
26
      }
27
 
28
    default:
29
      return state
30
  }
31
}
32
 
33
export default notificationReducer