更新用户总览图表,删除多余的console.log
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
'use client'
|
||||
import {useEffect, useState} from 'react'
|
||||
import {useCallback, useEffect, useState} from 'react'
|
||||
import {useStatus} from '@/lib/states'
|
||||
import {PageRecord} from '@/lib/api'
|
||||
import {Channel} from '@/lib/models'
|
||||
@@ -31,14 +31,32 @@ export default function ChannelsPage(props: ChannelsPageProps) {
|
||||
total: 0,
|
||||
list: [],
|
||||
})
|
||||
|
||||
// ======================
|
||||
// filter
|
||||
// ======================
|
||||
const filterSchema = z.object({
|
||||
auth_type: z.enum(['0', '1', '2']),
|
||||
expired_status: z.enum(['all', 'active']).default('all'),
|
||||
expire_after: z.date().optional(),
|
||||
expire_before: z.date().optional(),
|
||||
})
|
||||
type FilterSchema = z.infer<typeof filterSchema>
|
||||
const filterForm = useForm<FilterSchema>({
|
||||
resolver: zodResolver(filterSchema),
|
||||
defaultValues: {
|
||||
auth_type: '0',
|
||||
expired_status: 'all',
|
||||
expire_after: undefined,
|
||||
expire_before: undefined,
|
||||
},
|
||||
})
|
||||
// 检查是否过期
|
||||
const isExpired = (expiredAt: string | Date) => {
|
||||
const date = typeof expiredAt === 'string' ? new Date(expiredAt) : expiredAt
|
||||
return isBefore(date, new Date())
|
||||
}
|
||||
|
||||
const refresh = async (page: number, size: number) => {
|
||||
const refresh = useCallback(async (page: number, size: number) => {
|
||||
try {
|
||||
setStatus('load')
|
||||
|
||||
@@ -54,7 +72,6 @@ export default function ChannelsPage(props: ChannelsPageProps) {
|
||||
const resp = await listChannels({
|
||||
page, size, ...filter, auth_type,
|
||||
})
|
||||
console.log(resp, 'ip管理的respresprespresp')
|
||||
|
||||
if (!resp.success) {
|
||||
throw new Error(resp.message)
|
||||
@@ -83,33 +100,12 @@ export default function ChannelsPage(props: ChannelsPageProps) {
|
||||
description: (e as Error).message,
|
||||
})
|
||||
}
|
||||
}
|
||||
}, [setStatus, filterForm])
|
||||
|
||||
useEffect(() => {
|
||||
refresh(data.page, data.size).then()
|
||||
}, [])
|
||||
}, [data.page, data.size, refresh])
|
||||
|
||||
// ======================
|
||||
// filter
|
||||
// ======================
|
||||
|
||||
const filterSchema = z.object({
|
||||
auth_type: z.enum(['0', '1', '2']),
|
||||
expired_status: z.enum(['all', 'active']).default('all'),
|
||||
expire_after: z.date().optional(),
|
||||
expire_before: z.date().optional(),
|
||||
})
|
||||
type FilterSchema = z.infer<typeof filterSchema>
|
||||
|
||||
const filterForm = useForm<FilterSchema>({
|
||||
resolver: zodResolver(filterSchema),
|
||||
defaultValues: {
|
||||
auth_type: '0',
|
||||
expired_status: 'all',
|
||||
expire_after: undefined,
|
||||
expire_before: undefined,
|
||||
},
|
||||
})
|
||||
const filterHandler = filterForm.handleSubmit(async (value) => {
|
||||
await refresh(1, data.size)
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user