Skip to content

Commit

Permalink
fix: prefetching fee scenarios (#1384)
Browse files Browse the repository at this point in the history
  • Loading branch information
danielsimao authored Jul 5, 2023
1 parent 5583d92 commit 9cbbd19
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ type InheritAttrs = Omit<ModalProps, keyof Props | 'children'>;

type CollateralModalProps = Props & InheritAttrs;

const CollateralModal = ({ asset, position, onClose, ...props }: CollateralModalProps): JSX.Element | null => {
const CollateralModal = ({ asset, position, onClose, isOpen, ...props }: CollateralModalProps): JSX.Element | null => {
const { t } = useTranslation();
const { refetch } = useGetAccountLendingStatistics();
const { getLTV } = useGetLTV();
Expand Down Expand Up @@ -107,18 +107,19 @@ const CollateralModal = ({ asset, position, onClose, ...props }: CollateralModal
// Doing this call on mount so that the form becomes dirty
// TODO: find better approach
useEffect(() => {
if (variant === 'disable-error') return;
if (variant === 'disable-error' || !isOpen) return;

form.setFieldValue(LOAN_TOGGLE_COLLATERAL_FEE_TOKEN_FIELD, transaction.fee.defaultCurrency.ticker, true);
// eslint-disable-next-line react-hooks/exhaustive-deps
}, []);
}, [isOpen, variant]);

const content = getContentMap(t, variant, asset);

const isBtnDisabled = isTransactionFormDisabled(form, transaction.fee);

return (
<Modal
isOpen={isOpen}
onClose={onClose}
shouldCloseOnInteractOutside={(el) => !overlappingModalRef.current?.contains(el)}
{...props}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,11 @@ const LoansInsights = ({ statistics }: LoansInsightsProps): JSX.Element => {
// Doing this call on mount so that the form becomes dirty
// TODO: improve approach
useEffect(() => {
if (!isOpen) return;

form.setFieldValue(LOAN_CLAIM_REWARDS_FEE_TOKEN_FIELD, transaction.fee.defaultCurrency.ticker, true);
// eslint-disable-next-line react-hooks/exhaustive-deps
}, []);
}, [isOpen]);

const { supplyAmountUSD, netAPY } = statistics || {};

Expand Down

2 comments on commit 9cbbd19

@vercel
Copy link

@vercel vercel bot commented on 9cbbd19 Jul 5, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@vercel
Copy link

@vercel vercel bot commented on 9cbbd19 Jul 5, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.