fix comments
This commit is contained in:
parent
4e26bddd33
commit
aab51962ed
@ -90,7 +90,7 @@ export default function WalletConnectedButton() {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
navigate(getRoute(getPage(pathname), searchParams))
|
navigate(getRoute(getPage(pathname), new URLSearchParams()))
|
||||||
}
|
}
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
@ -19,7 +19,8 @@ interface Props {
|
|||||||
}
|
}
|
||||||
export default function BorrowButton(props: Props) {
|
export default function BorrowButton(props: Props) {
|
||||||
const account = useCurrentAccount()
|
const account = useCurrentAccount()
|
||||||
const hasNoDeposits = !!account?.deposits?.length && !!account?.lends?.length
|
const address = useStore((s) => s.address)
|
||||||
|
const hasNoDeposits = !!account?.deposits?.length && !!account?.lends?.length && !!address
|
||||||
|
|
||||||
const borrowHandler = useCallback(() => {
|
const borrowHandler = useCallback(() => {
|
||||||
if (!props.data.asset) return null
|
if (!props.data.asset) return null
|
||||||
|
@ -1,7 +1,10 @@
|
|||||||
|
import classNames from 'classnames'
|
||||||
|
|
||||||
import Button from 'components/common/Button/index'
|
import Button from 'components/common/Button/index'
|
||||||
import { ChevronDown } from 'components/common/Icons'
|
import { ChevronDown } from 'components/common/Icons'
|
||||||
import Text from 'components/common/Text'
|
import Text from 'components/common/Text'
|
||||||
import { Tooltip } from 'components/common/Tooltip'
|
import { Tooltip } from 'components/common/Tooltip'
|
||||||
|
import ConditionalWrapper from 'hocs/ConditionalWrapper'
|
||||||
import useToggle from 'hooks/useToggle'
|
import useToggle from 'hooks/useToggle'
|
||||||
|
|
||||||
interface Props extends ButtonProps {
|
interface Props extends ButtonProps {
|
||||||
@ -57,6 +60,19 @@ interface DropDownItemProps {
|
|||||||
|
|
||||||
function DropDownItem(props: DropDownItemProps) {
|
function DropDownItem(props: DropDownItemProps) {
|
||||||
return (
|
return (
|
||||||
|
<ConditionalWrapper
|
||||||
|
condition={!!props.item.disabled}
|
||||||
|
wrapper={(children) => (
|
||||||
|
<Tooltip
|
||||||
|
type='warning'
|
||||||
|
content={<Text size='sm'>{props.item.disabledTooltip}</Text>}
|
||||||
|
contentClassName='max-w-[200px]'
|
||||||
|
className='ml-auto'
|
||||||
|
>
|
||||||
|
{children}
|
||||||
|
</Tooltip>
|
||||||
|
)}
|
||||||
|
>
|
||||||
<button
|
<button
|
||||||
onClick={(e) => {
|
onClick={(e) => {
|
||||||
e.preventDefault()
|
e.preventDefault()
|
||||||
@ -64,10 +80,15 @@ function DropDownItem(props: DropDownItemProps) {
|
|||||||
props.closeMenu()
|
props.closeMenu()
|
||||||
e.stopPropagation()
|
e.stopPropagation()
|
||||||
}}
|
}}
|
||||||
className='z-1 px-4 py-3 flex gap-2 items-center hover:bg-white/5 w-full [&:not(:last-child)]:border-b border-white/10'
|
className={classNames(
|
||||||
|
'z-1 px-4 py-3 flex gap-2 items-center w-full [&:not(:last-child)]:border-b border-white/10',
|
||||||
|
props.item.disabled ? 'bg-black/20 text-white/40 cursor-events-none' : 'hover:bg-white/5',
|
||||||
|
)}
|
||||||
|
disabled={props.item.disabled}
|
||||||
>
|
>
|
||||||
<div className='flex justify-center w-5 h-5'>{props.item.icon}</div>
|
<div className='flex justify-center w-5 h-5'>{props.item.icon}</div>
|
||||||
<Text size='sm'>{props.item.text}</Text>
|
<Text size='sm'>{props.item.text}</Text>
|
||||||
</button>
|
</button>
|
||||||
|
</ConditionalWrapper>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@ -3,6 +3,7 @@ import { useCallback, useMemo } from 'react'
|
|||||||
import { ACCOUNT_MENU_BUTTON_ID } from 'components/account/AccountMenuContent'
|
import { ACCOUNT_MENU_BUTTON_ID } from 'components/account/AccountMenuContent'
|
||||||
import DropDownButton from 'components/common/Button/DropDownButton'
|
import DropDownButton from 'components/common/Button/DropDownButton'
|
||||||
import { ArrowDownLine, ArrowUpLine, Enter, ExclamationMarkCircled } from 'components/common/Icons'
|
import { ArrowDownLine, ArrowUpLine, Enter, ExclamationMarkCircled } from 'components/common/Icons'
|
||||||
|
import useCurrentAccount from 'hooks/accounts/useCurrentAccount'
|
||||||
import useAlertDialog from 'hooks/useAlertDialog'
|
import useAlertDialog from 'hooks/useAlertDialog'
|
||||||
import useAutoLend from 'hooks/useAutoLend'
|
import useAutoLend from 'hooks/useAutoLend'
|
||||||
import useLendAndReclaimModal from 'hooks/useLendAndReclaimModal'
|
import useLendAndReclaimModal from 'hooks/useLendAndReclaimModal'
|
||||||
@ -22,10 +23,11 @@ export default function Manage(props: Props) {
|
|||||||
const { isAutoLendEnabledForCurrentAccount } = useAutoLend()
|
const { isAutoLendEnabledForCurrentAccount } = useAutoLend()
|
||||||
const { open: showAlertDialog } = useAlertDialog()
|
const { open: showAlertDialog } = useAlertDialog()
|
||||||
const address = useStore((s) => s.address)
|
const address = useStore((s) => s.address)
|
||||||
|
const account = useCurrentAccount()
|
||||||
|
|
||||||
const hasLendAsset = useMemo(
|
const hasAssetInDeposits = useMemo(
|
||||||
() => !!props.data.accountLentValue && props.data.accountLentValue.isGreaterThan(0),
|
() => !!account?.deposits?.find((deposit) => deposit.denom === props.data.asset.denom),
|
||||||
[props.data.accountLentValue],
|
[account?.deposits, props.data.asset.denom],
|
||||||
)
|
)
|
||||||
|
|
||||||
const handleUnlend = useCallback(() => {
|
const handleUnlend = useCallback(() => {
|
||||||
@ -55,8 +57,11 @@ export default function Manage(props: Props) {
|
|||||||
() => [
|
() => [
|
||||||
{
|
{
|
||||||
icon: <ArrowUpLine />,
|
icon: <ArrowUpLine />,
|
||||||
text: hasLendAsset ? 'Lend more' : 'Lend',
|
text: 'Lend more',
|
||||||
onClick: () => openLend(props.data),
|
onClick: () => openLend(props.data),
|
||||||
|
disabled: !hasAssetInDeposits,
|
||||||
|
disabledTooltip: `You don’t have any ${props.data.asset.symbol}.
|
||||||
|
Please first deposit ${props.data.asset.symbol} into your Credit Account before lending.`,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
icon: <ArrowDownLine />,
|
icon: <ArrowDownLine />,
|
||||||
@ -64,7 +69,7 @@ export default function Manage(props: Props) {
|
|||||||
onClick: handleUnlend,
|
onClick: handleUnlend,
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
[handleUnlend, hasLendAsset, openLend, props.data],
|
[handleUnlend, hasAssetInDeposits, openLend, props.data],
|
||||||
)
|
)
|
||||||
|
|
||||||
if (!address) return null
|
if (!address) return null
|
||||||
|
@ -2,4 +2,6 @@ interface DropDownItem {
|
|||||||
icon: import('react').ReactNode
|
icon: import('react').ReactNode
|
||||||
onClick: () => void
|
onClick: () => void
|
||||||
text: string
|
text: string
|
||||||
|
disabled?: boolean
|
||||||
|
disabledTooltip?: string
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user