refactor: Always render BloombergView and handle missing company ID and data loading state internally.

This commit is contained in:
xucheng 2026-01-23 07:43:30 +08:00
parent c729872b07
commit 2bc05c3810
2 changed files with 14 additions and 14 deletions

View File

@ -381,17 +381,15 @@ function CompanyAnalysisView({
)}
{dataSource === 'Bloomberg' ? (
status?.company_id && (
<BloombergView
selectedCurrency={currency}
userMarket={company.market}
companyId={status.company_id}
companySymbol={company.symbol}
companyMarket={company.market}
companyName={company.company_name}
lastUpdate={status.last_update?.date}
/>
)
<BloombergView
selectedCurrency={currency}
userMarket={company.market}
companyId={status?.company_id || 0} // Pass 0 or null if not valid yet, View handles it
companySymbol={company.symbol}
companyMarket={company.market}
companyName={company.company_name}
lastUpdate={status?.last_update?.date}
/>
) : (
status?.company_id && (
<FinancialTables

View File

@ -40,7 +40,11 @@ export function BloombergView({ companyId, companySymbol, companyMarket, company
const { fetching, fetchData, updateStatus } = useFinancialData(companyObj, "Bloomberg")
const loadData = async () => {
if (!companyId) return
if (!companyId) {
setLoading(false) // Stop loading if no ID
setData(null)
return
}
setLoading(true)
setError("")
@ -97,8 +101,6 @@ export function BloombergView({ companyId, companySymbol, companyMarket, company
)
}
if (!data && !fetching) return null
// 如果后端提供了统一数据字段,直接使用
const mergedData = data?.unified_data || []