"use client"; import { useState, useTransition } from "react"; import { CodeOutput } from "@/components/tools/CodeOutput"; import { regeneratePdfApiKey } from "@/lib/actions/pdf-key-actions"; import { buildZoteroScript } from "@/lib/clean-pdf/zotero-script"; export function ZoteroSection({ apiKey, baseUrl }: { apiKey: string; baseUrl: string }) { const [key, setKey] = useState(apiKey); const [revealed, setRevealed] = useState(false); const [pending, startTransition] = useTransition(); const shownKey = revealed ? key : key.slice(0, 8) + "…" + key.slice(-4); const curlExample = `curl -H "Authorization: Bearer ${key}" \\\n "${baseUrl}/api/pdf?url=https://example.com/article&format=A4&theme=light" \\\n -o article.pdf`; const script = buildZoteroScript({ apiKey: key, baseUrl }); function regenerate() { if (!confirm("Старый ключ перестанет работать (в том числе в Zotero). Продолжить?")) return; startTransition(async () => { const res = await regeneratePdfApiKey(); if (res.ok && res.key) { setKey(res.key); setRevealed(true); } }); } return (
{shownKey}
Ключ персональный — не публикуйте его. Если ключ утёк, перевыпустите: старый сразу отключится.