Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 12 additions & 14 deletions src/components/Home/Home.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,23 +30,21 @@ const Home = () => {
}

function updateTitle(updatedId, updatedTitle) {
const update = tasks.map(item => {
if (item.id === updatedId) {
item.title = updatedTitle;
}
return item;
});
updateTasks(update);
const index = tasks.findIndex(item => item.id === updatedId);
if (index !== -1) {
const update = [...tasks];
update[index].title = updatedTitle;
updateTasks(update);
}
}

function updateStatus(updatedId, status) {
const update = tasks.map(item => {
if (item.id === updatedId) {
item.completed = status;
}
return item;
});
updateTasks(update);
const index = tasks.findIndex(item => item.id === updatedId);
if (index !== -1) {
const update = [...tasks];
update[index].completed = status;
updateTasks(update);
}
}

return (
Expand Down