aboutsummaryrefslogtreecommitdiff
path: root/src/features/todo/reducer.js
diff options
context:
space:
mode:
authorAdrián Oliva <adrian.oliva@cimat.mx>2023-05-18 13:59:48 -0600
committerAdrián Oliva <adrian.oliva@cimat.mx>2023-05-18 13:59:48 -0600
commit8e274132e60b21277506df3c7b47e5f75518fb32 (patch)
treef7cd47d25cd7071f4e56de61486d65690476ae2d /src/features/todo/reducer.js
parent8cb67965e363a9ea602a51d6bdee1c4d1e067c54 (diff)
downloadToDo-App-FE-8e274132e60b21277506df3c7b47e5f75518fb32.tar.gz
ToDo-App-FE-8e274132e60b21277506df3c7b47e5f75518fb32.zip
Added remove action.
Diffstat (limited to '')
-rw-r--r--src/features/todo/reducer.js8
1 files changed, 7 insertions, 1 deletions
diff --git a/src/features/todo/reducer.js b/src/features/todo/reducer.js
index daba8bc..f12f740 100644
--- a/src/features/todo/reducer.js
+++ b/src/features/todo/reducer.js
@@ -30,10 +30,16 @@ export const todo_slice = createSlice({
state.todos[selected_todo].done = action.payload.done;
},
+
+ remove_todo: (state, action) => {
+ state.todos = state.todos.filter(
+ (todo) => todo.id != action.payload
+ );
+ },
},
});
-export const { add_todo, change_done } = todo_slice.actions;
+export const { add_todo, change_done, remove_todo } = todo_slice.actions;
export const select_todos = (state) => state.todo_list.todos;
export const select_last_index = (state) => state.todo_list.last_id;