From 3295f5707068584a7fa1ba0eb6459e6f63bfadac Mon Sep 17 00:00:00 2001 From: MoonTestUse1 Date: Wed, 1 Jan 2025 21:17:01 +0600 Subject: [PATCH] =?UTF-8?q?=D0=9F=D0=BE=D1=87=D0=B8=D0=BD=D0=BA=D0=B0=20ad?= =?UTF-8?q?m7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- frontend/src/composables/useStatistics.ts | 28 +++++++++++----------- frontend/src/views/admin/DashboardView.vue | 8 ++++--- 2 files changed, 19 insertions(+), 17 deletions(-) diff --git a/frontend/src/composables/useStatistics.ts b/frontend/src/composables/useStatistics.ts index 05baba1..d1075cc 100644 --- a/frontend/src/composables/useStatistics.ts +++ b/frontend/src/composables/useStatistics.ts @@ -1,30 +1,30 @@ -import { ref, computed } from 'vue'; -import type { Statistics, StatisticCard } from '@/types/statistics'; +import { ref } from 'vue'; + +interface StatisticCard { + period: string; + label: string; + value: number | string; +} export function useStatistics() { - const statistics = ref(null); - - const statisticsCards = computed(() => { - if (!statistics.value) return []; - return [ - { period: 'total', label: 'Всего заявок', value: statistics.value.totalRequests }, - { period: 'resolved', label: 'Решено', value: statistics.value.resolvedRequests }, - { period: 'avgTime', label: 'Среднее время', value: statistics.value.averageResolutionTime } - ]; - }); + const statisticsCards = ref([]); const fetchStatistics = async () => { try { const response = await fetch('/api/admin/statistics?period=week'); if (!response.ok) throw new Error('Failed to fetch statistics'); - statistics.value = await response.json(); + const data = await response.json(); + statisticsCards.value = [ + { period: 'total', label: 'Всего заявок', value: data.totalRequests }, + { period: 'resolved', label: 'Решено', value: data.resolvedRequests }, + { period: 'avgTime', label: 'Среднее время', value: data.averageResolutionTime } + ]; } catch (error) { console.error('Error fetching statistics:', error); } }; return { - statistics, statisticsCards, fetchStatistics }; diff --git a/frontend/src/views/admin/DashboardView.vue b/frontend/src/views/admin/DashboardView.vue index 8938b5d..575a300 100644 --- a/frontend/src/views/admin/DashboardView.vue +++ b/frontend/src/views/admin/DashboardView.vue @@ -1,3 +1,4 @@ +```vue \ No newline at end of file + +``` \ No newline at end of file