feat: add enrichment columns to admin traffic usage table

Add 5 new columns (connected devices, spending, start/end dates, last node)
with progressive loading shimmer placeholders and 4-language translations.
This commit is contained in:
Fringg
2026-02-08 21:49:45 +03:00
parent 2dfa520604
commit 893c69ab6f
6 changed files with 192 additions and 7 deletions

View File

@@ -35,6 +35,18 @@ export interface ExportCsvResponse {
message: string;
}
export interface TrafficEnrichmentData {
devices_connected: number;
total_spent_kopeks: number;
subscription_start_date: string | null;
subscription_end_date: string | null;
last_node_name: string | null;
}
export interface TrafficEnrichmentResponse {
data: Record<number, TrafficEnrichmentData>;
}
export type TrafficParams = {
period?: number;
limit?: number;
@@ -69,6 +81,11 @@ function buildCacheKey(params: TrafficParams): string {
});
}
const enrichmentCache: { data: TrafficEnrichmentResponse | null; timestamp: number } = {
data: null,
timestamp: 0,
};
export const adminTrafficApi = {
getTrafficUsage: async (
params: TrafficParams,
@@ -104,6 +121,22 @@ export const adminTrafficApi = {
trafficCache.clear();
},
getEnrichment: async (options?: { skipCache?: boolean }): Promise<TrafficEnrichmentResponse> => {
if (
!options?.skipCache &&
enrichmentCache.data &&
Date.now() - enrichmentCache.timestamp < CACHE_TTL
) {
return enrichmentCache.data;
}
const response = await apiClient.get('/cabinet/admin/traffic/enrichment');
const data: TrafficEnrichmentResponse = response.data;
enrichmentCache.data = data;
enrichmentCache.timestamp = Date.now();
return data;
},
exportCsv: async (data: {
period: number;
start_date?: string;