add: pagination of users

This commit is contained in:
Alexandro Uc Santos
2024-02-05 21:26:57 -06:00
parent 1933603692
commit 2df3bcfcfb
10 changed files with 139 additions and 39 deletions

View File

@@ -19,7 +19,7 @@ import Pagination from '../components/Pagination.vue';
getInitData();
})
const limit = 10;
const limit = 3;
const getInitData = async() => {
loading.value = true;

View File

@@ -4,6 +4,7 @@
import CardUser from '../components/CardUser.vue';
import { useCompanyStore } from '../stores/company';
import CreateUserModal from '../components/CreateUserModal.vue';
import Pagination from '../components/Pagination.vue';
const companyStore = useCompanyStore();
@@ -13,11 +14,20 @@
const currentUser = ref(null);
const openModal = ref(false);
const limit = 3;
const getInitData = async() => {
console.log('callll')
loading.value = true;
await companyStore.getUsersCompany();
await companyStore.getUsersCompany(limit);
loading.value = false;
}
const getUsersByPage = async(data) => {
console.log(data)
loading.value = true;
companyStore.usersCurrentPage = data.page
await companyStore.getUsersCompany(limit, data.skip, true);
loading.value = false;
}
@@ -61,6 +71,12 @@
:readonly="false"
@set-user="handleSetCurrentUser(user)"
/>
<Pagination
:limit="limit"
:total="companyStore.usersTotal"
:current-page="companyStore.usersCurrentPage"
@get-elements="getUsersByPage"
/>
</div>
</div>
</template>

View File

@@ -28,7 +28,7 @@
loading.value = true;
filterQuery.value.company = "company="+ localStorage.getItem('id');
await vehicleStore.fetchVehicles(filterQuery.value, false);
await companyStore.getUsersCompany();
await companyStore.getDrivers();
loading.value = false;
}