feat(workbench): complete company view — health trend, major events, milestones, team, synergy + dashboard click-through
This commit is contained in:
@@ -4,7 +4,6 @@ import { useEffect, useState } from "react";
|
||||
import { Building2, Heart, AlertTriangle, FileText, TrendingUp, TrendingDown, Minus } from "lucide-react";
|
||||
import Link from "next/link";
|
||||
import { getDashboardSummary, type DashboardSummary } from "@/lib/dashboard";
|
||||
import { listCompanies, type Company } from "@/lib/companies";
|
||||
import { LoadingSpinner } from "@/components/shared/LoadingSpinner";
|
||||
import { EmptyState } from "@/components/shared/EmptyState";
|
||||
import { HealthScoreBadge } from "@/components/shared/HealthScoreBadge";
|
||||
@@ -15,19 +14,13 @@ import { HealthHeatmap, HealthTrends } from "@/components/dashboard/HealthHeatma
|
||||
*/
|
||||
export default function InvestorDashboardPage() {
|
||||
const [summary, setSummary] = useState<DashboardSummary | null>(null);
|
||||
const [companies, setCompanies] = useState<Company[]>([]);
|
||||
const [selectedCompanyId, setSelectedCompanyId] = useState<string>("");
|
||||
const [isLoading, setIsLoading] = useState(true);
|
||||
|
||||
useEffect(() => {
|
||||
async function load() {
|
||||
try {
|
||||
const [summaryResp, companiesResp] = await Promise.all([
|
||||
getDashboardSummary(),
|
||||
listCompanies({ page_size: 100 }),
|
||||
]);
|
||||
if (summaryResp.data) setSummary(summaryResp.data);
|
||||
if (companiesResp.data?.items) setCompanies(companiesResp.data.items);
|
||||
const resp = await getDashboardSummary();
|
||||
if (resp.data) setSummary(resp.data);
|
||||
} catch {
|
||||
// ignore
|
||||
} finally {
|
||||
@@ -83,35 +76,11 @@ export default function InvestorDashboardPage() {
|
||||
},
|
||||
];
|
||||
|
||||
// 筛选后的评分列表
|
||||
const filteredScores = selectedCompanyId
|
||||
? summary?.recent_scores.filter((s) => s.company_id === selectedCompanyId) ?? []
|
||||
: summary?.recent_scores ?? [];
|
||||
|
||||
// 选中的企业名称
|
||||
const selectedCompany = companies.find((c) => c.id === selectedCompanyId);
|
||||
|
||||
return (
|
||||
<div className="space-y-6">
|
||||
<div className="flex items-center justify-between">
|
||||
<div>
|
||||
<h1 className="text-2xl font-bold text-foreground">投资机构驾驶舱</h1>
|
||||
<p className="mt-1 text-sm text-muted-foreground">
|
||||
{selectedCompany ? `${selectedCompany.name} — 企业健康度概览` : "Portfolio 全局健康度与风险概览"}
|
||||
</p>
|
||||
</div>
|
||||
|
||||
{/* 企业筛选器 */}
|
||||
<select
|
||||
value={selectedCompanyId}
|
||||
onChange={(e) => setSelectedCompanyId(e.target.value)}
|
||||
className="rounded-md border bg-white px-3 py-1.5 text-sm focus:outline-none focus:ring-2 focus:ring-[var(--investor-primary)]"
|
||||
>
|
||||
<option value="">全部企业</option>
|
||||
{companies.map((c) => (
|
||||
<option key={c.id} value={c.id}>{c.name}</option>
|
||||
))}
|
||||
</select>
|
||||
<div>
|
||||
<h1 className="text-2xl font-bold text-foreground">投资机构驾驶舱</h1>
|
||||
<p className="mt-1 text-sm text-muted-foreground">Portfolio 全局健康度与风险概览</p>
|
||||
</div>
|
||||
|
||||
{/* KPI 卡片 */}
|
||||
@@ -144,10 +113,14 @@ export default function InvestorDashboardPage() {
|
||||
</Link>
|
||||
</div>
|
||||
|
||||
{filteredScores.length > 0 ? (
|
||||
{summary && summary.recent_scores.length > 0 ? (
|
||||
<div className="space-y-3">
|
||||
{filteredScores.map((score) => (
|
||||
<div key={score.id} className="flex items-center justify-between border-b pb-3 last:border-0 last:pb-0">
|
||||
{summary.recent_scores.map((score) => (
|
||||
<Link
|
||||
key={score.id}
|
||||
href={`/companies/${score.company_id}/workbench`}
|
||||
className="flex items-center justify-between border-b pb-3 last:border-0 last:pb-0 transition-colors hover:bg-muted/30 rounded-md px-2 -mx-2"
|
||||
>
|
||||
<div className="flex items-center gap-3">
|
||||
<HealthScoreBadge score={Math.round(score.total_score)} />
|
||||
<div>
|
||||
@@ -175,7 +148,7 @@ export default function InvestorDashboardPage() {
|
||||
</span>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
</Link>
|
||||
))}
|
||||
</div>
|
||||
) : (
|
||||
@@ -187,10 +160,10 @@ export default function InvestorDashboardPage() {
|
||||
<div className="space-y-4">
|
||||
<div className="rounded-lg border bg-white p-5 shadow-sm">
|
||||
<h2 className="mb-4 text-lg font-semibold">健康度热力图</h2>
|
||||
<HealthHeatmap companyId={selectedCompanyId || undefined} />
|
||||
<HealthHeatmap />
|
||||
</div>
|
||||
<div className="rounded-lg border bg-white p-5 shadow-sm">
|
||||
<HealthTrends companyId={selectedCompanyId || undefined} />
|
||||
<HealthTrends />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user