diff options
author | Adrián Oliva <adrian.oliva@cimat.mx> | 2023-05-29 18:28:55 -0600 |
---|---|---|
committer | Adrián Oliva <adrian.oliva@cimat.mx> | 2023-05-29 18:28:55 -0600 |
commit | daee56ba5509a4576fa066adfcc0d1bc05f98802 (patch) | |
tree | 0c0fd7ebb94ca5c4ad82dbea16ba2b58e91900a2 /src/ToDo-UI | |
parent | 4285674ab37c74a24b265ace4d15d4848457d375 (diff) | |
download | ToDo-App-FE-daee56ba5509a4576fa066adfcc0d1bc05f98802.tar.gz ToDo-App-FE-daee56ba5509a4576fa066adfcc0d1bc05f98802.zip |
Adding new to dos is now synchronized with database.
Changed the `refreshToDos` to also refresh the last index used.
Diffstat (limited to 'src/ToDo-UI')
-rw-r--r-- | src/ToDo-UI/NewToDo.jsx | 28 |
1 files changed, 12 insertions, 16 deletions
diff --git a/src/ToDo-UI/NewToDo.jsx b/src/ToDo-UI/NewToDo.jsx index dc062db..313456b 100644 --- a/src/ToDo-UI/NewToDo.jsx +++ b/src/ToDo-UI/NewToDo.jsx @@ -1,14 +1,16 @@ import React, { useState } from "react"; import { useSelector, useDispatch } from "react-redux"; import { - add_todo, - sort_todo, - refresh_filtered_todos, select_last_index, + select_current_filters, + select_current_sorting, + select_current_page, } from "../features/todo/reducer"; import { new_todo_function } from "../api/axios_methods"; +import { refresh_todos } from "../refreshToDos"; + function new_button(trigger_id) { return ( <div className="container mt-3 mb-3"> @@ -46,6 +48,10 @@ export function NewToDo() { const [new_due_date, set_new_due_date] = useState(""); const [new_priority, set_new_priority] = useState("Low"); + const my_filters = useSelector(select_current_filters); + const my_sorters = useSelector(select_current_sorting); + const my_curr_page = useSelector(select_current_page); + const new_todo_api = new_todo_function(); function handle_exit_modal() { @@ -65,19 +71,9 @@ export function NewToDo() { : new Date(new_due_date).toISOString(), priority: new_priority, }); - dispatch( - add_todo({ - text: new_text, - due_date: - new_due_date.length == 0 - ? "" - : new Date(new_due_date).toISOString(), - priority: new_priority, - creation_date: new Date().toISOString(), - }) - ); - dispatch(sort_todo()); - dispatch(refresh_filtered_todos()); + setTimeout(() => { + refresh_todos(my_filters, my_sorters, my_curr_page, dispatch); + }, 100); handle_exit_modal(); } |