add: pagination to loads public & calculator

This commit is contained in:
Alexandro Uc Santos
2024-02-09 21:32:57 -06:00
parent 3018a95a59
commit e648c2ff53
5 changed files with 86 additions and 7 deletions

View File

@@ -4,6 +4,8 @@ import api from "../lib/axios";
export default function useSearchLoads() {
const loads = ref([]);
const loading = ref(false);
const total = ref(0);
const currentPage = ref(1);
const getLoadsPublished = async(filterQuery) => {
loading.value = true;
@@ -14,12 +16,14 @@ export default function useSearchLoads() {
filterStr = "?"+cleanfilterArr.join("&");
}
try {
const endpoint = `/loads/${filterStr}`;
const endpoint = `/loads/${filterStr}&$sort%5BcreatedAt%5D=-1`;
const {data} = await api.get(endpoint);
console.log(data);
total.value = data.total;
loads.value = data.data;
} catch (error) {
loads.value = [];
total.value = 0;
console.log(error);
}
loading.value = false;
@@ -28,6 +32,8 @@ export default function useSearchLoads() {
return {
getLoadsPublished,
loading,
loads
loads,
total,
currentPage,
}
}