From 4285674ab37c74a24b265ace4d15d4848457d375 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adri=C3=A1n=20Oliva?= Date: Mon, 29 May 2023 12:42:46 -0600 Subject: Pagination now works on to do's list. Only 10 to dos will be shown at a time. You can sort by priority or due date and it should work on all of our to dos. Edit and delete also works. --- src/ToDo-UI/ListToDo.jsx | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) (limited to 'src/ToDo-UI/ListToDo.jsx') diff --git a/src/ToDo-UI/ListToDo.jsx b/src/ToDo-UI/ListToDo.jsx index 781f4cd..d57642b 100644 --- a/src/ToDo-UI/ListToDo.jsx +++ b/src/ToDo-UI/ListToDo.jsx @@ -5,10 +5,10 @@ import { remove_todo, edit_todo, set_sort_todo, - sort_todo, - refresh_filtered_todos, select_todos, + select_current_filters, select_current_sorting, + select_current_page, } from "../features/todo/reducer"; import { @@ -18,6 +18,8 @@ import { set_undone_function, } from "../api/axios_methods"; +import { refresh_todos } from "../refreshToDos"; + function sort_table_header(prefix, current_sorting) { if (prefix.toLowerCase().startsWith(current_sorting.substr(0, 3))) { switch (current_sorting.substr(-1)) { @@ -49,7 +51,7 @@ function sort_table_header(prefix, current_sorting) { function list_of_todos(edit_button, delete_button) { const dispatch = useDispatch(); const my_todos = useSelector(select_todos); - const my_sorting = useSelector(select_current_sorting); + const my_sorters = useSelector(select_current_sorting); function handle_sort_todos(where_clicked) { dispatch( @@ -57,8 +59,6 @@ function list_of_todos(edit_button, delete_button) { where_clicked: where_clicked, }) ); - dispatch(sort_todo()); - dispatch(refresh_filtered_todos()); } const set_done_api = set_done_function(); @@ -79,7 +79,7 @@ function list_of_todos(edit_button, delete_button) { Done Name handle_sort_todos("priority")}> - {sort_table_header("Priority", my_sorting)} + {sort_table_header("Priority", my_sorters)} - {sort_table_header("Due Date", my_sorting)} + {sort_table_header("Due Date", my_sorters)} Actions @@ -115,7 +115,6 @@ function list_of_todos(edit_button, delete_button) { done: e.target.checked, }) ); - dispatch(refresh_filtered_todos()); }} > @@ -221,8 +220,6 @@ export function ListToDos() { priority: edit_priority, }) ); - dispatch(sort_todo()); - dispatch(refresh_filtered_todos()); handle_exit_modal(); } @@ -256,7 +253,6 @@ export function ListToDos() { onClick={(e) => { remove_todo_api({ id: item.id }); dispatch(remove_todo(item.id)); - dispatch(refresh_filtered_todos()); }} > Delete -- cgit v1.2.3