import {
    CRUD_GET_LIST_SUCCESS,
    CRUD_DELETE_SUCCESS,
} from '../../../../actions/dataActions';

export default resource => (
    previousState = [],
    { type, payload, requestPayload, meta }
) => {
    if (!meta || meta.resource !== resource) {
        return previousState;
    }
    switch (type) {
        case CRUD_GET_LIST_SUCCESS:
            return payload.data.map(record => record.id);
        case CRUD_DELETE_SUCCESS: {
            const index = previousState
                .map(el => el == requestPayload.id) // eslint-disable-line eqeqeq
                .indexOf(true);
            if (index === -1) {
                return previousState;
            }
            return [
                ...previousState.slice(0, index),
                ...previousState.slice(index + 1),
            ];
        }
        default:
            return previousState;
    }
};

export const getIds = state => state;

import {
    CRUD_GET_LIST_SUCCESS,
    CRUD_DELETE_SUCCESS,
} from '../../../../actions/dataActions';

export default resource => (
    previousState = [],
    { type, payload, requestPayload, meta }
) => {
    if (!meta || meta.resource !== resource) {
        return previousState;
    }
    switch (type) {
        case CRUD_GET_LIST_SUCCESS:
            return payload.data.map(record => record.id);
        case CRUD_DELETE_SUCCESS: {
            const index = previousState.findIndex(
                el => el == requestPayload.id
            ); // eslint-disable-line eqeqeq
            if (index === -1) {
                return previousState;
            }
            return [
                ...previousState.slice(0, index),
                ...previousState.slice(index + 1),
            ];
        }
        default:
            return previousState;
    }
};

export const getIds = state => state;

--- 
+++ 
@@ -14,9 +14,9 @@
         case CRUD_GET_LIST_SUCCESS:
             return payload.data.map(record => record.id);
         case CRUD_DELETE_SUCCESS: {
-            const index = previousState.findIndex(
-                el => el == requestPayload.id
-            ); // eslint-disable-line eqeqeq
+            const index = previousState
+                .map(el => el == requestPayload.id) // eslint-disable-line eqeqeq
+                .indexOf(true);
             if (index === -1) {
                 return previousState;
             }
Fix delete reducer on IE11

Closes #1036
