validate prestige
This commit is contained in:
parent
8a8c141fbe
commit
a227055c1e
1 changed files with 5 additions and 5 deletions
|
|
@ -34,6 +34,11 @@ export const POST: RequestHandler = async ({ request, locals }) => {
|
||||||
throw error(400, 'Maximum prestige level reached');
|
throw error(400, 'Maximum prestige level reached');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const currentCashBalance = Number(userData.baseCurrencyBalance);
|
||||||
|
if (currentCashBalance < prestigeCost) {
|
||||||
|
throw error(400, `Insufficient cash funds for prestige. Need ${formatValue(prestigeCost)} cash, have ${formatValue(currentCashBalance)} cash. Coin holdings cannot be used for prestige costs.`);
|
||||||
|
}
|
||||||
|
|
||||||
const holdings = await tx
|
const holdings = await tx
|
||||||
.select({
|
.select({
|
||||||
coinId: userPortfolio.coinId,
|
coinId: userPortfolio.coinId,
|
||||||
|
|
@ -72,11 +77,6 @@ export const POST: RequestHandler = async ({ request, locals }) => {
|
||||||
.where(eq(userPortfolio.userId, userId));
|
.where(eq(userPortfolio.userId, userId));
|
||||||
}
|
}
|
||||||
|
|
||||||
const currentBalance = Number(userData.baseCurrencyBalance) + totalSaleValue;
|
|
||||||
if (currentBalance < prestigeCost) {
|
|
||||||
throw error(400, `Insufficient funds. Need ${formatValue(prestigeCost)}, have ${formatValue(currentBalance)}`);
|
|
||||||
}
|
|
||||||
|
|
||||||
await tx
|
await tx
|
||||||
.update(user)
|
.update(user)
|
||||||
.set({
|
.set({
|
||||||
|
|
|
||||||
Reference in a new issue