aboutsummaryrefslogtreecommitdiff
path: root/src/api
diff options
context:
space:
mode:
authorAdrián Oliva <adrian.oliva@cimat.mx>2023-05-29 00:28:38 -0600
committerAdrián Oliva <adrian.oliva@cimat.mx>2023-05-29 00:28:38 -0600
commitc95dbbbf5080cf144e07a134c3e30668085d2e41 (patch)
treec580e22b66dec4db2e5a6adc8e9e8007dd46432b /src/api
parent8aa1fddb3e1a3b010f7172c3e8965f8a844d2227 (diff)
downloadToDo-App-FE-c95dbbbf5080cf144e07a134c3e30668085d2e41.tar.gz
ToDo-App-FE-c95dbbbf5080cf144e07a134c3e30668085d2e41.zip
First instance for pagination.
Sorting and Filtering now WON'T be computed on Front End, but on Back End instead.
Diffstat (limited to '')
-rw-r--r--src/api/axios_methods.js49
1 files changed, 49 insertions, 0 deletions
diff --git a/src/api/axios_methods.js b/src/api/axios_methods.js
index f983157..822c334 100644
--- a/src/api/axios_methods.js
+++ b/src/api/axios_methods.js
@@ -87,6 +87,55 @@ export function set_undone_function() {
};
}
+// setFiltersAndSorters().
+export function set_fil_sort_function() {
+ // Set filters and sorters for our to dos.
+ // POST "/todos/setFiltSort"
+ return async (data) => {
+ try {
+ await api.post("/todos/setFiltSort", {
+ filters: {
+ name: data.filter.name,
+ priority: data.filter.priority,
+ done: data.filter.state,
+ },
+ sortField: data.sort.field,
+ sortOrder: data.sort.order,
+ });
+ } catch (err) {
+ console.log(err);
+ }
+ };
+}
+
+// getPage().
+export function get_todos_page_function() {
+ // Return a page of max 10 to dos with sorting and filters added.
+ // GET "/todos/filtSort/{page}"
+ return async (handler, data) => {
+ try {
+ const response = await api.get(`/todos/filtSort/${data.page}`);
+ handler(response.data);
+ } catch (err) {
+ console.log(err);
+ }
+ };
+}
+
+// getNumberOfPages().
+export function get_nu_pages_function() {
+ // Return the number of pages in total.
+ // GET "/todos/filtSort/pages"
+ return async () => {
+ try {
+ const response = await api.get("/todos/filtSort/pages");
+ return response.data;
+ } catch (err) {
+ console.log(err);
+ }
+ };
+}
+
// giveMeLastID().
export function get_last_id_function() {
// Retrieve last index used.