import { PureComponent } from 'react'; import Box from '@mui/material/Box'; import Button from '@mui/material/Button'; import Stack from '@mui/material/Stack'; import Table from '@mui/material/Table'; import TableBody from '@mui/material/TableBody'; import TableCell from '@mui/material/TableCell'; import TableContainer from '@mui/material/TableContainer'; import TableHead from '@mui/material/TableHead'; import TableRow from '@mui/material/TableRow'; import AddIcon from '@mui/icons-material/Add'; import DeleteSweepOutlinedIcon from '@mui/icons-material/DeleteSweepOutlined'; import { PanelTile } from 'dashgui/panels'; import { LINE_COLUMNS, hasArticleLines } from './manifestConfig'; import ManifestFormLine from './ManifestFormLine'; class ManifestLines extends PureComponent { render() { const { lines, saving, linesColor, onLineChange, onAddLine, onRemoveLine, onRemoveAllLines, columns = LINE_COLUMNS, supplierArticlesMap = {}, supplierArticlesByLineKey = {}, supplierArticlesLoading = false, loadingLineKeys = {}, onSkuBlur, onCreateArticle, onSearchArticle, onRemoveSupplierArticle, busySupplierArticleLineKeys = {}, wide = 4, ledgerLinesById = {}, onBookLine, } = this.props; const hasArticles = hasArticleLines(lines); return ( = 4 ? { gridColumn: { xs: '1 / -1', sm: '1 / -1', md: 'span 4' } } : {}), ...(!hasArticles ? { border: '1.5px solid', borderColor: 'error.main', } : {}), }} > {columns.map((col) => ( {col.label} ))} {Array.isArray(lines) && lines.map((line, index) => { const lineKey = line.key ?? index; const rawSku = line.sku != null ? String(line.sku).trim() : ''; const matched = supplierArticlesByLineKey[lineKey] || (rawSku ? supplierArticlesMap[rawSku.toLowerCase()] || supplierArticlesMap[rawSku] : null); const isLineLoading = loadingLineKeys[lineKey] || (supplierArticlesLoading && !matched); const ledgerLine = line.id != null ? ledgerLinesById[line.id] : null; return ( ); })}
); } } export default ManifestLines;