add: pagination to locations

This commit is contained in:
Alexandro Uc Santos
2024-02-03 19:30:17 -06:00
parent a3da672ed6
commit 1933603692
4 changed files with 139 additions and 6 deletions

View File

@@ -10,6 +10,8 @@ export const useCompanyStore = defineStore('company', () => {
const users = ref([]);
const budgets = ref([]);
const locations = ref([]);
const locationsTotal = ref(0);
const locationsCurrentPage = ref(1);
const proposals = ref([])
const loading = ref(false);
@@ -239,6 +241,7 @@ export const useCompanyStore = defineStore('company', () => {
console.log(resp);
if(resp !== null && resp.total > 0) {
locations.value = resp.data;
locationsTotal.value = resp.total;
} else {
locations.value = [];
}
@@ -248,10 +251,11 @@ export const useCompanyStore = defineStore('company', () => {
const createLocationCompany = async(formData, localData) => {
const data = await createLocation(formData);
if(data) {
locations.value.push({
locations.value.unshift({
...data,
...localData
});
locationsTotal.value++;
return 'success';
} else {
return 'Algo salio mal, intente más tarde';
@@ -306,6 +310,8 @@ export const useCompanyStore = defineStore('company', () => {
budgets,
users,
locations,
locationsTotal,
locationsCurrentPage,
clear,
$reset,
loading,