feat(dashboard): add company filter — switch between portfolio overview and single company view
This commit is contained in:
@@ -155,16 +155,19 @@ export function HealthTrends({ companyId }: { companyId?: string }) {
|
||||
</div>
|
||||
);
|
||||
}
|
||||
export function HealthHeatmap() {
|
||||
export function HealthHeatmap({ companyId }: { companyId?: string }) {
|
||||
const [data, setData] = useState<HeatmapRow[]>([]);
|
||||
const [loading, setLoading] = useState(true);
|
||||
|
||||
useEffect(() => {
|
||||
apiFetch<HeatmapRow[]>("/dashboard/heatmap")
|
||||
.then((res) => setData((res.data as HeatmapRow[]) || []))
|
||||
.then((res) => {
|
||||
const rows = (res.data as HeatmapRow[]) || [];
|
||||
setData(companyId ? rows.filter((r) => r.company_id === companyId) : rows);
|
||||
})
|
||||
.catch(() => {})
|
||||
.finally(() => setLoading(false));
|
||||
}, []);
|
||||
}, [companyId]);
|
||||
|
||||
if (loading) return <LoadingSpinner />;
|
||||
if (!data.length) return <EmptyState title="暂无热力图数据" />;
|
||||
|
||||
Reference in New Issue
Block a user