Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 | <script setup lang="ts">
import { onMounted, ref } from 'vue'
import { useRouter } from 'vue-router'
import ApiLoader from '@/components/common/ApiLoader.vue'
import StatementList from '@/components/feature/StatementList.vue'
import { fetchStatements } from '@/api/modules/statement'
import type { Statement } from '@/api/types'
const router = useRouter()
const loading = ref(true)
const error = ref<string | null>(null)
const statements = ref<Statement[]>([])
async function load() {
loading.value = true
error.value = null
try {
statements.value = await fetchStatements()
} catch (e) {
error.value = e instanceof Error ? e.message : 'error'
} finally {
loading.value = false
}
}
function goDetail(id: string) {
router.push(`/statement/${id}`)
}
onMounted(load)
</script>
<template>
<ApiLoader :loading="loading" :error="error" :empty="!loading && !error && statements.length === 0" @retry="load">
<StatementList :statements="statements" @select="goDetail" />
</ApiLoader>
</template> |