🐛 Equipping/unequipping gear in EquipmentTab doesn't work #123
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Bug
In the EquipmentTab, clicking "Equip" on an inventory item or "Unequip" on an equipped item doesn't seem to change the equipment state.
Investigation
The equip/unequip flow involves:
EquipmentTab.tsx):handleEquipcallsstoreEquipItem(instanceId, slot),handleUnequipcallsstoreUnequipItem(slot)craftingStore.ts): The store hasequipItemandunequipItemactionscrafting-actions/equipment-actions.ts): Contains the actualequipItem()andunequipItem()functionsThe
equipItemfunction inequipment-actions.tscallsCraftingUtils.canEquipInSlot()which validates whether the item can go in the target slot. If this validation fails (returns false), the equip silently fails with no user feedback.Potential issues:
canEquipInSlotmay be too restrictive — need to check if slot validation logic is correctInventoryListcomponent passesonEquipwhich callsstoreEquipItem(instanceId, slot)but the store'sequipItemaction may not match the expected signature (the action layer function takesgetandsetparameters, but the store may not pass them correctly)equipItemis not exposed — looking atcraftingStore.ts, there is noequipItemaction defined in the store. The store only hasdeleteEquipmentInstance. TheequipItemandunequipItemfunctions exist inequipment-actions.tsbut are never wired into the store's action interface.Files Involved
src/components/game/tabs/EquipmentTab.tsxsrc/components/game/tabs/EquipmentTab/InventoryList.tsxsrc/components/game/tabs/EquipmentTab/EquipmentSlotGrid.tsxsrc/lib/game/crafting-actions/equipment-actions.tssrc/lib/game/stores/craftingStore.tssrc/lib/game/stores/craftingStore.types.tsSuggested Fix
equipItemandunequipItemare properly exposed in the crafting store's action interfacegetandsetto the action functionscanEquipInSlotvalidation logic✅ Fixed. Changes made:
equipItem: (instanceId: string, slot: EquipmentSlot) => booleanandunequipItem: (slot: EquipmentSlot) => voidto theCraftingActionsinterface; addedEquipmentSlotimportequipItem/unequipItemfromequipment-actions.ts(aliased to avoid name conflict); wired them as store actions that delegate to the action functions withget/setparametershandleEquipto return the boolean result fromstoreEquipItem(matching theInventoryListprop type(instanceId: string, slot: EquipmentSlot) => boolean)Root cause:
equipItem/unequipItemfunctions existed inequipment-actions.tsbut were never exposed in the crafting store's action interface. The UI was callingstoreEquipItem/storeUnequipItemwhich didn't exist on the store.✅ Fixed equip/unequip gear - wired equipItem/unequipItem actions into crafting store and fixed type mismatch in EquipmentTab