Skip to content

Commit

Permalink
➕ feat: CRUD
Browse files Browse the repository at this point in the history
  • Loading branch information
Linder Hassinger committed Apr 13, 2024
1 parent f3fae2d commit 9f78b8f
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 4 deletions.
9 changes: 7 additions & 2 deletions semana-9/todolist/src/App.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -70,15 +70,20 @@ export default function App() {
handleOpen("edit");
};

const handleCheckTask = (task) => {
const handleCheckTask = async (task) => {
const searchTask = listTasks.find((element) => element.id === task.id);
searchTask.status = 2;

await updateTask(searchTask);

handleOpen("check");
};

const handleDeleteTask = (task) => {
const handleDeleteTask = async (task) => {
const filteredTasks = listTasks.filter((element) => element.id !== task.id);

await deleteTask(task);

setListTask(filteredTasks);
handleOpen("delete");
};
Expand Down
2 changes: 1 addition & 1 deletion semana-9/todolist/src/components/CheckForm/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export default function CheckForm(props) {
No, estoy seguro
</button>
<button
onClick={() => props.handleCheckTask(props.currentTask)}
onClick={async () => await props.handleCheckTask(props.currentTask)}
className="bg-green-500 px-4 py-2 text-white rounded-md"
>
Si, estoy seguro
Expand Down
2 changes: 1 addition & 1 deletion semana-9/todolist/src/components/DeleteForm/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export default function DeleteForm(props) {
No, estoy seguro
</button>
<button
onClick={() => props.handleDeleteTask(props.currentTask)}
onClick={async () => await props.handleDeleteTask(props.currentTask)}
className="bg-green-500 px-4 py-2 text-white rounded-md"
>
Si, estoy seguro
Expand Down

0 comments on commit 9f78b8f

Please sign in to comment.