🐛 Equipping/unequipping gear in EquipmentTab doesn't work #123

Closed
opened 2026-05-22 13:20:56 +02:00 by Anexim · 2 comments
Owner

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:

  1. UI Layer (EquipmentTab.tsx): handleEquip calls storeEquipItem(instanceId, slot), handleUnequip calls storeUnequipItem(slot)
  2. Store Layer (craftingStore.ts): The store has equipItem and unequipItem actions
  3. Action Layer (crafting-actions/equipment-actions.ts): Contains the actual equipItem() and unequipItem() functions

The equipItem function in equipment-actions.ts calls CraftingUtils.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:

  1. canEquipInSlot may be too restrictive — need to check if slot validation logic is correct
  2. No error feedback — when equip fails, the user gets no indication of why
  3. The InventoryList component passes onEquip which calls storeEquipItem(instanceId, slot) but the store's equipItem action may not match the expected signature (the action layer function takes get and set parameters, but the store may not pass them correctly)
  4. Store's equipItem is not exposed — looking at craftingStore.ts, there is no equipItem action defined in the store. The store only has deleteEquipmentInstance. The equipItem and unequipItem functions exist in equipment-actions.ts but are never wired into the store's action interface.

Files Involved

  • src/components/game/tabs/EquipmentTab.tsx
  • src/components/game/tabs/EquipmentTab/InventoryList.tsx
  • src/components/game/tabs/EquipmentTab/EquipmentSlotGrid.tsx
  • src/lib/game/crafting-actions/equipment-actions.ts
  • src/lib/game/stores/craftingStore.ts
  • src/lib/game/stores/craftingStore.types.ts

Suggested Fix

  1. Verify that equipItem and unequipItem are properly exposed in the crafting store's action interface
  2. Ensure the store passes get and set to the action functions
  3. Add user feedback (toast/alert) when equip fails
  4. Check canEquipInSlot validation logic
## 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: 1. **UI Layer** (`EquipmentTab.tsx`): `handleEquip` calls `storeEquipItem(instanceId, slot)`, `handleUnequip` calls `storeUnequipItem(slot)` 2. **Store Layer** (`craftingStore.ts`): The store has `equipItem` and `unequipItem` actions 3. **Action Layer** (`crafting-actions/equipment-actions.ts`): Contains the actual `equipItem()` and `unequipItem()` functions The `equipItem` function in `equipment-actions.ts` calls `CraftingUtils.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: 1. **`canEquipInSlot` may be too restrictive** — need to check if slot validation logic is correct 2. **No error feedback** — when equip fails, the user gets no indication of why 3. **The `InventoryList` component** passes `onEquip` which calls `storeEquipItem(instanceId, slot)` but the store's `equipItem` action may not match the expected signature (the action layer function takes `get` and `set` parameters, but the store may not pass them correctly) 4. **Store's `equipItem` is not exposed** — looking at `craftingStore.ts`, there is no `equipItem` action defined in the store. The store only has `deleteEquipmentInstance`. The `equipItem` and `unequipItem` functions exist in `equipment-actions.ts` but are never wired into the store's action interface. ## Files Involved - `src/components/game/tabs/EquipmentTab.tsx` - `src/components/game/tabs/EquipmentTab/InventoryList.tsx` - `src/components/game/tabs/EquipmentTab/EquipmentSlotGrid.tsx` - `src/lib/game/crafting-actions/equipment-actions.ts` - `src/lib/game/stores/craftingStore.ts` - `src/lib/game/stores/craftingStore.types.ts` ## Suggested Fix 1. Verify that `equipItem` and `unequipItem` are properly exposed in the crafting store's action interface 2. Ensure the store passes `get` and `set` to the action functions 3. Add user feedback (toast/alert) when equip fails 4. Check `canEquipInSlot` validation logic
Anexim added the ai:todo label 2026-05-22 13:20:56 +02:00
n8n-gitea was assigned by Anexim 2026-05-22 13:20:56 +02:00
Author
Owner

Fixed. Changes made:

  1. craftingStore.types.ts — Added equipItem: (instanceId: string, slot: EquipmentSlot) => boolean and unequipItem: (slot: EquipmentSlot) => void to the CraftingActions interface; added EquipmentSlot import
  2. craftingStore.ts — Imported equipItem/unequipItem from equipment-actions.ts (aliased to avoid name conflict); wired them as store actions that delegate to the action functions with get/set parameters
  3. EquipmentTab.tsx — Updated handleEquip to return the boolean result from storeEquipItem (matching the InventoryList prop type (instanceId: string, slot: EquipmentSlot) => boolean)

Root cause: equipItem/unequipItem functions existed in equipment-actions.ts but were never exposed in the crafting store's action interface. The UI was calling storeEquipItem/storeUnequipItem which didn't exist on the store.

✅ Fixed. Changes made: 1. **craftingStore.types.ts** — Added `equipItem: (instanceId: string, slot: EquipmentSlot) => boolean` and `unequipItem: (slot: EquipmentSlot) => void` to the `CraftingActions` interface; added `EquipmentSlot` import 2. **craftingStore.ts** — Imported `equipItem`/`unequipItem` from `equipment-actions.ts` (aliased to avoid name conflict); wired them as store actions that delegate to the action functions with `get`/`set` parameters 3. **EquipmentTab.tsx** — Updated `handleEquip` to return the boolean result from `storeEquipItem` (matching the `InventoryList` prop type `(instanceId: string, slot: EquipmentSlot) => boolean`) Root cause: `equipItem`/`unequipItem` functions existed in `equipment-actions.ts` but were never exposed in the crafting store's action interface. The UI was calling `storeEquipItem`/`storeUnequipItem` which didn't exist on the store.
Author
Owner

Fixed equip/unequip gear - wired equipItem/unequipItem actions into crafting store and fixed type mismatch in EquipmentTab

✅ Fixed equip/unequip gear - wired equipItem/unequipItem actions into crafting store and fixed type mismatch in EquipmentTab
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: Anexim/Mana-Loop#123