fix(ui): завершить локальную приёмку трафика и статистики

This commit is contained in:
Denozordec committed 2026-09-28 23:45:48 +07:00
1 parent 48b7a061c1
commit 165f40acd7
10 files changed
+130 -28

No files matched your search

+7 -2
View File
@@ -1,3 +1,4 @@
import { statisticsDtoSchema, statisticsPivotDtoSchema } from "@mmapp/contracts/statistics"
import type {
StatisticsDto,
StatisticsPivotDto,
@@ -23,7 +24,9 @@ export async function getStatistics(
if (query.service) params.set("service", query.service)
if (query.asn != null) params.set("asn", String(query.asn))
if (query.planes && query.planes !== "unique") params.set("planes", query.planes)
return requestJson<StatisticsDto>(baseUrl, `/api/statistics?${params.toString()}`)
const parsed = statisticsDtoSchema.safeParse(await requestJson<unknown>(baseUrl, `/api/statistics?${params.toString()}`))
if (!parsed.success) throw new Error("Некорректный ответ статистики")
return parsed.data
}
export async function getStatisticsPivot(
@@ -43,5 +46,7 @@ export async function getStatisticsPivot(
if (query.service) params.set("service", query.service)
if (query.asn != null) params.set("asn", String(query.asn))
if (query.planes && query.planes !== "unique") params.set("planes", query.planes)
return requestJson<StatisticsPivotDto>(baseUrl, `/api/statistics/pivot?${params.toString()}`)
const parsed = statisticsPivotDtoSchema.safeParse(await requestJson<unknown>(baseUrl, `/api/statistics/pivot?${params.toString()}`))
if (!parsed.success) throw new Error("Некорректный ответ сводной статистики")
return parsed.data
}