All files / src/components/common ApiLoader.vue

100% Statements 5/5
100% Branches 8/8
100% Functions 2/2
100% Lines 4/4

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                        17x       17x       30x       4x          
<script setup lang="ts">
import { useI18n } from 'vue-i18n'
import Skeleton from './Skeleton.vue'
import Empty from './Empty.vue'
import Button from './Button.vue'
 
defineProps<{
  loading: boolean
  error?: string | null
  empty?: boolean
}>()
 
const emit = defineEmits<{
  (e: 'retry'): void
}>()
 
const { t } = useI18n()
</script>
 
<template>
  <div>
    <Skeleton v-if="loading" />
    <div v-else-if="error" class="rounded-xl bg-red-50 p-4 text-sm text-red-700">
      <p>{{ t('common.error') }}: {{ error }}</p>
      <Button variant="secondary" class="mt-3" @click="emit('retry')">{{ t('common.retry') }}</Button>
    </div>
    <Empty v-else-if="empty" />
    <slot v-else />
  </div>
</template>