aboutsummaryrefslogtreecommitdiff
path: root/src/features
diff options
context:
space:
mode:
authorAdrián Oliva <adrian.oliva@cimat.mx>2023-05-19 15:19:11 -0600
committerAdrián Oliva <adrian.oliva@cimat.mx>2023-05-19 15:19:11 -0600
commitff4cc46041251972634a28c1f780541fd105aadc (patch)
tree10ac8ed59e3729781604257830a3ce71c7f90dcc /src/features
parent8e274132e60b21277506df3c7b47e5f75518fb32 (diff)
downloadToDo-App-FE-ff4cc46041251972634a28c1f780541fd105aadc.tar.gz
ToDo-App-FE-ff4cc46041251972634a28c1f780541fd105aadc.zip
Edit button almost done.
Noticed some bugs. Will patch on later commits.
Diffstat (limited to '')
-rw-r--r--src/features/todo/reducer.js15
1 files changed, 14 insertions, 1 deletions
diff --git a/src/features/todo/reducer.js b/src/features/todo/reducer.js
index f12f740..a13810b 100644
--- a/src/features/todo/reducer.js
+++ b/src/features/todo/reducer.js
@@ -36,10 +36,23 @@ export const todo_slice = createSlice({
(todo) => todo.id != action.payload
);
},
+
+ edit_todo: (state, action) => {
+ let selected_todo = state.todos.findIndex(
+ (x) => x.id == action.payload.id
+ );
+ if (selected_todo == -1) return;
+
+ state.todos[selected_todo].text = action.payload.text;
+ state.todos[selected_todo].due_date = action.payload.due_date;
+ state.todos[selected_todo].done = action.payload.done;
+ state.todos[selected_todo].priority = action.payload.priority;
+ },
},
});
-export const { add_todo, change_done, remove_todo } = todo_slice.actions;
+export const { add_todo, change_done, remove_todo, edit_todo } =
+ todo_slice.actions;
export const select_todos = (state) => state.todo_list.todos;
export const select_last_index = (state) => state.todo_list.last_id;