Skip to content

Commit

Permalink
🐛 asset-input: disable when borrowing and no deposited assets
Browse files Browse the repository at this point in the history
  • Loading branch information
sebipap authored and cruzdanilo committed Apr 17, 2024
1 parent 6ed5338 commit aa758b7
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
5 changes: 3 additions & 2 deletions components/OperationsModal/AssetInput/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,10 @@ type Props = {
decimals: number;
onChange: (value: string) => void;
tooltip?: string;
disabled?: boolean;
} & AAProps;

function AssetInput({ qty, onChange, symbol, decimals, amount, label, onMax, tooltip }: Props) {
function AssetInput({ qty, onChange, symbol, decimals, amount, label, onMax, tooltip, disabled }: Props) {
const { isConnected } = useWeb3();

const handleBlur = useCallback(() => {
Expand All @@ -33,7 +34,7 @@ function AssetInput({ qty, onChange, symbol, decimals, amount, label, onMax, too
<Box sx={{ display: 'flex', flexDirection: 'column', width: '100%' }}>
<Box sx={{ display: 'flex', justifyContent: 'space-between', alignItems: 'center' }}>
<AssetSelector />
<ModalInput value={qty} decimals={decimals} onValueChange={onChange} onBlur={handleBlur} />
<ModalInput value={qty} decimals={decimals} onValueChange={onChange} onBlur={handleBlur} disabled={disabled} />
</Box>
<Box
sx={{
Expand Down
3 changes: 2 additions & 1 deletion components/operations/BorrowAtMaturity/index.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { FC, PropsWithChildren, useCallback, useEffect, useRef, useState } from 'react';
import React, { FC, PropsWithChildren, useCallback, useEffect, useMemo, useRef, useState } from 'react';
import ModalTxCost from 'components/OperationsModal/ModalTxCost';
import ModalGif from 'components/OperationsModal/ModalGif';
import { toPercentage } from 'utils/utils';
Expand Down Expand Up @@ -103,6 +103,7 @@ const BorrowAtMaturity: FC<PropsWithChildren> = ({ children }) => {
label={t('Safe borrow limit')}
amount={safeMaximumBorrow}
tooltip={t('The maximum amount you can borrow without putting your health factor at risk')}
disabled={marketAccount?.totalFloatingDepositAssets === 0n}
/>
</ModalBoxRow>
<ModalBoxRow>
Expand Down

0 comments on commit aa758b7

Please sign in to comment.