'use strict';
import { FETCH_CLOUDINARY_IMAGES } from '../actions/types';


export default function cloudinaryImageStore(state = [], action = null) {
  switch (action.type) {

    case FETCH_CLOUDINARY_IMAGES:
      console.log(`Action <${action.type}> executed with payload`, action.payload);
      return action.payload.resources;

    default:
      console.log(`Action <${action.type}> executed with payload`, action.payload);
      return state;

  }
};

@@ -39,16 +39,24 @@
 Y_IMAGES
+_SUCCESS
  %7D from 
@@ -75,16 +75,16 @@
 types';%0A
-
 %0A%0Aexport
@@ -209,16 +209,24 @@
 Y_IMAGES
+_SUCCESS
 :%0A      
@@ -313,39 +313,538 @@
     
-return action.payload.resources
+const %7B subfolderNames, tlImages %7D = action.payload;%0A      console.log('SUB-FOLDERNAMES:', subfolderNames, tlImages);%0A      let foldersObj = subfolderNames.reduce((memo, curr) =%3E %7B%0A        const regTest = new RegExp(%60%5E$%7Bcurr.path%7D%60),%0A              images = tlImages.filter(img =%3E regTest.test(img.public_id));%0A        memo%5Bcurr.name%5D = Object.assign(%7B%7D, curr, %7B images %7D);%0A        return memo;%0A      %7D, %7B%7D);%0A      let newState = Object.assign(%7B%7D, state, foldersObj);%0A      console.log('newState:', newState);%0A      return newState
 ;%0A%0A 

refactor (Reducer): Rewrite case statement to handle more complex data payload