From 8cb67965e363a9ea602a51d6bdee1c4d1e067c54 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Adri=C3=A1n=20Oliva?= <adrian.oliva@cimat.mx>
Date: Thu, 18 May 2023 13:53:06 -0600
Subject: Now we can change the done state.

---
 src/ToDo.jsx | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

(limited to 'src/ToDo.jsx')

diff --git a/src/ToDo.jsx b/src/ToDo.jsx
index f6eb68c..1dbfad7 100644
--- a/src/ToDo.jsx
+++ b/src/ToDo.jsx
@@ -2,6 +2,7 @@ import React, { useState } from "react";
 import { useSelector, useDispatch } from "react-redux";
 import {
     add_todo,
+    change_done,
     select_todos,
     select_last_index,
 } from "./features/todo/reducer";
@@ -186,6 +187,7 @@ export function NewToDo() {
 
 export function ListToDos() {
     const my_todos = useSelector(select_todos);
+    const dispatch = useDispatch();
 
     return (
         <div className="container">
@@ -209,7 +211,14 @@ export function ListToDos() {
                                         type="checkbox"
                                         checked={item.done}
                                         id="flexCheckChecked"
-                                        disabled
+                                        onChange={(e) =>
+                                            dispatch(
+                                                change_done({
+                                                    id: item.id,
+                                                    done: e.target.checked,
+                                                })
+                                            )
+                                        }
                                     ></input>
                                 </div>
                             </th>
-- 
cgit v1.2.3

