From 463a7d8f14e9c277d7a1934634eb5b633774b757 Mon Sep 17 00:00:00 2001 From: AMelonInsideLemon <166175391+AMelonInsideLemon@users.noreply.github.com> Date: Sun, 19 Jan 2025 14:44:37 +0100 Subject: [PATCH] moveproductCategoryToSlotName to addItems --- src/controllers/custom/addItemsController.ts | 16 +++++++++++++++- src/helpers/purchaseHelpers.ts | 16 +--------------- 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/src/controllers/custom/addItemsController.ts b/src/controllers/custom/addItemsController.ts index 408c3867..d064a6e3 100644 --- a/src/controllers/custom/addItemsController.ts +++ b/src/controllers/custom/addItemsController.ts @@ -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 = { + 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", diff --git a/src/helpers/purchaseHelpers.ts b/src/helpers/purchaseHelpers.ts index af4ac234..3fbcaf52 100644 --- a/src/helpers/purchaseHelpers.ts +++ b/src/helpers/purchaseHelpers.ts @@ -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 = { - 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 -};