Skip to content

Commit 56afdc8

Browse files
committed
miscellaneous
1 parent 8e3e139 commit 56afdc8

5 files changed

Lines changed: 13 additions & 2 deletions

File tree

backend/dashboard/views.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@ def get(self, request):
4040
status_label = 'CRITICAL'
4141
elif stock.quantity_available <= stock.reorder_level:
4242
status_label = 'LOW'
43+
elif stock.quantity_available > stock.max_stock_level:
44+
status_label = 'OVERSTOCK'
4345
else:
4446
status_label = 'NORMAL'
4547

@@ -168,4 +170,4 @@ def get(self, request):
168170
]
169171

170172
serializer = SupplierSummarySerializer(data, many=True)
171-
return Response(serializer.data, status=status.HTTP_200_OK)
173+
return Response(serializer.data, status=status.HTTP_200_OK)

backend/db.sqlite3

0 Bytes
Binary file not shown.

frontend/src/pages/DashboardPage.jsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ function DashboardPage() {
7777
const stats = useMemo(() => {
7878
const criticalCount = stockOverview.filter((item) => item.status === 'CRITICAL').length
7979
const lowCount = stockOverview.filter((item) => item.status === 'LOW').length
80+
const overstockCount = stockOverview.filter((item) => item.status === 'OVERSTOCK').length
8081
const totalAvgDailyConsumption = consumptionSummary.reduce(
8182
(sum, item) => sum + Number(item.avg_daily_consumption || 0),
8283
0,
@@ -91,7 +92,7 @@ function DashboardPage() {
9192
{
9293
label: 'Reorder Alerts',
9394
value: lowStockAlerts.length,
94-
helper: `${criticalCount} critical and ${lowCount} low stock items`,
95+
helper: `${criticalCount} critical, ${lowCount} low, ${overstockCount} overstock`,
9596
},
9697
{
9798
label: `Past ${consumptionDays}D Avg Usage`,

frontend/src/pages/StocksPage.jsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,11 @@ function getStockStatus(stock) {
2929
const qty = Number(stock.quantity_available || 0)
3030
const safety = Number(stock.safety_stock || 0)
3131
const reorder = Number(stock.reorder_level || 0)
32+
const max = Number(stock.max_stock_level || 0)
3233

3334
if (qty <= safety) return 'CRITICAL'
3435
if (qty <= reorder) return 'LOW'
36+
if (qty > max) return 'OVERSTOCK'
3537
return 'NORMAL'
3638
}
3739

@@ -190,6 +192,7 @@ function StocksPage() {
190192
<option value="all">All status</option>
191193
<option value="CRITICAL">Critical</option>
192194
<option value="LOW">Low</option>
195+
<option value="OVERSTOCK">Overstock</option>
193196
<option value="NORMAL">Normal</option>
194197
</select>
195198
</div>

frontend/src/styles/pages.css

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,11 @@
9494
color: #166534;
9595
}
9696

97+
.status-overstock {
98+
background: #ede9fe;
99+
color: #5b21b6;
100+
}
101+
97102
.action-grid {
98103
margin-top: 0.65rem;
99104
display: grid;

0 commit comments

Comments
 (0)