import React, { useState } from 'react'; import { ExcelRow, COLUMNS } from '../types'; import { Clock, Undo2, Package, Box, DollarSign, FileText, Search, Filter } from 'lucide-react'; import { cn } from '../lib/utils'; interface PendingValidationViewProps { data: ExcelRow[]; pendingRows: Record; rowStatuses: Record; onRevertRow: (articleNo: string) => void; onEdit: (index: number) => void; } export function PendingValidationView({ data, pendingRows, rowStatuses, onRevertRow, onEdit }: PendingValidationViewProps) { const [search, setSearch] = useState(''); const pendingEntries = Object.entries(pendingRows); const filteredEntries = search ? pendingEntries.filter(([articleNo, { articleName }]) => articleNo.toLowerCase().includes(search.toLowerCase()) || articleName.toLowerCase().includes(search.toLowerCase()) ) : pendingEntries; const getFieldDiff = (original: ExcelRow, updated: ExcelRow, colIndex: number) => { const orig = original[colIndex]; const upd = updated[colIndex]; if (orig !== upd) { return { from: String(orig ?? ''), to: String(upd ?? '') }; } return null; }; const getChangedFields = (original: ExcelRow, updated: ExcelRow) => { const changes: { field: string; from: string; to: string }[] = []; const fieldConfigs = [ { col: COLUMNS.DETAILS_EN, label: 'Details EN' }, { col: COLUMNS.DETAILS_DE, label: 'Details DE' }, { col: COLUMNS.INNER_L, label: 'Inner L' }, { col: COLUMNS.INNER_W, label: 'Inner W' }, { col: COLUMNS.INNER_H, label: 'Inner H' }, { col: COLUMNS.OUTER_L, label: 'Outer L' }, { col: COLUMNS.OUTER_W, label: 'Outer W' }, { col: COLUMNS.OUTER_H, label: 'Outer H' }, { col: COLUMNS.UNITS_INNER, label: 'Units Inner' }, { col: COLUMNS.UNITS_OUTER, label: 'Units Outer' }, { col: COLUMNS.MOQ, label: 'MOQ' }, { col: COLUMNS.BARCODE, label: 'Barcode' }, { col: COLUMNS.TARIFF_CODE, label: 'Tariff Code' }, { col: COLUMNS.COUNTRY_ORIGIN, label: 'Country' }, { col: COLUMNS.RECOMMENDED_AGE, label: 'Recommended Age' }, ]; fieldConfigs.forEach(({ col, label }) => { const diff = getFieldDiff(original, updated, col); if (diff) { changes.push({ field: label, ...diff }); } }); return changes; }; return (

Pending Validation

{pendingEntries.length} change{pendingEntries.length !== 1 ? 's' : ''} pending
setSearch(e.target.value)} className="bg-slate-800 border border-slate-700 rounded-md pl-9 pr-3 py-2 text-sm text-white placeholder:text-slate-500 focus:outline-none focus:border-blue-500 w-64" />
{filteredEntries.length === 0 ? (
{search ? (

No pending changes match your search

) : (

No pending validation changes

)}
) : (
{filteredEntries.map(([articleNo, { rowIndex, originalData, newData, articleName }]) => { const changes = getChangedFields(originalData, newData); const status = rowStatuses[articleNo]; return (
{articleNo}
{articleName}
Changes ({changes.length})
{changes.map((change, idx) => (
{change.field}: {change.from} {change.to}
))}
); })}
)}
); }