|
| 1 | +import React from 'react'; |
| 2 | +import { Modal, Table, TableHead, TableRow, TableHeader, TableBody, TableCell, TableContainer } from '@carbon/react'; |
| 3 | + |
| 4 | +const ReceivingStockModal = ({ open, onClose, receivingStock }) => { |
| 5 | + const headers = [ |
| 6 | + { key: 'status', header: 'Status' }, |
| 7 | + { key: 'sourceName', header: 'Source' }, |
| 8 | + { key: 'destinationName', header: 'Destination' }, |
| 9 | + { key: 'stockItemName', header: 'Stock Item' }, |
| 10 | + { key: 'stockItemPackagingUOMName', header: 'Unit' }, |
| 11 | + { key: 'quantity', header: 'Quantity' }, |
| 12 | + ]; |
| 13 | + |
| 14 | + return ( |
| 15 | + <Modal |
| 16 | + open={open} |
| 17 | + onRequestClose={onClose} |
| 18 | + modalHeading="Received Stock" |
| 19 | + primaryButtonText="Close" |
| 20 | + onSecondarySubmit={onClose} |
| 21 | + size="lg" |
| 22 | + > |
| 23 | + <div> |
| 24 | + {receivingStock && receivingStock.length > 0 ? ( |
| 25 | + <TableContainer> |
| 26 | + <Table> |
| 27 | + <TableHead> |
| 28 | + <TableRow> |
| 29 | + {headers.map((header) => ( |
| 30 | + <TableHeader key={header.key}>{header.header}</TableHeader> |
| 31 | + ))} |
| 32 | + </TableRow> |
| 33 | + </TableHead> |
| 34 | + <TableBody> |
| 35 | + {receivingStock.map((item, index) => |
| 36 | + item?.stockOperationItems.map((stock, stockIndex) => ( |
| 37 | + <TableRow key={`${index}-${stockIndex}`}> |
| 38 | + <TableCell>{item?.status || 'N/A'}</TableCell> |
| 39 | + <TableCell>{item?.sourceName || 'N/A'}</TableCell> |
| 40 | + <TableCell>{item?.destinationName || 'N/A'}</TableCell> |
| 41 | + <TableCell>{stock?.stockItemName || 'N/A'}</TableCell> |
| 42 | + <TableCell>{stock?.stockItemPackagingUOMName || 'N/A'}</TableCell> |
| 43 | + <TableCell>{stock?.quantity || 'N/A'}</TableCell> |
| 44 | + </TableRow> |
| 45 | + )), |
| 46 | + )} |
| 47 | + </TableBody> |
| 48 | + </Table> |
| 49 | + </TableContainer> |
| 50 | + ) : ( |
| 51 | + <p>No received stock data available.</p> |
| 52 | + )} |
| 53 | + </div> |
| 54 | + </Modal> |
| 55 | + ); |
| 56 | +}; |
| 57 | + |
| 58 | +export default ReceivingStockModal; |
0 commit comments