"use client"; import { Badge } from "@kandev/ui/badge"; import { Button } from "@kandev/ui/button"; import type { ImportDiff, SyncDiff } from "@/lib/api/domains/office-api"; type SyncDiffPaneProps = { title: string; description: string; icon: React.ReactNode; diff: SyncDiff | null; loading: boolean; applying: boolean; applyLabel: string; onApply: () => void; }; export function SyncDiffPane({ title, description, icon, diff, loading, applying, applyLabel, onApply, }: SyncDiffPaneProps) { const totalChanges = diff ? countChanges(diff) : 0; return (
{icon}

{title}

{description}

{diff?.errors && diff.errors.length > 0 && }
); } function DiffBody({ diff, loading, totalChanges, }: { diff: SyncDiff | null; loading: boolean; totalChanges: number; }) { if (loading && !diff) { return

Loading...

; } if (!diff || totalChanges === 0) { return

No changes detected.

; } return ( <> ); } function DiffSection({ label, diff }: { label: string; diff: ImportDiff }) { const total = (diff.created?.length ?? 0) + (diff.updated?.length ?? 0) + (diff.deleted?.length ?? 0); if (total === 0) return null; return (

{label}

{diff.created?.map((name) => ( + {name} ))} {diff.updated?.map((name) => ( ~ {name} ))} {diff.deleted?.map((name) => ( − {name} ))}
); } function ParseErrorsSection({ errors, }: { errors: { workspace_id: string; file_path: string; error: string }[]; }) { return (

Parse errors ({errors.length})

    {errors.map((err) => (
  • {err.file_path} — {err.error}
  • ))}
); } function countChanges(diff: SyncDiff): number { const sections = [ diff.preview.agents, diff.preview.skills, diff.preview.routines, diff.preview.projects, ]; return sections.reduce( (acc, s) => acc + (s.created?.length ?? 0) + (s.updated?.length ?? 0) + (s.deleted?.length ?? 0), 0, ); }