From 45d322cfd330deb41f0306f0cac181fe33ad430d Mon Sep 17 00:00:00 2001 From: James Grugett Date: Tue, 1 Mar 2022 19:07:30 -0800 Subject: [PATCH] Fix loan calc on front end --- web/components/amount-input.tsx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/web/components/amount-input.tsx b/web/components/amount-input.tsx index e5165b1f..e36962a2 100644 --- a/web/components/amount-input.tsx +++ b/web/components/amount-input.tsx @@ -38,7 +38,8 @@ export function AmountInput(props: { const user = useUser() 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( amount ?? 0,