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 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 | 7x 6x 2x 2x 2x 2x 7x 2x 2x 2x 2x 2x 2x 2x 7x 7x 7x | <template>
<div class="credits-usage-breakdown" data-testid="credits-usage-breakdown">
<p v-if="!usageDay || usageDay.breakdown.length === 0" class="text-muted small mb-0">
{{ t('credits.breakdownEmpty') }}
</p>
<template v-else>
<div
v-for="group in grouped.flows"
:key="group.flowId ?? ''"
class="usage-flow"
data-testid="credits-usage-flow"
>
<div class="usage-line fw-semibold">
<span class="text-truncate">{{ flowLabel(group.flowId) }}</span>
<span class="usage-figures">
{{ callsLabel(group.events) }}
<span class="usage-credits">{{ creditsShare(group.credits) }}</span>
</span>
</div>
<div
v-for="(line, index) in group.lines"
:key="index"
class="usage-line usage-function small"
>
<span class="text-truncate">
{{ functionLabel(line) }}
<span v-if="line.viaApiKey" class="badge bg-secondary ms-1">
{{ t('credits.viaApiKey') }}
</span>
</span>
<span class="usage-figures text-muted">
{{ callsLabel(line.events) }}
<span class="usage-credits">{{ creditsShare(line.credits) }}</span>
</span>
</div>
</div>
<div v-if="grouped.other" class="usage-flow">
<div class="usage-line small">
<span>{{ format('credits.otherLines', { count: grouped.other.count ?? 0 }) }}</span>
<span class="usage-figures text-muted">
{{ callsLabel(grouped.other.events) }}
<span class="usage-credits">{{ creditsShare(grouped.other.credits) }}</span>
</span>
</div>
</div>
<p class="text-muted small mb-0 mt-2">{{ t('credits.breakdownNote') }}</p>
</template>
</div>
</template>
<script setup lang="ts">
// @implements UC-CREDITS-011.1
import { computed } from 'vue'
import type { CreditsUsageDay } from '@/stores/credits'
import { groupUsageByFlow } from '@/utils/creditsHistory'
import { useCreditsLabels } from '@/composables/useCreditsLabels'
const props = defineProps<{
/** Undefined when the API has no detail for the day (older than 90 days) */
usageDay: CreditsUsageDay | undefined
}>()
const { t, format, flowLabel, functionLabel, callsLabel, creditsShare } = useCreditsLabels()
const grouped = computed(() => groupUsageByFlow(props.usageDay?.breakdown ?? []))
</script>
<style scoped>
.credits-usage-breakdown {
border-top: 1px solid var(--bs-border-color, #dee2e6);
padding: 0.75rem 1rem 1rem;
}
.usage-flow + .usage-flow {
margin-top: 0.75rem;
}
.usage-line {
display: flex;
justify-content: space-between;
gap: 1rem;
min-width: 0;
}
.usage-function {
padding-left: 1rem;
}
.usage-figures {
flex-shrink: 0;
white-space: nowrap;
}
.usage-credits {
display: inline-block;
min-width: 4.5rem;
text-align: right;
}
</style>
|