atlp-rwanda/atlp-devpulse-fn

View on GitHub
src/redux/reducers/singleBlogReducer.ts

Summary

Maintainability
A
0 mins
Test Coverage
import { FETCH_SINGLE_BLOG_FAIL, FETCH_SINGLE_BLOG_SUCCESS } from "../index";

const initialState = {
  isLoading: true,
  isLoaded: false,
  errors: null,
  data: {},
};

export default (state = initialState, { type, payload }: any) => {
  switch (type) {
    case FETCH_SINGLE_BLOG_SUCCESS:
      return {
        ...state,
        isLoading: false,
        data: payload,
      };

    case FETCH_SINGLE_BLOG_FAIL:
      return {
        ...state,
        isLoading: false,
        isLoaded: true,
        error: true,
      };

    default:
      return state;
  }
};