Proyectos de Subversion LeadersLinked - SPA

Rev

Rev 1644 | Rev 1647 | 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