X
X
X0lera2019-06-24 12:22:43
redux
X0lera, 2019-06-24 12:22:43

How to delete?

How to delete board, list, todo.

const initialState = {
  boards: {
    byId: {
      [ 45455 ]: {
        id: 45455,
        title: 'Дела',
        listsIds: [ 34444 ]
      }
    },
    allIds: [ 45455 ]
  },
  lists: {
    byId: {
      [ 34444 ]: {
        id: 34444,
        title: 'Тесты',
        todosIds: [ 5555 ]
      }
    },
    allIds: [ 34444 ]
  },
  todos: {
    byId: {
      [ 5555 ]: {
        id: 5555,
        title: 'Открыть',
        active: true
      }
    },
    allIds: [ 5555 ]
  }
};

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Anton Spirin, 2019-06-27
@X0lera

case DELETE_SOME_BY_ID:
  const byId = { ...state.some.byId };
  delete byId[action.payload.id];
  const allIdis = state.some.allIdis.filter(el => el.id != action.payload.id);

  return {
     ...state,
    some: {
      byId,
      allIds,
    },
  };

It's clear that, in your case, before deleting the board, you need to go through all the nested lists and tasks and delete them.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question