Rev 1151 | AutorÃa | Comparar con el anterior | Ultima modificación | Ver Log |
import { TOPIC_ACTIONS } from './topics.types';const initialState = {topicsAllIds: [],topicById: {},capsulesAllIds: [],capsuleById: {},slidesAllIds: [],slideById: {}};const topicsReducer = (state = initialState, { type, payload }) => {switch (type) {case TOPIC_ACTIONS.ADD_TOPIC: {const topic = payload;const topicsIds = new Set([...state.topicsAllIds, topic.uuid]);return {...state,topicById: {...state.topicById,[topic.uuid]: topic},topicsAllIds: Array.from(topicsIds)};}case TOPIC_ACTIONS.ADD_CAPSULE: {const capsule = payload;const capsulesIds = new Set([...state.capsulesAllIds, capsule.uuid]);return {...state,capsuleById: {...state.capsuleById,[capsule.uuid]: capsule},capsulesAllIds: Array.from(capsulesIds)};}case TOPIC_ACTIONS.ADD_SLIDE: {const slide = payload;const slidesIds = new Set([...state.slidesAllIds, slide.uuid]);return {...state,slideById: {...state.slideById,[slide.uuid]: slide},slidesAllIds: Array.from(slidesIds)};}default:return state;}};export default topicsReducer;