From c1399fb44e60a730f0fd10fe71d2877ac01815ef Mon Sep 17 00:00:00 2001 From: MayaTheShy Date: Sat, 21 Mar 2026 16:53:11 -0400 Subject: [PATCH] Add StorageOverview component for inventory management display --- web/client/src/components/StorageOverview.jsx | 123 ++++++++++++++++++ 1 file changed, 123 insertions(+) create mode 100644 web/client/src/components/StorageOverview.jsx diff --git a/web/client/src/components/StorageOverview.jsx b/web/client/src/components/StorageOverview.jsx new file mode 100644 index 0000000..5340ecc --- /dev/null +++ b/web/client/src/components/StorageOverview.jsx @@ -0,0 +1,123 @@ +import React from 'react'; +import { useInventoryStore } from '../store/inventoryStore'; +import './StorageOverview.css'; + +function StorageOverview() { + const inventory = useInventoryStore((state) => state.inventory); + const activity = useInventoryStore((state) => state.activity); + const connected = useInventoryStore((state) => state.connected); + const lastUpdate = useInventoryStore((state) => state.lastUpdate); + const craftTurtleOk = useInventoryStore((state) => state.craftTurtleOk); + const requestScan = useInventoryStore((state) => state.requestScan); + + const usedPercent = inventory.totalSlots > 0 + ? Math.round((inventory.usedSlots / inventory.totalSlots) * 100) + : 0; + + const getUsageColor = () => { + if (usedPercent >= 90) return 'critical'; + if (usedPercent >= 75) return 'warning'; + return 'normal'; + }; + + const timeSinceUpdate = lastUpdate + ? Math.floor((Date.now() - lastUpdate) / 1000) + : null; + + return ( +
+
+

📊 Storage

+ +
+ + {/* Storage capacity bar */} +
+
+ Capacity + {usedPercent}% +
+
+
+
+
+ {inventory.usedSlots} / {inventory.totalSlots} slots +
+
+ + {/* Stats grid */} +
+
+ Total Items + {(inventory.grandTotal || 0).toLocaleString()} +
+
+ Item Types + {(inventory.itemList || []).length} +
+
+ Chests + {inventory.chestCount || 0} +
+
+ Free Slots + {inventory.freeSlots || 0} +
+
+ Furnaces + {inventory.furnaceCount || 0} +
+
+ Craft Turtle + + {craftTurtleOk ? '✅ Online' : '❌ Offline'} + +
+
+ + {/* Peripherals */} +
+

Peripherals

+
+
+ {inventory.dropperOk ? '✅' : '❌'} Dropper +
+
+ {inventory.barrelOk ? '✅' : '❌'} Barrel +
+
+
+ + {/* Activity indicators */} +
+

Activity

+
+ {activity.sorting &&
📦 Sorting
} + {activity.smelting &&
🔥 Smelting
} + {activity.dispensing &&
📤 Dispensing
} + {activity.composting &&
🌱 Composting
} + {activity.defragging &&
🔧 Defragging
} + {activity.crafting &&
🔨 Crafting
} + {!activity.sorting && !activity.smelting && !activity.dispensing && + !activity.composting && !activity.defragging && !activity.crafting && ( +
💤 Idle
+ )} +
+
+ + {/* Last update */} + {lastUpdate > 0 && ( +
+ Last update: {timeSinceUpdate !== null ? `${timeSinceUpdate}s ago` : 'Never'} +
+ )} +
+ ); +} + +export default StorageOverview;