'use client'; import { Loader2 } from 'lucide-react'; import { useTranslations } from 'next-intl'; import { Badge } from '@/components/ui/badge'; import { Dialog, DialogContent, DialogDescription, DialogHeader, DialogTitle, } from '@/components/ui/dialog'; import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow, } from '@/components/ui/table'; import type { ConfigDiffResult } from '@/lib/services/openflare'; interface DiffDialogProps { open: boolean; onOpenChange: (open: boolean) => void; diff: ConfigDiffResult | null; loading: boolean; error: string | null; } function DiffChipList({ title, items }: { title: string; items: string[] }) { const t = useTranslations('configVersions'); return (

{title}

{t('itemCount', { count: items.length })}
{items.length > 0 ? (
{items.map((item) => ( {item} ))}
) : (

{t('noChange')}

)}
); } export function DiffDialog({ open, onOpenChange, diff, loading, error, }: DiffDialogProps) { const t = useTranslations('configVersions'); return ( {t('diffTitle')} {t('diffDesc')} {loading ? (
{t('loadingDiff')}
) : error ? (

{error}

) : diff ? (

{t('activeVersion')}

{diff.active_version || t('none')}

{t('addedDomains')}

{diff.added_domains.length}

{t('removedDomains')}

{diff.removed_domains.length}

{t('modifiedDomains')}

{diff.modified_domains.length}

{diff.main_config_changed ? t('mainChanged') : t('mainUnchanged')} {diff.waf_config_changed ? t('wafChanged') : t('wafUnchanged')} {t('websiteDelta', { from: diff.active_website_count, to: diff.current_website_count, })}
{diff.changed_option_details.length > 0 ? (
{t('optionKey')} {t('activeValue')} {t('pendingValue')} {diff.changed_option_details.map((item) => ( {item.key} {item.previous_value === '' ? t('emptyValue') : item.previous_value} {item.current_value === '' ? t('emptyValue') : item.current_value} ))}
) : (

{t('noOptionChanges')}

)}
) : null}
); }