Skip to content

Commit

Permalink
sorted the batches expiry date from the most nearing expiring to the …
Browse files Browse the repository at this point in the history
…furthest expiring ind sipensing module (#139)

Co-authored-by: Felix Kiprotich <fkiprotich845>
  • Loading branch information
FelixKiprotich350 authored Dec 17, 2024
1 parent dd031d5 commit 8bacf9a
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/forms/stock-dispense/stock-dispense.component.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,14 @@ const StockDispense: React.FC<StockDispenseProps> = ({ medicationDispense, updat
const drugUuid = medicationDispense?.medicationReference?.reference?.split('/')[1];
const { inventoryItems, error, isLoading } = useDispenseStock(drugUuid);
const validInventoryItems = inventoryItems.filter((item) => isValidBatch(medicationDispense, item));
const validInventoryItemss = inventoryItems
.filter((item) => isValidBatch(medicationDispense, item))
.sort((a, b) => {
const dateA = new Date(a.expiration);
const dateB = new Date(b.expiration);

return dateA.getDate() - dateB.getDate();
});

function parseDate(dateString) {
return new Date(dateString);
Expand Down

0 comments on commit 8bacf9a

Please sign in to comment.