import React from 'react'; import { Dialog, DialogTitle, DialogContent, DialogActions, Button, Typography, Box, Chip, IconButton, Divider } from '@mui/material'; import { Close as CloseIcon, Check as CheckIcon } from '@mui/icons-material'; import type { DiffPreviewData, DiffSegment } from '../../../utils/getSectionDiffs'; interface DiffPreviewModalProps { isOpen: boolean; diffData: DiffPreviewData | null; onAccept: () => void; onReject: () => void; loading?: boolean; } function renderDiffSegments(segments: DiffSegment[]): React.ReactNode { return segments.map((seg, i) => { if (seg.added) { return ( {seg.value} ); } if (seg.removed) { return ( {seg.value} ); } return {seg.value}; }); } export const DiffPreviewModal: React.FC = ({ isOpen, diffData, onAccept, onReject, loading = false, }) => { if (!diffData) return null; const hasAnyChange = diffData.introductionChanged || diffData.sectionDiffs.some(s => s.changed); return ( SEO Recommendations — Review Changes } label={`${diffData.sectionDiffs.filter(s => s.changed).length} section(s) changed`} color="warning" size="small" variant="outlined" /> Added Removed {!hasAnyChange && ( No changes detected between original and recommended content. )} {diffData.introductionChanged && ( Introduction {renderDiffSegments(diffData.introductionDiff!)} )} {diffData.sectionDiffs.map((section, idx) => { if (!section.changed) return null; return ( {section.heading} {renderDiffSegments(section.segments)} ); })} ); }; export default DiffPreviewModal;