"use client"; import { useState } from "react"; import Link from "next/link"; import { api } from "./api"; export function DuplicateList({ items }: { items: any[] }) { const [list, setList] = useState(items); const [msg, setMsg] = useState(""); const merge = async (from: string, into: string, label: string) => { if (!confirm(`Merge ${label}? This cannot be undone from the UI.`)) return; try { await api(`/api/admin/tools/${from}/action`, { method: "POST", body: JSON.stringify({ action: "merge", into }) }); setList((l) => l.filter((x) => x.aId !== from && x.bId !== from)); setMsg("Merged."); } catch (e) { setMsg((e as Error).message); } }; return
{msg &&

{msg}

}
; }