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];

View File

@@ -9,7 +9,7 @@
<div class="card">
<div class="card-header">
<h3 class="card-title">
<a :href="'{{ route('accounts.show', '') }}/' + account.id"
<a :href="'{{ route('accounts.show', '0') }}/' + account.id"
x-text="account.name"></a>
<span class="small">
@@ -42,7 +42,7 @@
<template x-if="group.transactions[0].type === 'transfer'">
<span class="text-muted fa-solid fa-arrows-rotate fa-fw"></span>
</template>
<a :href="'{{route('transactions.show', '') }}/' + group.id" x-text="group.title"></a><br/></span>
<a :href="'{{route('transactions.show', '0') }}/' + group.id" x-text="group.title"></a><br/></span>
</template>
<ul class="list-unstyled list-no-margin">
<template x-for="transaction in group.transactions">
@@ -61,7 +61,7 @@
<template x-if="transaction.type == 'transfer'">
<span class="text-muted fa-solid fa-arrows-rotate fa-fw"></span>
</template>
<a :href="'{{route('transactions.show', '') }}/' + group.id" x-text="transaction.description"></a>
<a :href="'{{route('transactions.show', '0') }}/' + group.id" x-text="transaction.description"></a>
</span>
</template>
</li>

View File

@@ -30,7 +30,7 @@
<template x-for="bill in group.bills">
<tr>
<td>
<a :href="'{{ route('subscriptions.show',['']) }}/' + bill.id" :title="bill.name">
<a :href="'{{ route('subscriptions.show',['0']) }}/' + bill.id" :title="bill.name">
<span x-text="bill.name"></span>
</a>
<template x-if="bill.paid">