feat(webui): more equipment #826
@ -1,6 +1,7 @@
 | 
			
		||||
import { getAccountIdForRequest } from "@/src/services/loginService";
 | 
			
		||||
import { addEquipment, addPowerSuit, getInventory, updateSlots } from "@/src/services/inventoryService";
 | 
			
		||||
import { productCategoryToSlotName } from "@/src/helpers/purchaseHelpers";
 | 
			
		||||
import { SlotNames } from "@/src/types/purchaseTypes";
 | 
			
		||||
import { InventorySlot } from "@/src/types/inventoryTypes/inventoryTypes";
 | 
			
		||||
import { RequestHandler } from "express";
 | 
			
		||||
 | 
			
		||||
export const addItemsController: RequestHandler = async (req, res) => {
 | 
			
		||||
@ -24,9 +25,22 @@ export const addItemsController: RequestHandler = async (req, res) => {
 | 
			
		||||
    res.end();
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
const productCategoryToSlotName: Record<ItemType, SlotNames> = {
 | 
			
		||||
| 
					
	
	
	
	
	
	
	
	 | 
			||||
    Suits: InventorySlot.SUITS,
 | 
			
		||||
    Pistols: InventorySlot.WEAPONS,
 | 
			
		||||
    Melee: InventorySlot.WEAPONS,
 | 
			
		||||
    LongGuns: InventorySlot.WEAPONS,
 | 
			
		||||
    SpaceSuits: InventorySlot.SPACESUITS,
 | 
			
		||||
    SpaceGuns: InventorySlot.SPACESUITS,
 | 
			
		||||
    SpaceMelee: InventorySlot.SPACESUITS,
 | 
			
		||||
    Sentinels: InventorySlot.SENTINELS,
 | 
			
		||||
    SentinelWeapons: InventorySlot.SENTINELS
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
enum ItemType {
 | 
			
		||||
    Suits = "Suits",
 | 
			
		||||
    SpaceSuits = "SpaceSuits",
 | 
			
		||||
    LongGuns = "LongGuns",
 | 
			
		||||
    Pistols = "Pistols",
 | 
			
		||||
    Melee = "Melee",
 | 
			
		||||
    SpaceGuns = "SpaceGuns",
 | 
			
		||||
 | 
			
		||||
@ -1,6 +1,5 @@
 | 
			
		||||
import { slotPurchaseNameToSlotName } from "@/src/services/purchaseService";
 | 
			
		||||
import { SlotNames, SlotPurchaseName } from "@/src/types/purchaseTypes";
 | 
			
		||||
import { InventorySlot } from "@/src/types/inventoryTypes/inventoryTypes";
 | 
			
		||||
import { SlotPurchaseName } from "@/src/types/purchaseTypes";
 | 
			
		||||
 | 
			
		||||
export const isSlotPurchaseName = (slotPurchaseName: string): slotPurchaseName is SlotPurchaseName => {
 | 
			
		||||
    return slotPurchaseName in slotPurchaseNameToSlotName;
 | 
			
		||||
@ -10,16 +9,3 @@ export const parseSlotPurchaseName = (slotPurchaseName: string): SlotPurchaseNam
 | 
			
		||||
    if (!isSlotPurchaseName(slotPurchaseName)) throw new Error(`invalid slot name ${slotPurchaseName}`);
 | 
			
		||||
    return slotPurchaseName;
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
export const productCategoryToSlotName: Record<string, SlotNames> = {
 | 
			
		||||
    Suits: InventorySlot.SUITS,
 | 
			
		||||
    Pistols: InventorySlot.WEAPONS,
 | 
			
		||||
    Melee: InventorySlot.WEAPONS,
 | 
			
		||||
    LongGuns: InventorySlot.WEAPONS,
 | 
			
		||||
    SpaceSuits: InventorySlot.SPACESUITS,
 | 
			
		||||
    SpaceGuns: InventorySlot.SPACESUITS,
 | 
			
		||||
    SpaceMelee: InventorySlot.SPACESUITS,
 | 
			
		||||
    Sentinels: InventorySlot.SENTINELS,
 | 
			
		||||
    SentinelWeapons: InventorySlot.SENTINELS,
 | 
			
		||||
    MechSuits: InventorySlot.MECHSUITS
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user
	
⚠️ Potential issue
Add error handling for unknown item types.
The default case assumes the item type exists in productCategoryToSlotName. Add validation to prevent runtime errors.
📝 Committable suggestion