diff --git a/web/components/manaboard.tsx b/web/components/manaboard.tsx index 08fa126c..2e7376c0 100644 --- a/web/components/manaboard.tsx +++ b/web/components/manaboard.tsx @@ -84,6 +84,7 @@ export function Manaboard(props: { holder={user} value={values[index]} createdTime={createdTimes[index]} + allSlots={users} /> @@ -114,8 +115,9 @@ export function BuySlotModal(props: { slot: number value: number createdTime: number + allSlots: User[] }) { - const { slot, title, holder, value, createdTime } = props + const { slot, allSlots, holder, value, createdTime } = props const user = useUser() const [open, setOpen] = useState(false) @@ -133,6 +135,14 @@ export function BuySlotModal(props: { // await buyLeaderboardSlot({ slotId, reassessValue: newValue }) // } + // If the user already exists in a different slot, forbid them from buying this one + const userExists = allSlots.find( + (u, index) => u.id === user?.id && index + 1 !== slot + ) + const errorMsg = userExists + ? 'Sell your other slot first (by revaluing it to M$ 0)' + : '' + async function onBuy() { if (user) { // Start transactions, but don't block @@ -187,7 +197,7 @@ export function BuySlotModal(props: { onChange={(amount) => setNewValue(amount && amount >= 1 ? amount : 0) } - error="" + error={errorMsg} label={ENV_CONFIG.moneyMoniker} /> @@ -200,7 +210,11 @@ export function BuySlotModal(props: { ) : (