From 7c5fe019f13e51c63134b48f9c5d1b1353192e04 Mon Sep 17 00:00:00 2001 From: MayaTheShy Date: Sat, 21 Mar 2026 16:49:29 -0400 Subject: [PATCH] Add CraftingPanel component for crafting functionality --- web/client/src/components/CraftingPanel.jsx | 71 +++++++++++++++++++++ 1 file changed, 71 insertions(+) create mode 100644 web/client/src/components/CraftingPanel.jsx diff --git a/web/client/src/components/CraftingPanel.jsx b/web/client/src/components/CraftingPanel.jsx new file mode 100644 index 0000000..2b40a4f --- /dev/null +++ b/web/client/src/components/CraftingPanel.jsx @@ -0,0 +1,71 @@ +import React, { useState } from 'react'; +import { useInventoryStore } from '../store/inventoryStore'; +import { formatItemName } from '../utils/itemUtils'; +import ItemIcon from './ItemIcon'; +import './CraftingPanel.css'; + +function CraftingPanel() { + const craftable = useInventoryStore((state) => state.craftable); + const craftTurtleOk = useInventoryStore((state) => state.craftTurtleOk); + const craftItem = useInventoryStore((state) => state.craftItem); + const [craftingIdx, setCraftingIdx] = useState(null); + + const handleCraft = async (idx) => { + setCraftingIdx(idx); + await craftItem(idx); + setCraftingIdx(null); + }; + + return ( +
+
+

🔨 Crafting

+
+ 🐢 {craftTurtleOk ? 'Turtle Online' : 'Turtle Offline'} +
+
+ + {!craftTurtleOk && ( +
+ ⚠️ Crafting turtle is not connected. Crafting commands will fail. +
+ )} + +
+ {(craftable || []).map((recipe, idx) => ( +
+
+ +
+ {formatItemName(recipe.output)} + Produces {recipe.count || 1} +
+
+ +
+ {recipe.slots && Object.entries(recipe.slots).map(([slot, item]) => ( +
+ + {formatItemName(item)} +
+ ))} +
+ + +
+ ))} + {(!craftable || craftable.length === 0) && ( +
No crafting recipes configured
+ )} +
+
+ ); +} + +export default CraftingPanel;