refactor: replace any with proper types in admin page api calls
Some checks failed
Deploy Admin Frontend / build-and-deploy (push) Failing after 7s
Some checks failed
Deploy Admin Frontend / build-and-deploy (push) Failing after 7s
- Add CacheStats, NotificationTemplate, NotificationLog, ReviewCardItem to types/api.ts - Use PaginatedResult<T> for ReviewAdmin pagination - All queryFn now declare explicit Promise<T> return type Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
parent
11287e2c4f
commit
cf1ea873e0
@ -2,6 +2,7 @@ import { Card, Button, Statistic, Row, Col, Space, Typography, message } from 'a
|
||||
import { ClearOutlined, ReloadOutlined, DeleteOutlined } from '@ant-design/icons'
|
||||
import { useQuery, useMutation, useQueryClient } from '@tanstack/react-query'
|
||||
import { api } from '@/services/http-client'
|
||||
import type { CacheStats } from '@/types/api'
|
||||
|
||||
const { Title } = Typography
|
||||
|
||||
@ -10,7 +11,7 @@ export default function CacheAdmin() {
|
||||
|
||||
const { data: stats, isLoading } = useQuery({
|
||||
queryKey: ['admin', 'cache-stats'],
|
||||
queryFn: () => api.get<any>('/admin-api/cache/stats'),
|
||||
queryFn: (): Promise<CacheStats> => api.get('/admin-api/cache/stats'),
|
||||
refetchInterval: 10_000,
|
||||
})
|
||||
|
||||
|
||||
@ -3,6 +3,7 @@ import { Card, Table, Button, Modal, Form, Input, Select, Tag, Space, Typography
|
||||
import { PlusOutlined, DeleteOutlined, EditOutlined } from '@ant-design/icons'
|
||||
import { useQuery, useMutation, useQueryClient } from '@tanstack/react-query'
|
||||
import { api } from '@/services/http-client'
|
||||
import type { NotificationTemplate, NotificationLog } from '@/types/api'
|
||||
|
||||
const { Title } = Typography
|
||||
|
||||
@ -18,12 +19,14 @@ export default function NotificationAdmin() {
|
||||
|
||||
const { data: templates, isLoading } = useQuery({
|
||||
queryKey: ['admin', 'notification-templates'],
|
||||
queryFn: () => api.get<any[]>('/admin-api/notifications/templates').then(d => d ?? []),
|
||||
queryFn: (): Promise<NotificationTemplate[]> =>
|
||||
api.get('/admin-api/notifications/templates').then((d: NotificationTemplate[]) => d ?? []),
|
||||
})
|
||||
|
||||
const { data: sendLogs } = useQuery({
|
||||
queryKey: ['admin', 'notification-logs'],
|
||||
queryFn: () => api.get<any[]>('/admin-api/notifications/send-log?limit=50').then(d => d ?? []),
|
||||
queryFn: (): Promise<NotificationLog[]> =>
|
||||
api.get('/admin-api/notifications/send-log?limit=50').then((d: NotificationLog[]) => d ?? []),
|
||||
})
|
||||
|
||||
const saveMutation = useMutation({
|
||||
|
||||
@ -3,6 +3,7 @@ import { Table, Tag, Space, Input, Select, Typography } from 'antd'
|
||||
import { SearchOutlined } from '@ant-design/icons'
|
||||
import { useQuery } from '@tanstack/react-query'
|
||||
import { api } from '@/services/http-client'
|
||||
import type { ReviewCardItem, PaginatedResult } from '@/types/api'
|
||||
|
||||
const { Title } = Typography
|
||||
|
||||
@ -16,11 +17,11 @@ export default function ReviewAdmin() {
|
||||
|
||||
const { data, isLoading } = useQuery({
|
||||
queryKey: ['admin', 'reviews', search, statusFilter],
|
||||
queryFn: () => {
|
||||
queryFn: (): Promise<PaginatedResult<ReviewCardItem>> => {
|
||||
const params = new URLSearchParams()
|
||||
if (search) params.set('search', search)
|
||||
if (statusFilter) params.set('status', statusFilter)
|
||||
return api.get<any>(`/admin-api/reviews?${params.toString()}`)
|
||||
return api.get(`/admin-api/reviews?${params.toString()}`)
|
||||
},
|
||||
refetchInterval: 30_000,
|
||||
})
|
||||
|
||||
@ -12,3 +12,45 @@ export interface PaginationParams {
|
||||
sortBy?: string
|
||||
sortOrder?: 'asc' | 'desc'
|
||||
}
|
||||
|
||||
export interface CacheStats {
|
||||
hits: number
|
||||
misses: number
|
||||
hitRate: number
|
||||
available: boolean
|
||||
}
|
||||
|
||||
export interface NotificationTemplate {
|
||||
id: string
|
||||
name: string
|
||||
type: string
|
||||
title: string
|
||||
content: string
|
||||
channel: string
|
||||
enabled: boolean
|
||||
createdBy?: string
|
||||
createdAt: string
|
||||
updatedAt: string
|
||||
}
|
||||
|
||||
export interface NotificationLog {
|
||||
id: string
|
||||
userId: string
|
||||
type: string
|
||||
title: string
|
||||
readAt: string | null
|
||||
createdAt: string
|
||||
}
|
||||
|
||||
export interface ReviewCardItem {
|
||||
id: string
|
||||
userId: string
|
||||
frontText: string
|
||||
difficulty: string | null
|
||||
status: string
|
||||
scheduleState: string | null
|
||||
intervalDays: number
|
||||
repetitionCount: number
|
||||
lapseCount: number
|
||||
nextReviewAt: string | null
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user