Add pagination for booksearch
This commit is contained in:
@@ -18,23 +18,20 @@ const offset = computed(() => (pageNumber.value - 1) * limit);
|
||||
|
||||
let currentFilterState = ref(FilterStates.READ);
|
||||
|
||||
let data;
|
||||
let error;
|
||||
let totalBooksData;
|
||||
let errorFetchTotal;
|
||||
let data = ref(null);
|
||||
let error = ref(null);
|
||||
let totalBooksData = ref(null);
|
||||
let errorFetchTotal = ref(null);
|
||||
|
||||
let totalBooksNumber = computed(() => totalBooksData ? totalBooksData.value["count"] : 0);
|
||||
let totalBooksNumber = computed(() => (typeof(totalBooksData) != 'undefined' &&
|
||||
totalBooksData.value != null) ? totalBooksData.value["count"] : 0);
|
||||
let pageTotal = computed(() => Math.ceil(totalBooksNumber.value / limit))
|
||||
|
||||
fetchData();
|
||||
|
||||
function fetchData() {
|
||||
let res = getMyBooks(currentFilterState.value, limit, offset.value);
|
||||
data = res.data;
|
||||
error = res.error;
|
||||
let resCount = getCountMyBooks(currentFilterState.value);
|
||||
totalBooksData = resCount.data;
|
||||
|
||||
let res = getMyBooks(data, error, currentFilterState.value, limit, offset.value);
|
||||
let resCount = getCountMyBooks(totalBooksData, errorFetchTotal, currentFilterState.value);
|
||||
}
|
||||
|
||||
function onFilterButtonClick(newstate) {
|
||||
@@ -48,7 +45,7 @@ function computeDynamicClass(state) {
|
||||
|
||||
function pageChange(newPageNumber) {
|
||||
pageNumber.value = newPageNumber;
|
||||
data.value = null
|
||||
data.value = null;
|
||||
fetchData();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user