From 0dd0e11763574bbd120c124c5585acbd01a6370e Mon Sep 17 00:00:00 2001 From: pjra99 Date: Mon, 13 Dec 2021 17:56:02 +0530 Subject: [PATCH 1/2] --fix: todo bug resolved --- src/components/Layout/EditTodoModal.js | 2 +- src/utils/services.js | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/components/Layout/EditTodoModal.js b/src/components/Layout/EditTodoModal.js index 1b46e42..dc3ea6f 100644 --- a/src/components/Layout/EditTodoModal.js +++ b/src/components/Layout/EditTodoModal.js @@ -104,7 +104,7 @@ const EditTodoModal = ({ handleEditTodo(e.target.value)} + onClick={e => handleEditTodo(data)} > Save diff --git a/src/utils/services.js b/src/utils/services.js index 0075d17..b8d83a3 100644 --- a/src/utils/services.js +++ b/src/utils/services.js @@ -342,7 +342,8 @@ export const updateTodo = async (id, data) => { export const editTodo = async (id, data) => { setUserToken(); try { - const response = await axios.put(`${UPDATE_TODO}/${id}`, data); + deleteTodo(id); + const response = await axios.post(ADD_TODO, data); if (response.status === 200 && response.data.error === false) { return response.data; } else return response.data; From d4d7980576c5fa17640d66685cb53583ef611a1c Mon Sep 17 00:00:00 2001 From: pjra99 Date: Mon, 13 Dec 2021 18:46:52 +0530 Subject: [PATCH 2/2] --fix: todo bug resolved --- src/components/Layout/EditTodoModal.js | 5 ++++- src/utils/services.js | 3 +-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/components/Layout/EditTodoModal.js b/src/components/Layout/EditTodoModal.js index dc3ea6f..9efd51b 100644 --- a/src/components/Layout/EditTodoModal.js +++ b/src/components/Layout/EditTodoModal.js @@ -46,7 +46,10 @@ const EditTodoModal = ({ const handleEditTodo = async data => { if (!data || data.length < 7) return; try { - const res = await editTodo(todo._id, { title: data }); + const res = await editTodo(todo._id, { + title: data, + status: todo.status + }); if (!res.error && res.message === "success") { handleVisible(!visible); setRefresh(!refresh); diff --git a/src/utils/services.js b/src/utils/services.js index b8d83a3..0075d17 100644 --- a/src/utils/services.js +++ b/src/utils/services.js @@ -342,8 +342,7 @@ export const updateTodo = async (id, data) => { export const editTodo = async (id, data) => { setUserToken(); try { - deleteTodo(id); - const response = await axios.post(ADD_TODO, data); + const response = await axios.put(`${UPDATE_TODO}/${id}`, data); if (response.status === 200 && response.data.error === false) { return response.data; } else return response.data;