use first obligation when clicking repay from reserve overview

This commit is contained in:
juan 2021-02-01 13:55:12 -05:00
parent 6b03bf31a1
commit dff1d6e1c1
1 changed files with 9 additions and 3 deletions

View File

@ -5,6 +5,7 @@ import {
useUserBalance,
useBorrowedAmount,
useBorrowingPower,
useUserObligationByReserve,
} from "./../../hooks";
import { LendingReserve } from "../../models/lending";
import { formatNumber } from "../../utils/utils";
@ -44,6 +45,7 @@ export const UserLendingCard = (props: {
totalInQuote: borrowingPowerInUSD,
borrowingPower,
} = useBorrowingPower(address);
const { userObligationsByReserve } = useUserObligationByReserve(address);
return (
<Card
@ -156,9 +158,13 @@ export const UserLendingCard = (props: {
<Link to={`/withdraw/${address}`}>
<Button>{LABELS.WITHDRAW_ACTION}</Button>
</Link>
<Link to={`/repay/${address}`}>
<Button>{LABELS.REPAY_ACTION}</Button>
</Link>
{!!userObligationsByReserve.length && (
<Link
to={`/repay/loan/${userObligationsByReserve[0].obligation.account.pubkey.toBase58()}`}
>
<Button>{LABELS.REPAY_ACTION}</Button>
</Link>
)}
</div>
</Card>
);