@openmrs/esm-stock-management-app 1.0.1-pre.750 → 1.0.1-pre.758

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,58 @@
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;
@@ -3,7 +3,8 @@ import { Button, Stack, ComboButton, MenuItem } from '@carbon/react';
3
3
  import { Printer } from '@carbon/react/icons';
4
4
  import { useTranslation } from 'react-i18next';
5
5
  import { useStockItem } from '../../../stock-items.resource';
6
- import { showModal } from '@openmrs/esm-framework';
6
+ import { showModal, useConfig } from '@openmrs/esm-framework';
7
+ import { type ConfigObject } from '../../../../config-schema';
7
8
  import styles from './printable-transaction.scss';
8
9
  import { useEffect, useMemo, useState } from 'react';
9
10
  import { StockItemInventoryFilter, useStockItemTransactions } from '../../../stock-items.resource';
@@ -18,6 +19,8 @@ type Props = {
18
19
  const TransactionsPrintAction: React.FC<Props> = ({ columns, data, itemUuid }) => {
19
20
  const { t } = useTranslation();
20
21
 
22
+ const { enablePrintButton } = useConfig<ConfigObject>();
23
+
21
24
  const [stockCardItemFilter, setStockCardItemFilter] = useState<StockItemInventoryFilter>({
22
25
  startIndex: 0,
23
26
  totalCount: true,
@@ -86,22 +89,24 @@ const TransactionsPrintAction: React.FC<Props> = ({ columns, data, itemUuid }) =
86
89
 
87
90
  return (
88
91
  <>
89
- <ComboButton label="Print">
90
- <MenuItem
91
- label={t('printStockCard', 'Print Stock Card')}
92
- renderIcon={(props) => <Printer size={24} {...props} />}
93
- iconDescription="Print Stock Card"
94
- onClick={handleStockcardClick}
95
- disabled={isStockItemLoading || isStockCardLoading}
96
- />
97
- <MenuItem
98
- label={t('printBinCard', 'Print Bin Card')}
99
- renderIcon={(props) => <Printer size={24} {...props} />}
100
- iconDescription="Print Bin Card"
101
- onClick={handleBincardClick}
102
- disabled={isStockItemLoading}
103
- />
104
- </ComboButton>
92
+ {enablePrintButton && (
93
+ <ComboButton label="Print">
94
+ <MenuItem
95
+ label={t('printStockCard', 'Print Stock Card')}
96
+ renderIcon={(props) => <Printer size={24} {...props} />}
97
+ iconDescription="Print Stock Card"
98
+ onClick={handleStockcardClick}
99
+ disabled={isStockItemLoading || isStockCardLoading}
100
+ />
101
+ <MenuItem
102
+ label={t('printBinCard', 'Print Bin Card')}
103
+ renderIcon={(props) => <Printer size={24} {...props} />}
104
+ iconDescription="Print Bin Card"
105
+ onClick={handleBincardClick}
106
+ disabled={isStockItemLoading}
107
+ />
108
+ </ComboButton>
109
+ )}
105
110
  </>
106
111
  );
107
112
  };