feat: centralized constants and enums for project-wide use
This commit is contained in:
@@ -4,6 +4,7 @@ import { inventoryService } from "@/modules/inventory/inventory.service";
|
||||
import { itemTransactions } from "@/db/schema";
|
||||
import { withTransaction } from "@/lib/db";
|
||||
import type { Transaction } from "@/lib/types";
|
||||
import { TransactionType, ItemTransactionType } from "@/lib/constants";
|
||||
|
||||
// Module-level session storage
|
||||
const sessions = new Map<string, TradeSession>();
|
||||
@@ -25,7 +26,7 @@ const processTransfer = async (tx: Transaction, from: TradeParticipant, to: Trad
|
||||
await economyService.modifyUserBalance(
|
||||
from.id,
|
||||
-from.offer.money,
|
||||
'TRADE_OUT',
|
||||
TransactionType.TRADE_OUT,
|
||||
`Trade with ${to.username} (Thread: ${threadId})`,
|
||||
to.id,
|
||||
tx
|
||||
@@ -33,7 +34,7 @@ const processTransfer = async (tx: Transaction, from: TradeParticipant, to: Trad
|
||||
await economyService.modifyUserBalance(
|
||||
to.id,
|
||||
from.offer.money,
|
||||
'TRADE_IN',
|
||||
TransactionType.TRADE_IN,
|
||||
`Trade with ${from.username} (Thread: ${threadId})`,
|
||||
from.id,
|
||||
tx
|
||||
@@ -54,7 +55,7 @@ const processTransfer = async (tx: Transaction, from: TradeParticipant, to: Trad
|
||||
relatedUserId: BigInt(to.id),
|
||||
itemId: item.id,
|
||||
quantity: -item.quantity,
|
||||
type: 'TRADE_OUT',
|
||||
type: ItemTransactionType.TRADE_OUT,
|
||||
description: `Traded to ${to.username}`,
|
||||
});
|
||||
|
||||
@@ -64,7 +65,7 @@ const processTransfer = async (tx: Transaction, from: TradeParticipant, to: Trad
|
||||
relatedUserId: BigInt(from.id),
|
||||
itemId: item.id,
|
||||
quantity: item.quantity,
|
||||
type: 'TRADE_IN',
|
||||
type: ItemTransactionType.TRADE_IN,
|
||||
description: `Received from ${from.username}`,
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user