user.balanceUsd => user.balance
This commit is contained in:
parent
9f59f4b3c4
commit
53907d2d52
|
@ -30,7 +30,7 @@ export const placeBet = functions.runWith({ minInstances: 1 }).https.onCall(
|
||||||
return { status: 'error', message: 'User not found' }
|
return { status: 'error', message: 'User not found' }
|
||||||
const user = userSnap.data() as User
|
const user = userSnap.data() as User
|
||||||
|
|
||||||
if (user.balanceUsd < amount)
|
if (user.balance < amount)
|
||||||
return { status: 'error', message: 'Insufficient balance' }
|
return { status: 'error', message: 'Insufficient balance' }
|
||||||
|
|
||||||
const contractDoc = firestore.doc(`contracts/${contractId}`)
|
const contractDoc = firestore.doc(`contracts/${contractId}`)
|
||||||
|
@ -53,7 +53,7 @@ export const placeBet = functions.runWith({ minInstances: 1 }).https.onCall(
|
||||||
|
|
||||||
transaction.create(newBetDoc, newBet)
|
transaction.create(newBetDoc, newBet)
|
||||||
transaction.update(contractDoc, { pot: newPot })
|
transaction.update(contractDoc, { pot: newPot })
|
||||||
transaction.update(userDoc, { balanceUsd: newBalance })
|
transaction.update(userDoc, { balance: newBalance })
|
||||||
|
|
||||||
return { status: 'success' }
|
return { status: 'success' }
|
||||||
})
|
})
|
||||||
|
@ -104,7 +104,7 @@ const getNewBetInfo = (
|
||||||
createdTime: Date.now(),
|
createdTime: Date.now(),
|
||||||
}
|
}
|
||||||
|
|
||||||
const newBalance = user.balanceUsd - amount
|
const newBalance = user.balance - amount
|
||||||
|
|
||||||
return { newBet, newPot, newBalance }
|
return { newBet, newPot, newBalance }
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,7 +4,7 @@ export type User = {
|
||||||
name: string
|
name: string
|
||||||
username: string
|
username: string
|
||||||
avatarUrl: string
|
avatarUrl: string
|
||||||
balanceUsd: number
|
balance: number
|
||||||
createdTime: number
|
createdTime: number
|
||||||
lastUpdatedTime: number
|
lastUpdatedTime: number
|
||||||
}
|
}
|
|
@ -14,7 +14,7 @@ export type User = {
|
||||||
name: string
|
name: string
|
||||||
username: string
|
username: string
|
||||||
avatarUrl: string
|
avatarUrl: string
|
||||||
balanceUsd: number
|
balance: number
|
||||||
createdTime: number
|
createdTime: number
|
||||||
lastUpdatedTime: number
|
lastUpdatedTime: number
|
||||||
}
|
}
|
||||||
|
@ -50,7 +50,7 @@ export function listenForLogin(onUser: (_user: User | null) => void) {
|
||||||
username: user.displayName?.replace(/\s+/g, '') || 'DefaultUsername',
|
username: user.displayName?.replace(/\s+/g, '') || 'DefaultUsername',
|
||||||
avatarUrl: user.photoURL || '',
|
avatarUrl: user.photoURL || '',
|
||||||
email: user.email || 'default@blah.com',
|
email: user.email || 'default@blah.com',
|
||||||
balanceUsd: 10000,
|
balance: 10000,
|
||||||
// TODO: use Firestore timestamp?
|
// TODO: use Firestore timestamp?
|
||||||
createdTime: Date.now(),
|
createdTime: Date.now(),
|
||||||
lastUpdatedTime: Date.now(),
|
lastUpdatedTime: Date.now(),
|
||||||
|
|
|
@ -31,7 +31,7 @@ export default function Account() {
|
||||||
<div className="max-w-md card-body">
|
<div className="max-w-md card-body">
|
||||||
<h2 className="card-title font-major-mono">{user?.name}</h2>
|
<h2 className="card-title font-major-mono">{user?.name}</h2>
|
||||||
<p>{user?.email}</p>
|
<p>{user?.email}</p>
|
||||||
<p>${user?.balanceUsd} USD</p>
|
<p>M${user?.balance}</p>
|
||||||
<div className="card-actions">
|
<div className="card-actions">
|
||||||
<button
|
<button
|
||||||
className="btn glass rounded-full hover:bg-green-500"
|
className="btn glass rounded-full hover:bg-green-500"
|
||||||
|
|
Loading…
Reference in New Issue
Block a user