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