From ebb75b93e85416de5c760fe7ba39f14d92c9e732 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Adri=C3=A1n=20Oliva?= <adrian.oliva@cimat.mx>
Date: Fri, 19 May 2023 20:52:06 -0600
Subject: Finished details on sorting.

Now it sorts after events like "adding new to do" and "edit a to do."
---
 src/ToDo.jsx | 25 ++++++++++++++++---------
 1 file changed, 16 insertions(+), 9 deletions(-)

(limited to 'src/ToDo.jsx')

diff --git a/src/ToDo.jsx b/src/ToDo.jsx
index 1f290ab..79d6903 100644
--- a/src/ToDo.jsx
+++ b/src/ToDo.jsx
@@ -5,6 +5,7 @@ import {
     change_done,
     remove_todo,
     edit_todo,
+    set_sort_todo,
     sort_todo,
     select_todos,
     select_last_index,
@@ -168,7 +169,8 @@ export function NewToDo() {
                                                 new Date().toString(),
                                         })
                                     ),
-                                        handle_exit_modal();
+                                        dispatch(sort_todo());
+                                    handle_exit_modal();
                                 }}
                                 data-bs-dismiss="modal"
                             >
@@ -245,23 +247,27 @@ export function ListToDos() {
                             <th scope="col">Name</th>
                             <th
                                 scope="col"
-                                onClick={(e) =>
+                                onClick={(e) => {
                                     dispatch(
-                                        sort_todo({
+                                        set_sort_todo({
                                             where_clicked: "priority",
                                         })
-                                    )
-                                }
+                                    ),
+                                        dispatch(sort_todo());
+                                }}
                             >
                                 {sort_table_header("Priority", my_sorting)}
                             </th>
                             <th
                                 scope="col"
-                                onClick={(e) =>
+                                onClick={(e) => {
                                     dispatch(
-                                        sort_todo({ where_clicked: "due_date" })
-                                    )
-                                }
+                                        set_sort_todo({
+                                            where_clicked: "due_date",
+                                        })
+                                    ),
+                                        dispatch(sort_todo());
+                                }}
                             >
                                 {sort_table_header("Due Date", my_sorting)}
                             </th>
@@ -454,6 +460,7 @@ export function ListToDos() {
                                             priority: edit_priority,
                                         })
                                     ),
+                                        dispatch(sort_todo()),
                                         handle_exit_modal();
                                 }}
                                 data-bs-dismiss="modal"
-- 
cgit v1.2.3

