import type { FileDiff, DiffLine, ReviewComment } from "./types";
import { FileCard } from "./FileCard";

interface DiffViewerProps {
  files: FileDiff[];
  comments: ReviewComment[];
  onAddComment: (
    filePath: string,
    lineNumber: number,
    lineType: DiffLine["type"],
    body: string,
  ) => void;
  onResolveComment: (commentId: string) => void;
  onUnresolveComment: (commentId: string) => void;
}

export function DiffViewer({
  files,
  comments,
  onAddComment,
  onResolveComment,
  onUnresolveComment,
}: DiffViewerProps) {
  return (
    <div className="space-y-4">
      {files.map((file) => (
        <FileCard
          key={file.newPath}
          file={file}
          comments={comments.filter((c) => c.filePath === file.newPath)}
          onAddComment={onAddComment}
          onResolveComment={onResolveComment}
          onUnresolveComment={onUnresolveComment}
        />
      ))}
    </div>
  );
}
