fad458b2a7
- UIUX 文档:填充 19 个缺口(多主体画像/健康度/AI+看板/增长域/洞察域/创始人端/OODA/助推/商密) - UIUX 文档:插入 6 个新章节(十四~十九),旧章节重编号为二十~三十一,更新目录和交叉引用 - 作业指导书 x5:导航改为 6 域分组,新增 Context Bar/工作模式/Insight Rail/决策线程/多工作区等 UI 概念 - 新建 docs/2-task-uiux.md:50 个代码落地开发任务,按 P0-P6 分优先级 + 8 Sprint 规划 - 后端/前端:大量新增模型、路由、组件(来自之前 Phase 开发)
80 lines
2.9 KiB
TypeScript
80 lines
2.9 KiB
TypeScript
"use client";
|
||
|
||
import { useEffect, useState } from "react";
|
||
import { Network, Plus } from "lucide-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";
|
||
|
||
const SYNERGY_TYPE_LABELS: Record<string, string> = {
|
||
customer: "客户协同",
|
||
talent: "人才协同",
|
||
funding: "融资协同",
|
||
supply_chain: "供应链协同",
|
||
tech: "技术协同",
|
||
};
|
||
|
||
export default function SynergiesPage() {
|
||
const [items, setItems] = useState<Record<string, any>[]>([]);
|
||
const [isLoading, setIsLoading] = useState(true);
|
||
|
||
const load = () => {
|
||
listSynergies()
|
||
.then((resp) => setItems((resp.data as Record<string, any>[]) ?? []))
|
||
.catch(() => setItems([]))
|
||
.finally(() => setIsLoading(false));
|
||
};
|
||
|
||
useEffect(() => { load(); }, []);
|
||
|
||
const handleAuthorize = async (id: string) => {
|
||
try {
|
||
await authorizeSynergy(id);
|
||
toast.success("授权成功");
|
||
load();
|
||
} catch {
|
||
toast.error("授权失败");
|
||
}
|
||
};
|
||
|
||
return (
|
||
<PageContainer title="协同中心" description="Portfolio 内部协同匹配 → 双方授权 → 效果追踪">
|
||
{isLoading ? (
|
||
<LoadingSpinner />
|
||
) : items.length === 0 ? (
|
||
<EmptyState description="暂无协同机会" />
|
||
) : (
|
||
<div className="space-y-3">
|
||
{items.map((item, i) => (
|
||
<div key={i} className="rounded-lg border border-gray-200 bg-white p-4">
|
||
<div className="flex items-center justify-between">
|
||
<div className="flex items-center gap-2">
|
||
<Badge color="blue">{SYNERGY_TYPE_LABELS[item.type as string] ?? item.type}</Badge>
|
||
<h3 className="font-medium text-gray-900">{item.title as string}</h3>
|
||
</div>
|
||
<div className="flex items-center gap-2">
|
||
<Badge color={item.status === "completed" ? "green" : item.status === "authorized" ? "blue" : "gray"}>
|
||
{item.status as string}
|
||
</Badge>
|
||
{item.authorized === false && (
|
||
<button
|
||
onClick={() => handleAuthorize(item.id as string)}
|
||
className="rounded-md bg-gray-900 px-2 py-1 text-xs text-white hover:bg-gray-700"
|
||
>
|
||
授权
|
||
</button>
|
||
)}
|
||
</div>
|
||
</div>
|
||
{item.description && <p className="mt-2 text-sm text-gray-600">{item.description as string}</p>}
|
||
{item.match_reason && <p className="mt-1 text-xs text-gray-400">匹配理由:{item.match_reason as string}</p>}
|
||
</div>
|
||
))}
|
||
</div>
|
||
)}
|
||
</PageContainer>
|
||
);
|
||
}
|