Skip to content

Commit

Permalink
Add new "available" badge to stock page (#7368)
Browse files Browse the repository at this point in the history
  • Loading branch information
SchrodingersGat authored May 28, 2024
1 parent f3223c6 commit 4cf395c
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/frontend/src/pages/stock/StockDetail.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -501,6 +501,9 @@ export default function StockDetail() {
);

const stockBadges: ReactNode[] = useMemo(() => {
let available = (stockitem?.quantity ?? 0) - (stockitem?.allocated ?? 0);
available = Math.max(0, available);

return instanceQuery.isLoading
? []
: [
Expand All @@ -521,6 +524,12 @@ export default function StockDetail() {
visible={!stockitem.serial}
key="quantity"
/>,
<DetailsBadge
color="yellow"
label={t`Available` + `: ${available}`}
visible={!stockitem.serial && available != stockitem.quantity}
key="available"
/>,
<DetailsBadge
color="blue"
label={t`Batch Code` + `: ${stockitem.batch}`}
Expand Down

0 comments on commit 4cf395c

Please sign in to comment.