import * as actionTypes from '../../../constants/admin'; import initialState from '../../initialState'; export default function topic(state = initialState.topicId, {payload, type, error}) { switch (type) { // payload.type -> type case actionTypes.CREATE_TOPICS_REQUEST: { return { ...state, isFetching: true, // payload } } case actionTypes.CREATE_TOPICS_REQUEST_SUCCESS: { const {data:{topic}}=payload return { ...state, isFetching: false, topic } } case actionTypes.CREATE_TOPICS_REQUEST_FAILURE: { return { ...state, isFetching: false, error } } default: { return state; } } }