All files / src/views StatementDetailView.vue

0% Statements 0/13
0% Branches 0/4
0% Functions 0/2
0% Lines 0/13

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                                                                 
<script setup lang="ts">
import { onMounted, ref } from 'vue'
import { useRoute } from 'vue-router'
import ApiLoader from '@/components/common/ApiLoader.vue'
import StatementDetail from '@/components/feature/StatementDetail.vue'
import { fetchStatementDetail } from '@/api/modules/statement'
import type { StatementDetail as StatementDetailType } from '@/api/types'
 
const route = useRoute()
const loading = ref(true)
const error = ref<string | null>(null)
const detail = ref<StatementDetailType | null>(null)
 
async function load() {
  loading.value = true
  error.value = null
  try {
    detail.value = await fetchStatementDetail(String(route.params.id))
  } catch (e) {
    error.value = e instanceof Error ? e.message : 'error'
  } finally {
    loading.value = false
  }
}
 
onMounted(load)
</script>
 
<template>
  <ApiLoader :loading="loading" :error="error" @retry="load">
    <StatementDetail v-if="detail" :detail="detail" />
  </ApiLoader>
</template>