-
Notifications
You must be signed in to change notification settings - Fork 47
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
(Fix) FIxed the view all tabs on stock management dashboard , under inventory alerts, issuing and receiving #248
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
import React from 'react'; | ||
import { Modal, Table, TableHead, TableRow, TableHeader, TableBody, TableCell, TableContainer } from '@carbon/react'; | ||
|
||
const ExpiredStockModal = ({ open, onClose, expiredStock }) => { | ||
const headers = [ | ||
{ key: 'drugName', header: 'Drug Name' }, | ||
{ key: 'batchNo', header: 'Batch No' }, | ||
{ key: 'quantity', header: 'Quantity' }, | ||
{ key: 'dispensingUnitName', header: 'Unit' }, | ||
{ key: 'expiration', header: 'Expiration Date' }, | ||
]; | ||
|
||
const formatDate = (dateString) => { | ||
if (!dateString) return 'N/A'; | ||
const date = new Date(dateString); | ||
return new Intl.DateTimeFormat('en-GB', { | ||
year: 'numeric', | ||
month: 'short', | ||
day: '2-digit', | ||
}).format(date); | ||
}; | ||
|
||
return ( | ||
<Modal | ||
open={open} | ||
onRequestClose={onClose} | ||
modalHeading="Expired Stock" | ||
primaryButtonText="Close" | ||
onSecondarySubmit={onClose} | ||
size="lg" | ||
> | ||
<div> | ||
{expiredStock.length > 0 ? ( | ||
<TableContainer> | ||
<Table> | ||
<TableHead> | ||
<TableRow> | ||
{headers.map((header) => ( | ||
<TableHeader key={header.key}>{header.header}</TableHeader> | ||
))} | ||
</TableRow> | ||
</TableHead> | ||
<TableBody> | ||
{expiredStock.map((item, index) => ( | ||
<TableRow key={index}> | ||
<TableCell>{item?.drugName || 'N/A'}</TableCell> | ||
<TableCell>{item?.batchNo || 'N/A'}</TableCell> | ||
<TableCell>{item?.quantity || 'N/A'}</TableCell> | ||
<TableCell>{item?.dispensingUnitName || 'N/A'}</TableCell> | ||
<TableCell>{formatDate(item?.expiration)}</TableCell> | ||
</TableRow> | ||
))} | ||
</TableBody> | ||
</Table> | ||
</TableContainer> | ||
) : ( | ||
<p>No expired stock data available.</p> | ||
)} | ||
</div> | ||
</Modal> | ||
); | ||
}; | ||
|
||
export default ExpiredStockModal; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,12 @@ | ||
import React from 'react'; | ||
import React, { useState } from 'react'; | ||
import { useTranslation } from 'react-i18next'; | ||
import { Button } from '@carbon/react'; | ||
import { navigate, useLayoutType } from '@openmrs/esm-framework'; | ||
import styles from './stock-home-detail-card.scss'; | ||
import { ResourceRepresentation } from '../core/api/api'; | ||
import { DocumentImport } from '@carbon/react/icons'; | ||
import { useStockIssuing } from './stock-home-issuing.resource'; | ||
import IssuingStockModal from './stock-home-issuing-modal.component'; | ||
|
||
const StockHomeIssuingCard = () => { | ||
const { t } = useTranslation(); | ||
|
@@ -16,6 +17,8 @@ const StockHomeIssuingCard = () => { | |
totalCount: true, | ||
}); | ||
|
||
const [isModalOpen, setModalOpen] = useState(false); | ||
|
||
if (isLoading) return <></>; | ||
|
||
if (items?.length === 0) { | ||
|
@@ -64,7 +67,7 @@ const StockHomeIssuingCard = () => { | |
</div> | ||
</div> | ||
))} | ||
<Button | ||
{/* <Button | ||
onClick={() => { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. remove unused code |
||
navigate({ | ||
to: `${window.getOpenmrsSpaBase()}stock-management/requisitions`, | ||
|
@@ -73,7 +76,12 @@ const StockHomeIssuingCard = () => { | |
kind="ghost" | ||
> | ||
View All | ||
</Button> */} | ||
<Button onClick={() => setModalOpen(true)} kind="ghost"> | ||
View All | ||
</Button> | ||
|
||
<IssuingStockModal open={isModalOpen} onClose={() => setModalOpen(false)} issuingStock={items} /> | ||
</> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. lets use |
||
); | ||
}; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
import React from 'react'; | ||
import { Modal, Table, TableHead, TableRow, TableHeader, TableBody, TableCell, TableContainer } from '@carbon/react'; | ||
|
||
const IssuingStockModal = ({ open, onClose, issuingStock }) => { | ||
const headers = [ | ||
{ key: 'status', header: 'Status' }, | ||
{ key: 'sourceName', header: 'Source' }, | ||
{ key: 'destinationName', header: 'Destination' }, | ||
{ key: 'stockItemName', header: 'Stock Item' }, | ||
{ key: 'stockItemPackagingUOMName', header: 'Unit' }, | ||
{ key: 'quantity', header: 'Quantity' }, | ||
]; | ||
|
||
return ( | ||
<Modal | ||
samsonmwanzia marked this conversation as resolved.
Show resolved
Hide resolved
|
||
open={open} | ||
onRequestClose={onClose} | ||
modalHeading="Issued Stock" | ||
primaryButtonText="Close" | ||
onSecondarySubmit={onClose} | ||
size="lg" | ||
> | ||
<div> | ||
{issuingStock && issuingStock.length > 0 ? ( | ||
<TableContainer> | ||
<Table> | ||
<TableHead> | ||
<TableRow> | ||
{headers.map((header) => ( | ||
<TableHeader key={header.key}>{header.header}</TableHeader> | ||
))} | ||
</TableRow> | ||
</TableHead> | ||
<TableBody> | ||
{issuingStock.map((item, index) => ( | ||
<TableRow key={index}> | ||
<TableCell>{item?.status || 'N/A'}</TableCell> | ||
<TableCell>{item?.sourceName || 'N/A'}</TableCell> | ||
<TableCell>{item?.destinationName || 'N/A'}</TableCell> | ||
<TableCell>{item?.stockItemName || 'N/A'}</TableCell> | ||
<TableCell>{item?.stockItemPackagingUOMName || 'N/A'}</TableCell> | ||
<TableCell>{item?.quantity || 'N/A'}</TableCell> | ||
</TableRow> | ||
))} | ||
</TableBody> | ||
</Table> | ||
</TableContainer> | ||
) : ( | ||
<p>No issued stock data available.</p> | ||
)} | ||
</div> | ||
</Modal> | ||
); | ||
}; | ||
|
||
export default IssuingStockModal; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
import React from 'react'; | ||
import { Modal, Table, TableHead, TableRow, TableHeader, TableBody, TableCell, TableContainer } from '@carbon/react'; | ||
|
||
const ReceivingStockModal = ({ open, onClose, receivingStock }) => { | ||
const headers = [ | ||
{ key: 'status', header: 'Status' }, | ||
{ key: 'sourceName', header: 'Source' }, | ||
{ key: 'destinationName', header: 'Destination' }, | ||
{ key: 'stockItemName', header: 'Stock Item' }, | ||
{ key: 'stockItemPackagingUOMName', header: 'Unit' }, | ||
{ key: 'quantity', header: 'Quantity' }, | ||
]; | ||
|
||
return ( | ||
<Modal | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. lets use the stick to using the |
||
open={open} | ||
onRequestClose={onClose} | ||
modalHeading="Received Stock" | ||
primaryButtonText="Close" | ||
onSecondarySubmit={onClose} | ||
size="lg" | ||
> | ||
<div> | ||
{receivingStock && receivingStock.length > 0 ? ( | ||
<TableContainer> | ||
<Table> | ||
<TableHead> | ||
<TableRow> | ||
{headers.map((header) => ( | ||
<TableHeader key={header.key}>{header.header}</TableHeader> | ||
))} | ||
</TableRow> | ||
</TableHead> | ||
<TableBody> | ||
{receivingStock.map((item, index) => | ||
item?.stockOperationItems.map((stock, stockIndex) => ( | ||
<TableRow key={`${index}-${stockIndex}`}> | ||
<TableCell>{item?.status || 'N/A'}</TableCell> | ||
<TableCell>{item?.sourceName || 'N/A'}</TableCell> | ||
<TableCell>{item?.destinationName || 'N/A'}</TableCell> | ||
<TableCell>{stock?.stockItemName || 'N/A'}</TableCell> | ||
<TableCell>{stock?.stockItemPackagingUOMName || 'N/A'}</TableCell> | ||
<TableCell>{stock?.quantity || 'N/A'}</TableCell> | ||
</TableRow> | ||
)), | ||
)} | ||
</TableBody> | ||
</Table> | ||
</TableContainer> | ||
) : ( | ||
<p>No received stock data available.</p> | ||
)} | ||
</div> | ||
</Modal> | ||
); | ||
}; | ||
|
||
export default ReceivingStockModal; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lets clean out on unused code if its nolonger necessary