"use client"; import { useEffect, useState } from "react"; import { listSynergies, authorizeSynergy } from "@/lib/api-v2"; import { PageContainer, Badge } from "@/components/shared/PageContainer"; import { LoadingSpinner } from "@/components/shared/LoadingSpinner"; import { EmptyState } from "@/components/shared/EmptyState"; import { toast } from "sonner"; /** 协同机会项。 */ interface Synergy { id: string; type: string; title: string; status: string; authorized?: boolean; description?: string; match_reason?: string; } const SYNERGY_TYPE_LABELS: Record = { customer: "客户协同", talent: "人才协同", funding: "融资协同", supply_chain: "供应链协同", tech: "技术协同", }; export default function SynergiesPage() { const [items, setItems] = useState([]); const [isLoading, setIsLoading] = useState(true); const load = () => { listSynergies() .then((resp) => setItems((resp.data as Synergy[]) ?? [])) .catch(() => setItems([])) .finally(() => setIsLoading(false)); }; useEffect(() => { load(); }, []); const handleAuthorize = async (id: string) => { try { await authorizeSynergy(id); toast.success("授权成功"); load(); } catch { toast.error("授权失败"); } }; return ( {isLoading ? ( ) : items.length === 0 ? ( ) : (
{items.map((item, i) => (
{SYNERGY_TYPE_LABELS[item.type] ?? item.type}

{item.title}

{item.status} {item.authorized === false && ( )}
{item.description &&

{item.description}

} {item.match_reason &&

匹配理由:{item.match_reason}

}
))}
)}
); }