From c88944aa80567e20a0b24fe36f831175d8418cf5 Mon Sep 17 00:00:00 2001 From: saml33 Date: Sat, 31 Dec 2022 20:46:26 +1100 Subject: [PATCH] update account button label to Actions --- components/account/AccountActions.tsx | 37 ++++++++++++--------------- public/locales/en/common.json | 1 + public/locales/es/common.json | 1 + public/locales/ru/common.json | 1 + public/locales/zh/common.json | 1 + public/locales/zh_tw/common.json | 1 + 6 files changed, 22 insertions(+), 20 deletions(-) diff --git a/components/account/AccountActions.tsx b/components/account/AccountActions.tsx index d34afd12..1023dedb 100644 --- a/components/account/AccountActions.tsx +++ b/components/account/AccountActions.tsx @@ -1,13 +1,13 @@ -import { Fragment, ReactNode, useMemo, useState } from 'react' +import { Fragment, ReactNode, useState } from 'react' import Button, { LinkButton } from '../shared/Button' import { - AdjustmentsHorizontalIcon, ArrowDownRightIcon, ArrowUpLeftIcon, DocumentDuplicateIcon, PencilIcon, TrashIcon, UsersIcon, + WrenchIcon, } from '@heroicons/react/20/solid' import { useTranslation } from 'next-i18next' import CloseAccountModal from '../modals/CloseAccountModal' @@ -15,14 +15,9 @@ import AccountNameModal from '../modals/AccountNameModal' import { copyToClipboard } from 'utils' import { notify } from 'utils/notifications' import { abbreviateAddress } from 'utils/formatting' -import { - HealthType, - MangoAccount, - toUiDecimalsForQuote, -} from '@blockworks-foundation/mango-v4' +import { MangoAccount } from '@blockworks-foundation/mango-v4' import DelegateModal from '@components/modals/DelegateModal' import useMangoAccount from 'hooks/useMangoAccount' -import useMangoGroup from 'hooks/useMangoGroup' import BorrowRepayModal from '@components/modals/BorrowRepayModal' import { useWallet } from '@solana/wallet-adapter-react' import CreateAccountModal from '@components/modals/CreateAccountModal' @@ -41,7 +36,6 @@ export const handleCopyAddress = ( const AccountActions = () => { const { t } = useTranslation(['common', 'close-account']) - const { group } = useMangoGroup() const { mangoAccount } = useMangoAccount() const [showCloseAccountModal, setShowCloseAccountModal] = useState(false) const [showEditAccountModal, setShowEditAccountModal] = useState(false) @@ -51,14 +45,16 @@ const AccountActions = () => { const [showCreateAccountModal, setShowCreateAccountModal] = useState(false) const { connected } = useWallet() - const hasBorrows = useMemo(() => { - if (!mangoAccount || !group) return false - return ( - toUiDecimalsForQuote( - mangoAccount.getLiabsValue(group, HealthType.init).toNumber() - ) >= 1 - ) - }, [mangoAccount, group]) + // this doesn't work for detecting spot borrows as it includes perp liabs. was only using it to make the repay button have primary styles so could delete + + // const hasBorrows = useMemo(() => { + // if (!mangoAccount || !group) return false + // return ( + // toUiDecimalsForQuote( + // mangoAccount.getLiabsValue(group, HealthType.init).toNumber() + // ) >= 1 + // ) + // }, [mangoAccount, group]) const handleBorrowModal = () => { if (!connected || mangoAccount) { @@ -75,7 +71,8 @@ const AccountActions = () => { className="flex w-1/3 items-center justify-center sm:w-auto" disabled={!mangoAccount} onClick={() => setShowRepayModal(true)} - secondary={!hasBorrows} + // secondary={!hasBorrows} + secondary > {t('repay')} @@ -98,8 +95,8 @@ const AccountActions = () => { className="flex w-full items-center justify-center" secondary > - - {t('settings')} + + {t('actions')}