"use client";
import { useState } from "react";
export function SyncPreview({ sourceId }: { sourceId: number }) { const [text, setText] = useState(""); async function preview() { setText("讀取中…"); const response = await fetch(`/api/sources/${sourceId}/preview`); const body = await response.json(); setText(response.ok ? `本頁預覽：新增 ${body.added}、已存在 ${body.existing}，共檢查 ${body.inspected} 篇${body.hasMore ? "（來源尚有更多頁）" : ""}` : body.error || "無法預覽"); } return <div><button type="button" onClick={preview}>預覽同步差異</button>{text && <p className="meta">{text}</p>}</div>; }
