user.balanceUsd => user.balance

This commit is contained in:
mantikoros 2021-12-13 11:58:47 -06:00
parent 9f59f4b3c4
commit 53907d2d52
4 changed files with 7 additions and 7 deletions

View File

@ -30,7 +30,7 @@ export const placeBet = functions.runWith({ minInstances: 1 }).https.onCall(
return { status: 'error', message: 'User not found' }
const user = userSnap.data() as User
if (user.balanceUsd < amount)
if (user.balance < amount)
return { status: 'error', message: 'Insufficient balance' }
const contractDoc = firestore.doc(`contracts/${contractId}`)
@ -53,7 +53,7 @@ export const placeBet = functions.runWith({ minInstances: 1 }).https.onCall(
transaction.create(newBetDoc, newBet)
transaction.update(contractDoc, { pot: newPot })
transaction.update(userDoc, { balanceUsd: newBalance })
transaction.update(userDoc, { balance: newBalance })
return { status: 'success' }
})
@ -104,7 +104,7 @@ const getNewBetInfo = (
createdTime: Date.now(),
}
const newBalance = user.balanceUsd - amount
const newBalance = user.balance - amount
return { newBet, newPot, newBalance }
}

View File

@ -4,7 +4,7 @@ export type User = {
name: string
username: string
avatarUrl: string
balanceUsd: number
balance: number
createdTime: number
lastUpdatedTime: number
}

View File

@ -14,7 +14,7 @@ export type User = {
name: string
username: string
avatarUrl: string
balanceUsd: number
balance: number
createdTime: number
lastUpdatedTime: number
}
@ -50,7 +50,7 @@ export function listenForLogin(onUser: (_user: User | null) => void) {
username: user.displayName?.replace(/\s+/g, '') || 'DefaultUsername',
avatarUrl: user.photoURL || '',
email: user.email || 'default@blah.com',
balanceUsd: 10000,
balance: 10000,
// TODO: use Firestore timestamp?
createdTime: Date.now(),
lastUpdatedTime: Date.now(),

View File

@ -31,7 +31,7 @@ export default function Account() {
<div className="max-w-md card-body">
<h2 className="card-title font-major-mono">{user?.name}</h2>
<p>{user?.email}</p>
<p>${user?.balanceUsd} USD</p>
<p>M${user?.balance}</p>
<div className="card-actions">
<button
className="btn glass rounded-full hover:bg-green-500"