mirror of
https://github.com/iflytek/skillhub.git
synced 2026-10-09 03:17:52 +00:00
feat(web): lazy-load profile review tabs
- useProfileReviewList now accepts enabled parameter - Profile review tabs only fetch data when activated
This commit is contained in:
parent
9cdd200bc2
commit
4d0a55957a
2 changed files with 7 additions and 5 deletions
|
|
@ -1,10 +1,11 @@
|
|||
import { useMutation, useQuery, useQueryClient } from '@tanstack/react-query'
|
||||
import { adminApi } from '@/api/client'
|
||||
|
||||
export function useProfileReviewList(status: string, page = 0, size = 20) {
|
||||
export function useProfileReviewList(status: string, page = 0, size = 20, enabled = true) {
|
||||
return useQuery({
|
||||
queryKey: ['profile-reviews', status, page, size],
|
||||
queryFn: () => adminApi.getProfileReviews({ status, page, size }),
|
||||
enabled,
|
||||
})
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -60,10 +60,11 @@ export function ProfileReviewTable() {
|
|||
APPROVED: 0,
|
||||
REJECTED: 0,
|
||||
})
|
||||
const [activeStatus, setActiveStatus] = useState<ReviewStatus>('PENDING')
|
||||
|
||||
const pendingQuery = useProfileReviewList('PENDING', pages.PENDING, PAGE_SIZE)
|
||||
const approvedQuery = useProfileReviewList('APPROVED', pages.APPROVED, PAGE_SIZE)
|
||||
const rejectedQuery = useProfileReviewList('REJECTED', pages.REJECTED, PAGE_SIZE)
|
||||
const pendingQuery = useProfileReviewList('PENDING', pages.PENDING, PAGE_SIZE, activeStatus === 'PENDING')
|
||||
const approvedQuery = useProfileReviewList('APPROVED', pages.APPROVED, PAGE_SIZE, activeStatus === 'APPROVED')
|
||||
const rejectedQuery = useProfileReviewList('REJECTED', pages.REJECTED, PAGE_SIZE, activeStatus === 'REJECTED')
|
||||
|
||||
const approveMutation = useApproveProfileReview()
|
||||
const rejectMutation = useRejectProfileReview()
|
||||
|
|
@ -321,7 +322,7 @@ export function ProfileReviewTable() {
|
|||
{renderPendingSummaryCard(pendingCount)}
|
||||
</div>
|
||||
|
||||
<Tabs defaultValue="PENDING">
|
||||
<Tabs value={activeStatus} onValueChange={(v) => setActiveStatus(v as ReviewStatus)}>
|
||||
<TabsList className="gap-4 rounded-xl border-b-0 bg-muted/70 p-1 shadow-none">
|
||||
<TabsTrigger
|
||||
value="PENDING"
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue