diff options
author | Adrián Oliva <adrian.oliva@cimat.mx> | 2023-05-27 14:16:12 -0600 |
---|---|---|
committer | Adrián Oliva <adrian.oliva@cimat.mx> | 2023-05-27 14:16:12 -0600 |
commit | e04bff29bf8146bb709a76fc187e0683065e4f03 (patch) | |
tree | acb7a81dd4d362f3bdac09e0d3e5723d413a5c67 /src/App.jsx | |
parent | 5fc5f300463f606c948ec10fc5554e3c60a8ec36 (diff) | |
download | ToDo-App-FE-e04bff29bf8146bb709a76fc187e0683065e4f03.tar.gz ToDo-App-FE-e04bff29bf8146bb709a76fc187e0683065e4f03.zip |
List of to dos is initialized on database.
At the beginning, the app will fetch the to dos from the back end and
write all of them on Redux.
Diffstat (limited to '')
-rw-r--r-- | src/App.jsx | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/src/App.jsx b/src/App.jsx index a77c0d2..8397a9f 100644 --- a/src/App.jsx +++ b/src/App.jsx @@ -3,7 +3,32 @@ import { Search } from "./ToDo-UI/Search"; import { NewToDo } from "./ToDo-UI/NewToDo"; import { ListToDos } from "./ToDo-UI/ListToDo"; +import { useDispatch } from "react-redux"; +import { set_todo, refresh_filtered_todos } from "./features/todo/reducer"; + +import { get_todos_function } from "./api/axios_methods"; + function App() { + const get_todos = get_todos_function(); + + const dispatch = useDispatch(); + function handler(data) { + data.map((todo) => { + dispatch( + set_todo({ + id: todo.id, + text: todo.text, + due_date: todo.dueDate.substring(0, 16), + done: todo.done, + priority: todo.priority, + creation_date: todo.creationDate, + }) + ); + }); + dispatch(refresh_filtered_todos()); + } + get_todos(handler); + return ( <div> <Search /> |