Call buyLeaderboardSlot from client

This commit is contained in:
James Grugett 2022-03-31 23:49:10 -05:00
parent de562799f4
commit 85c362d357
4 changed files with 13 additions and 0 deletions

View File

@ -21,3 +21,4 @@ export * from './update-user-metrics'
export * from './backup-db'
export * from './change-user-info'
export * from './market-close-emails'
export * from './buy-leaderboard-slot'

View File

@ -4,6 +4,7 @@ import { ENV_CONFIG } from '../../common/envs/constants'
import { User } from '../../common/user'
import { formatMoney } from '../../common/util/format'
import { useUser } from '../hooks/use-user'
import { buyLeaderboardSlot } from '../lib/firebase/api-call'
import { AmountInput } from './amount-input'
import { Avatar } from './avatar'
import { Col } from './layout/col'
@ -93,6 +94,12 @@ export function BuySlotModal(props: {
}
}, [user])
const onBuy = async () => {
// Feel free to change this. - James
const slotId = `${title}-${slot}`
await buyLeaderboardSlot({ slotId, reassessValue: newValue })
}
return (
<>
<Modal open={open} setOpen={setOpen}>

View File

@ -66,3 +66,8 @@ export const changeUserInfo = (data: {
.then((r) => r.data as { status: string; message?: string })
.catch((e) => ({ status: 'error', message: e.message }))
}
export const buyLeaderboardSlot = cloudFunction<
{ slotId: string; reassessValue: number },
{ status: 'success' | 'error'; message?: string }
>('buyLeaderboardSlot')