feat(fc2a): add useApi composable, import store, extend system store with stats

useApi centralizes fetch error handling — every API call throws ApiError
on non-2xx with the parsed body attached, so components don't repeat the
'check response.ok' boilerplate.

import store wraps import settings, batch status, task list (with cursor
pagination), and the trigger/retry/clear admin actions. system store
gains a refreshStats() that powers the Settings overview tab.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-05-14 12:29:49 -04:00
parent e597a9300e
commit af9f42ef68
3 changed files with 170 additions and 4 deletions
+16 -4
View File
@@ -1,18 +1,30 @@
import { defineStore } from 'pinia'
import { ref } from 'vue'
import { useApi } from '../composables/useApi.js'
export const useSystemStore = defineStore('system', () => {
const api = useApi()
const healthy = ref(null) // null=unknown, true=ok, false=down
const stats = ref(null)
const statsLoading = ref(false)
async function refreshHealth() {
try {
const r = await fetch('/api/health')
const body = await r.json()
healthy.value = r.ok && body.status === 'ok'
const body = await api.get('/api/health')
healthy.value = body.status === 'ok'
} catch {
healthy.value = false
}
}
return { healthy, refreshHealth }
async function refreshStats() {
statsLoading.value = true
try {
stats.value = await api.get('/api/system/stats')
} finally {
statsLoading.value = false
}
}
return { healthy, stats, statsLoading, refreshHealth, refreshStats }
})