Fix account list and remove sanctum

This commit is contained in:
James Cole
2025-05-08 20:22:01 +02:00
parent ee96dd3ab6
commit 07ff2305fd
9 changed files with 73 additions and 44 deletions

View File

@@ -20,6 +20,7 @@
import {api} from "../../../../boot/axios";
import format from "date-fns/format";
import {getCacheKey} from "../../../../support/get-cache-key.js";
export default class Get {
@@ -37,6 +38,31 @@ export default class Get {
return api.get('/api/v1/accounts/' + identifier, {params: params});
}
/**
*
* @param params
* @returns {Promise<AxiosResponse<any>>}
*/
index(params) {
// first, check API in some consistent manner.
// then, load if necessary.
const cacheKey = getCacheKey('/api/v1/accounts', params);
const cacheValid = window.store.get('cacheValid');
let cachedData = window.store.get(cacheKey);
if (cacheValid && typeof cachedData !== 'undefined') {
console.log('Cache is valid, return cache.');
return Promise.resolve(cachedData);
}
// if not, store in cache and then return res.
return api.get('/api/v1/accounts', {params: params}).then(response => {
console.log('Cache is invalid, return fresh.');
window.store.set(cacheKey, response.data);
return Promise.resolve({data: response.data.data, meta: response.data.meta});
});
}
/**
*

View File

@@ -383,7 +383,8 @@ let index = function () {
// one page only.o
(new Get()).index(params).then(response => {
console.log(response);
this.totalPages = response.meta.lastPage;
this.totalPages = response.meta.pagination.total_pages;
console.log('a');
for (let i = 0; i < response.data.length; i++) {
if (response.data.hasOwnProperty(i)) {
let current = response.data[i];