fix(frontend): auto-fetch report data when campaignId changes
Some checks failed
CI / test (push) Failing after 11s
Some checks failed
CI / test (push) Failing after 11s
useCampaignReport hook 缺少 useEffect 自动触发数据获取,导致打开报告抽屉时 显示空白。添加 useEffect 监听 campaignId 变化,自动调用 refetch。 - 新增 useEffect 在 campaignId 变化时自动获取数据
This commit is contained in:
parent
160332665e
commit
f93d2f224f
@ -1,4 +1,4 @@
|
||||
import { useState, useCallback, type Dispatch, type SetStateAction } from 'react'
|
||||
import { useState, useCallback, useEffect, type Dispatch, type SetStateAction } from 'react'
|
||||
import { campaignsApi, runsApi, type CampaignReport, type Run, type CampaignTimelineEntry, type CampaignAnalysis, type CampaignComparison } from '../api'
|
||||
|
||||
interface CampaignReportData {
|
||||
@ -59,6 +59,12 @@ export function useCampaignReport(campaignId: string | null): UseCampaignReportR
|
||||
}
|
||||
}, [campaignId])
|
||||
|
||||
useEffect(() => {
|
||||
if (campaignId) {
|
||||
void refetch(false)
|
||||
}
|
||||
}, [campaignId, refetch])
|
||||
|
||||
const setAnalysis: Dispatch<SetStateAction<CampaignAnalysis | null>> = (value) => {
|
||||
setData((prev) => ({
|
||||
...prev,
|
||||
|
||||
Loading…
Reference in New Issue
Block a user