Proyectos de Subversion LeadersLinked - SPA

Rev

Rev 1642 | Rev 1645 | Ir a la última revisión | Autoría | Comparar con el anterior | Ultima modificación | Ver Log |

import { actionsTypes } from './report.actions'

const reportState = {
  showModal: false,
  type: 'Publicación',
  reportUrl: '',
  onComplete: () => {}
}

const reportReducer = (state = reportState, action) => {
  const { type, payload } = action

  switch (type) {
    case [actionsTypes.CLOSE_MODAL]: {
      return { ...state, ...reportState }
    }

    case [actionsTypes.SHOW_MODAL]: {
      console.log('On reducer')

      return {
        ...state,
        showModal: true,
        type: payload?.type,
        reportUrl: payload?.reportUrl,
        onComplete: payload?.onComplete
      }
    }

    default: {
      return state
    }
  }
}

export default reportReducer