From 297516d09270e3038623557077880c1be3c3e78f Mon Sep 17 00:00:00 2001 From: Austin Chen Date: Fri, 1 Apr 2022 08:26:36 -0700 Subject: [PATCH] Prevent buying slots when fake balance is low --- web/components/manaboard.tsx | 29 +++++++++++++++++++++++------ web/pages/leaderboards.tsx | 7 +++++-- 2 files changed, 28 insertions(+), 8 deletions(-) diff --git a/web/components/manaboard.tsx b/web/components/manaboard.tsx index 7d10fd53..f17a712b 100644 --- a/web/components/manaboard.tsx +++ b/web/components/manaboard.tsx @@ -10,6 +10,8 @@ import { Transaction, writeTransaction, } from '../lib/firebase/transactions' +import { loadFakeBalance } from '../pages/leaderboards' +import { AddFundsButton } from './add-funds-button' import { AmountInput } from './amount-input' import { Avatar } from './avatar' import { Col } from './layout/col' @@ -150,6 +152,10 @@ export function BuySlotModal(props: { } } + const fakeBalance = loadFakeBalance() + const noFundsMsg = + value > fakeBalance ? `You only have ${formatMoney(fakeBalance)}!` : '' + return ( <> @@ -183,12 +189,23 @@ export function BuySlotModal(props: { label={ENV_CONFIG.moneyMoniker} /> - -
- Additional fees: {formatMoney(newValue * 0.25)} per hour -
+ {noFundsMsg ? ( +
+ {noFundsMsg}{' '} + + + +
+ ) : ( + + +
+ Additional fees: {formatMoney(newValue * 0.25)} per hour +
+ + )}