import React from 'react'; import { useTranslation } from 'react-i18next'; import { type StockOperationDTO } from '../../../core/api/types/stockOperation/StockOperationDTO'; import { DataTable, Table, TableBody, TableContainer, TableHead, TableHeader, TableRow, TableCell, DataTableSkeleton, Button, } from '@carbon/react'; import styles from './stock-operation-items-form-step.scc.scss'; import { ArrowLeft } from '@carbon/react/icons'; const formatDate = (date: Date | string | null) => { if (!date) return ' '; const d = new Date(date); const day = String(d.getDate()).padStart(2, '0'); const month = String(d.getMonth() + 1).padStart(2, '0'); const year = d.getFullYear(); return `${month}/${day}/${year}`; }; interface ReceivedItemsProps { stockOperation?: StockOperationDTO; onPrevious?: () => void; } const ReceivedItems: React.FC = ({ stockOperation, onPrevious }) => { const { t } = useTranslation(); const headers = [ { key: 'item', header: t('item', 'Item') }, { key: 'requested', header: t('requested', 'Requested') }, { key: 'batch', header: t('batch', 'Batch No') }, { key: 'expiry', header: t('expiry', 'Expiry') }, { key: 'qtySent', header: t('quantitySent', 'Quantity Sent') }, { key: 'qtyReceived', header: t('quantityReceived', 'Quantity Received') }, { key: 'qtyUoM', header: t('quantityUoM', 'Quantity Unit of Measurement(UoM)'), }, ]; const rows = stockOperation?.stockOperationItems?.map((item) => ({ id: item.uuid, item: item.stockItemName, requested: item.quantityRequested || ' ', batch: item.batchNo, expiry: formatDate(item.expiration), qtySent: item.quantity || ' ', qtyReceived: item.quantityReceived || ' ', qtyUoM: item.quantityReceivedPackagingUOMName, })) || []; if (!stockOperation) { return ; } const headerTitle = t('receivedItems', 'Received Items'); return (

{headerTitle}

{({ rows, headers, getHeaderProps, getTableProps, getRowProps }) => ( {headers.map((header) => ( {header.header} ))} {rows.map((row) => ( {row.cells.map((cell) => ( {cell.value} ))} ))}
)}
{typeof onPrevious === 'function' && (
); }; export default ReceivedItems;