diff --git a/src/pages/learning/DataPages.tsx b/src/pages/learning/DataPages.tsx
index b47ca33..653262c 100644
--- a/src/pages/learning/DataPages.tsx
+++ b/src/pages/learning/DataPages.tsx
@@ -1,5 +1,5 @@
import { useState } from 'react';
-import { Table, Card, Input, Select, Space, Tag, Descriptions, Button, message, Spin, Alert, Tabs } from 'antd';
+import { Table, Input, Select, Space, Tag, Button, Tabs } from 'antd';
import { useQuery } from '@tanstack/react-query';
import { learningAdminAPI } from '../../services/learningAdmin';
@@ -171,7 +171,7 @@ export function AnomalyPage() {
export function UserDiagnosePage() {
const [userId, setUserId] = useState('');
- const { data, isLoading, refetch } = useQuery({
+ const { data, refetch } = useQuery({
queryKey: ['admin-user-diag', userId],
queryFn: () => learningAdminAPI.getUserDiagnose(userId),
enabled: false,
@@ -183,7 +183,7 @@ export function UserDiagnosePage() {
setUserId(e.target.value)} style={{ width: 300 }} />
- {data &&
{JSON.stringify(data, null, 2)}}
+ {data ? {JSON.stringify(data, null, 2)} : null}
);
}
@@ -192,7 +192,7 @@ export function UserDiagnosePage() {
export function MaterialDiagnosePage() {
const [materialId, setMaterialId] = useState('');
- const { data, isLoading, refetch } = useQuery({
+ const { data, refetch } = useQuery({
queryKey: ['admin-mat-diag', materialId],
queryFn: () => learningAdminAPI.getMaterialDiagnose(materialId),
enabled: false,
@@ -204,7 +204,7 @@ export function MaterialDiagnosePage() {
setMaterialId(e.target.value)} style={{ width: 300 }} />
- {data && {JSON.stringify(data, null, 2)}}
+ {data ? {JSON.stringify(data, null, 2)} : null}
);
}
diff --git a/src/services/learningAdmin.ts b/src/services/learningAdmin.ts
index dde9725..62a51ee 100644
--- a/src/services/learningAdmin.ts
+++ b/src/services/learningAdmin.ts
@@ -1,5 +1,15 @@
const BASE = '/api/admin/learning';
+export interface PaginatedResponse {
+ items: T[];
+ total: number;
+}
+
+interface AnomalyData {
+ deltaOutliers: unknown[];
+ futureEvents: unknown[];
+}
+
async function getApi(path: string, params?: Record): Promise {
let url = `${BASE}${path}`;
if (params) {
@@ -35,17 +45,17 @@ export interface DashboardData {
export const learningAdminAPI = {
getDashboard: () => getApi('/dashboard'),
- getReadingEvents: (params?: Record) => getApi('/reading-events', params),
- getFailedEvents: (params?: Record) => getApi('/reading-events/failed', params),
- getSessions: (params?: Record) => getApi('/sessions', params),
- getProgress: (params?: Record) => getApi('/progress', params),
- getDailyActivities: (params?: Record) => getApi('/daily-activities', params),
- getRecords: (params?: Record) => getApi('/records', params),
- getUserTimeline: (userId: string) => getApi('/user-timeline', { userId }),
- getUserDiagnose: (userId: string) => getApi('/user-diagnose', { userId }),
- getMaterialDiagnose: (materialId: string) => getApi('/material-diagnose', { materialId }),
- getAnomalies: () => getApi('/anomalies'),
- getTemporaryMaterials: (params?: Record) => getApi('/temporary-materials', params),
- recalculate: () => postApi('/recalculate'),
- exportData: (type: string) => getApi('/export', { type }),
+ getReadingEvents: (params?: Record) => getApi>('/reading-events', params),
+ getFailedEvents: (params?: Record) => getApi>('/reading-events/failed', params),
+ getSessions: (params?: Record) => getApi>('/sessions', params),
+ getProgress: (params?: Record) => getApi>('/progress', params),
+ getDailyActivities: (params?: Record) => getApi>('/daily-activities', params),
+ getRecords: (params?: Record) => getApi>('/records', params),
+ getUserTimeline: (userId: string) => getApi('/user-timeline', { userId }),
+ getUserDiagnose: (userId: string) => getApi('/user-diagnose', { userId }),
+ getMaterialDiagnose: (materialId: string) => getApi('/material-diagnose', { materialId }),
+ getAnomalies: () => getApi('/anomalies'),
+ getTemporaryMaterials: (params?: Record) => getApi>('/temporary-materials', params),
+ recalculate: () => postApi('/recalculate'),
+ exportData: (type: string) => getApi('/export', { type }),
};