Fix loan calc on front end

This commit is contained in:
James Grugett 2022-03-01 19:07:30 -08:00
parent 5bf4654bf4
commit 45d322cfd3

View File

@ -38,7 +38,8 @@ export function AmountInput(props: {
const user = useUser() const user = useUser()
const userBets = useUserContractBets(user?.id, contractId) ?? [] const userBets = useUserContractBets(user?.id, contractId) ?? []
const prevLoanAmount = _.sumBy(userBets, (bet) => bet.loanAmount ?? 0) const openUserBets = userBets.filter((bet) => !bet.isSold && !bet.sale)
const prevLoanAmount = _.sumBy(openUserBets, (bet) => bet.loanAmount ?? 0)
const loanAmount = Math.min( const loanAmount = Math.min(
amount ?? 0, amount ?? 0,