fix: resolve TypeScript build errors in admin learning pages
All checks were successful
Deploy Admin Frontend / build-and-deploy (push) Successful in 9s
All checks were successful
Deploy Admin Frontend / build-and-deploy (push) Successful in 9s
- Remove 5 unused antd imports (Card, Descriptions, message, Spin, Alert) - Add PaginatedResponse<T> interface for typed API responses - Add explicit return types to all learningAdminAPI functions - Remove unused isLoading from UserDiagnosePage / MaterialDiagnosePage Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
parent
5bfac05bec
commit
ea73400857
@ -1,5 +1,5 @@
|
|||||||
import { useState } from 'react';
|
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 { useQuery } from '@tanstack/react-query';
|
||||||
import { learningAdminAPI } from '../../services/learningAdmin';
|
import { learningAdminAPI } from '../../services/learningAdmin';
|
||||||
|
|
||||||
@ -171,7 +171,7 @@ export function AnomalyPage() {
|
|||||||
|
|
||||||
export function UserDiagnosePage() {
|
export function UserDiagnosePage() {
|
||||||
const [userId, setUserId] = useState('');
|
const [userId, setUserId] = useState('');
|
||||||
const { data, isLoading, refetch } = useQuery({
|
const { data, refetch } = useQuery({
|
||||||
queryKey: ['admin-user-diag', userId],
|
queryKey: ['admin-user-diag', userId],
|
||||||
queryFn: () => learningAdminAPI.getUserDiagnose(userId),
|
queryFn: () => learningAdminAPI.getUserDiagnose(userId),
|
||||||
enabled: false,
|
enabled: false,
|
||||||
@ -183,7 +183,7 @@ export function UserDiagnosePage() {
|
|||||||
<Input placeholder="User ID" value={userId} onChange={e => setUserId(e.target.value)} style={{ width: 300 }} />
|
<Input placeholder="User ID" value={userId} onChange={e => setUserId(e.target.value)} style={{ width: 300 }} />
|
||||||
<Button type="primary" onClick={() => refetch()}>查询</Button>
|
<Button type="primary" onClick={() => refetch()}>查询</Button>
|
||||||
</Space>
|
</Space>
|
||||||
{data && <pre style={{ background: '#f5f5f5', padding: 16, borderRadius: 8, overflow: 'auto', maxHeight: 600 }}>{JSON.stringify(data, null, 2)}</pre>}
|
{data ? <pre style={{ background: '#f5f5f5', padding: 16, borderRadius: 8, overflow: 'auto', maxHeight: 600 }}>{JSON.stringify(data, null, 2)}</pre> : null}
|
||||||
</PageWrapper>
|
</PageWrapper>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -192,7 +192,7 @@ export function UserDiagnosePage() {
|
|||||||
|
|
||||||
export function MaterialDiagnosePage() {
|
export function MaterialDiagnosePage() {
|
||||||
const [materialId, setMaterialId] = useState('');
|
const [materialId, setMaterialId] = useState('');
|
||||||
const { data, isLoading, refetch } = useQuery({
|
const { data, refetch } = useQuery({
|
||||||
queryKey: ['admin-mat-diag', materialId],
|
queryKey: ['admin-mat-diag', materialId],
|
||||||
queryFn: () => learningAdminAPI.getMaterialDiagnose(materialId),
|
queryFn: () => learningAdminAPI.getMaterialDiagnose(materialId),
|
||||||
enabled: false,
|
enabled: false,
|
||||||
@ -204,7 +204,7 @@ export function MaterialDiagnosePage() {
|
|||||||
<Input placeholder="Material ID" value={materialId} onChange={e => setMaterialId(e.target.value)} style={{ width: 300 }} />
|
<Input placeholder="Material ID" value={materialId} onChange={e => setMaterialId(e.target.value)} style={{ width: 300 }} />
|
||||||
<Button type="primary" onClick={() => refetch()}>查询</Button>
|
<Button type="primary" onClick={() => refetch()}>查询</Button>
|
||||||
</Space>
|
</Space>
|
||||||
{data && <pre style={{ background: '#f5f5f5', padding: 16, borderRadius: 8, overflow: 'auto', maxHeight: 600 }}>{JSON.stringify(data, null, 2)}</pre>}
|
{data ? <pre style={{ background: '#f5f5f5', padding: 16, borderRadius: 8, overflow: 'auto', maxHeight: 600 }}>{JSON.stringify(data, null, 2)}</pre> : null}
|
||||||
</PageWrapper>
|
</PageWrapper>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,5 +1,15 @@
|
|||||||
const BASE = '/api/admin/learning';
|
const BASE = '/api/admin/learning';
|
||||||
|
|
||||||
|
export interface PaginatedResponse<T> {
|
||||||
|
items: T[];
|
||||||
|
total: number;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface AnomalyData {
|
||||||
|
deltaOutliers: unknown[];
|
||||||
|
futureEvents: unknown[];
|
||||||
|
}
|
||||||
|
|
||||||
async function getApi<T>(path: string, params?: Record<string, any>): Promise<T> {
|
async function getApi<T>(path: string, params?: Record<string, any>): Promise<T> {
|
||||||
let url = `${BASE}${path}`;
|
let url = `${BASE}${path}`;
|
||||||
if (params) {
|
if (params) {
|
||||||
@ -35,17 +45,17 @@ export interface DashboardData {
|
|||||||
|
|
||||||
export const learningAdminAPI = {
|
export const learningAdminAPI = {
|
||||||
getDashboard: () => getApi<DashboardData>('/dashboard'),
|
getDashboard: () => getApi<DashboardData>('/dashboard'),
|
||||||
getReadingEvents: (params?: Record<string, any>) => getApi('/reading-events', params),
|
getReadingEvents: (params?: Record<string, any>) => getApi<PaginatedResponse<unknown>>('/reading-events', params),
|
||||||
getFailedEvents: (params?: Record<string, any>) => getApi('/reading-events/failed', params),
|
getFailedEvents: (params?: Record<string, any>) => getApi<PaginatedResponse<unknown>>('/reading-events/failed', params),
|
||||||
getSessions: (params?: Record<string, any>) => getApi('/sessions', params),
|
getSessions: (params?: Record<string, any>) => getApi<PaginatedResponse<unknown>>('/sessions', params),
|
||||||
getProgress: (params?: Record<string, any>) => getApi('/progress', params),
|
getProgress: (params?: Record<string, any>) => getApi<PaginatedResponse<unknown>>('/progress', params),
|
||||||
getDailyActivities: (params?: Record<string, any>) => getApi('/daily-activities', params),
|
getDailyActivities: (params?: Record<string, any>) => getApi<PaginatedResponse<unknown>>('/daily-activities', params),
|
||||||
getRecords: (params?: Record<string, any>) => getApi('/records', params),
|
getRecords: (params?: Record<string, any>) => getApi<PaginatedResponse<unknown>>('/records', params),
|
||||||
getUserTimeline: (userId: string) => getApi('/user-timeline', { userId }),
|
getUserTimeline: (userId: string) => getApi<unknown>('/user-timeline', { userId }),
|
||||||
getUserDiagnose: (userId: string) => getApi('/user-diagnose', { userId }),
|
getUserDiagnose: (userId: string) => getApi<unknown>('/user-diagnose', { userId }),
|
||||||
getMaterialDiagnose: (materialId: string) => getApi('/material-diagnose', { materialId }),
|
getMaterialDiagnose: (materialId: string) => getApi<unknown>('/material-diagnose', { materialId }),
|
||||||
getAnomalies: () => getApi('/anomalies'),
|
getAnomalies: () => getApi<AnomalyData>('/anomalies'),
|
||||||
getTemporaryMaterials: (params?: Record<string, any>) => getApi('/temporary-materials', params),
|
getTemporaryMaterials: (params?: Record<string, any>) => getApi<PaginatedResponse<unknown>>('/temporary-materials', params),
|
||||||
recalculate: () => postApi('/recalculate'),
|
recalculate: () => postApi<unknown>('/recalculate'),
|
||||||
exportData: (type: string) => getApi('/export', { type }),
|
exportData: (type: string) => getApi<unknown>('/export', { type }),
|
||||||
};
|
};
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user