"use client"; import { useState } from "react"; import { Button } from "@/components/ui/button"; import { Dialog, DialogContent, DialogHeader, DialogTitle, DialogFooter } from "@/components/ui/dialog"; import { ScrollArea } from "@/components/ui/scroll-area"; import { DiffResult } from "@/services/diffPatch"; import { Card, CardContent } from "@/components/ui/card"; interface DiffReviewModalProps { isOpen: boolean; onClose: () => void; diffResult: DiffResult | null; onApply: () => void; } const DiffReviewModal = ({ isOpen, onClose, diffResult, onApply }: DiffReviewModalProps) => { const [isApplying, setIsApplying] = useState(false); const handleApply = async () => { setIsApplying(true); try { await onApply(); onClose(); } finally { setIsApplying(false); } }; if (!diffResult) return null; let oldLineNum = 1; let newLineNum = 1; return ( Code Changes Review
+{diffResult.added} lines -{diffResult.removed} lines
{diffResult.changes.map((change, changeIndex) => { const lines = change.value.endsWith('\n') ? change.value.slice(0, -1).split('\n') : change.value.split('\n'); return lines.map((line, lineIndex) => { let currentOldLine = ' '; let currentNewLine = ' '; if (change.removed) { currentOldLine = String(oldLineNum++); } else if (change.added) { currentNewLine = String(newLineNum++); } else { currentOldLine = String(oldLineNum++); currentNewLine = String(newLineNum++); } return (
{currentOldLine} {currentNewLine} {change.added ? '+' : change.removed ? '-' : ' '} {line}
); }); })}
); }; export default DiffReviewModal;