"use client"; import { useEffect, useState } from "react"; import { listFinancialData} from "@/lib/api-v2"; import { PageContainer,Badge, TableEmpty } from "@/components/shared/PageContainer"; import { LoadingSpinner } from "@/components/shared/LoadingSpinner"; import { EmptyState } from "@/components/shared/EmptyState"; /** 财务数据项。 */ interface FinancialData { period_year: number; period_month: number; statement_type: string; credibility_score: number; source: string; } /** * 投资人端 — 财务数据校验页面。 */ export default function FinancialPage() { const [items, setItems] = useState([]); const [isLoading, setIsLoading] = useState(true); const [companyId, setCompanyId] = useState(""); useEffect(() => { if (!companyId) { // eslint-disable-next-line react-hooks/set-state-in-effect setIsLoading(false); return; } listFinancialData(companyId) .then((resp) => setItems((resp.data as FinancialData[]) ?? [])) .catch(() => setItems([])) .finally(() => setIsLoading(false)); }, [companyId]); return (
setCompanyId(e.target.value)} className="rounded-md border border-gray-300 px-3 py-1.5 text-sm" />
{isLoading ? ( ) : !companyId ? ( ) : (
{items.length === 0 ? ( ) : ( items.map((item, i) => ( )) )}
期间 报表类型 可信度 来源
{item.period_year}-{String(item.period_month).padStart(2, "0")} {item.statement_type} = 80 ? "green" : item.credibility_score >= 50 ? "amber" : "red" }> {item.credibility_score} {item.source}
)}
); }