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

View File

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