apps/web/src/views/GuildView.vue (view raw)
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 |
<script setup lang="ts">
import { onMounted, ref } from "vue";
import { useRoute } from "vue-router";
import { client } from "@/stores/api";
const route = useRoute();
const guildId = route.params.guildId as string | undefined;
const stats = ref<{ mean: number; median: number; totalClosed: number }>({
mean: 0,
median: 0,
totalClosed: 0,
});
onMounted(async () => {
if (!guildId) return;
const res = await client.api.guilds({ guildId }).stats.overall.get();
if (res.status === 200 && res.data) stats.value = res.data;
});
const formatMs = (ms: number) => {
const secs = Math.floor(ms / 1000);
if (secs < 60) return `${secs}s`;
const mins = Math.floor(secs / 60);
if (mins < 60) return `${mins}m ${secs % 60}s`;
const hours = Math.floor(mins / 60);
if (hours < 24) return `${hours}h ${mins % 60}m`;
const days = Math.floor(hours / 24);
return `${days}d ${hours % 24}h`;
};
</script>
<template>
<div class="stats-row">
<div class="stat">
<span class="stat-label">Closed Tickets</span>
<span class="stat-value">{{ stats.totalClosed }}</span>
</div>
<div class="stat">
<span class="stat-label">Mean TTC</span>
<span class="stat-value">{{ formatMs(stats.mean) }}</span>
</div>
<div class="stat">
<span class="stat-label">Median TTC</span>
<span class="stat-value">{{ formatMs(stats.median) }}</span>
</div>
</div>
</template>
<style scoped>
.stats-row {
display: flex;
justify-content: space-between;
align-items: center;
flex-wrap: wrap;
gap: 0.5rem;
.stat {
flex: 1 1 250px;
display: flex;
flex-direction: column;
align-items: center;
background-color: hsl(var(--crust));
padding: 2.5rem 1.5rem;
border-radius: 1.5rem;
.stat-label {
font-size: 0.75rem;
font-weight: 900;
text-transform: uppercase;
color: hsl(var(--subtext0));
margin-bottom: 0.25rem;
}
.stat-value {
font-size: 3.5rem;
font-weight: 800;
line-height: 1;
color: hsl(var(--text));
}
}
}
</style>
|