"use client"; import { Badge } from "@kandev/ui/badge"; import { Button } from "@kandev/ui/button"; import type { ImportDiff, SyncDiff } from "@/lib/api/domains/office-api"; import { useTranslation } from "react-i18next"; type SyncDiffPaneProps = { title: string; description: string; icon: React.ReactNode; diff: SyncDiff | null; loading: boolean; applying: boolean; applyLabel: string; onApply: () => void; /** * AC-OFFICE-CONFIG-SYNC-006.6: when config sync owns this workspace, apply * is refused server-side. Passing a reason disables the button and states * why, instead of letting the operator hit the 409. The read-only diff * below keeps rendering either way (AC-OFFICE-CONFIG-SYNC-005.3). */ disabledReason?: string; }; export function SyncDiffPane({ title, description, icon, diff, loading, applying, applyLabel, onApply, disabledReason, }: SyncDiffPaneProps) { const { t } = useTranslation(); const totalChanges = diff ? countChanges(diff) : 0; return (
{icon}

{title}

{description}

{disabledReason &&

{disabledReason}

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

{t("common:loadingEllipsis")}

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

{t("office:noChangesDetected")}

; } 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 }[]; }) { const { t } = useTranslation(); return (

{t("office:parseErrors")} {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, ); }