fix: fixed accountId usage (#491)

* fix: fixed accountId usage

* fix: fixed rewards center

* fix: copy fix
This commit is contained in:
Linkie Link 2023-09-20 15:53:24 +02:00 committed by GitHub
parent 2ba18d2f05
commit 574dedec23
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 9 additions and 11 deletions

View File

@ -1,4 +1,5 @@
import classNames from 'classnames' import classNames from 'classnames'
import useAccountId from 'hooks/useAccountId'
import { NavLink, useParams } from 'react-router-dom' import { NavLink, useParams } from 'react-router-dom'
import { getRoute } from 'utils/route' import { getRoute } from 'utils/route'
@ -11,7 +12,8 @@ interface Props {
} }
export default function Tab(props: Props) { export default function Tab(props: Props) {
const { address, accountId } = useParams() const accountId = useAccountId()
const { address } = useParams()
return ( return (
<div className='relative w-full mb-4'> <div className='relative w-full mb-4'>

View File

@ -7,7 +7,7 @@ import DesktopNavigation from 'components/Navigation/DesktopNavigation'
import RewardsCenter from 'components/RewardsCenter' import RewardsCenter from 'components/RewardsCenter'
import Settings from 'components/Settings' import Settings from 'components/Settings'
import Wallet from 'components/Wallet' import Wallet from 'components/Wallet'
import useCurrentAccount from 'hooks/useCurrentAccount' import useAccountId from 'hooks/useAccountId'
import useStore from 'store' import useStore from 'store'
export const menuTree: { pages: Page[]; label: string }[] = [ export const menuTree: { pages: Page[]; label: string }[] = [
@ -20,7 +20,7 @@ export const menuTree: { pages: Page[]; label: string }[] = [
export default function DesktopHeader() { export default function DesktopHeader() {
const address = useStore((s) => s.address) const address = useStore((s) => s.address)
const focusComponent = useStore((s) => s.focusComponent) const focusComponent = useStore((s) => s.focusComponent)
const currentAccount = useCurrentAccount() const accountId = useAccountId()
function handleCloseFocusMode() { function handleCloseFocusMode() {
if (focusComponent && focusComponent.onClose) focusComponent.onClose() if (focusComponent && focusComponent.onClose) focusComponent.onClose()
@ -52,7 +52,7 @@ export default function DesktopHeader() {
</div> </div>
) : ( ) : (
<div className='flex gap-4'> <div className='flex gap-4'>
{currentAccount && <RewardsCenter />} {accountId && <RewardsCenter />}
{address && <AccountMenu />} {address && <AccountMenu />}
<Wallet /> <Wallet />
<Settings /> <Settings />

View File

@ -8,11 +8,8 @@ import { Logo } from 'components/Icons'
import Overlay from 'components/Overlay' import Overlay from 'components/Overlay'
import Text from 'components/Text' import Text from 'components/Text'
import { ASSETS } from 'constants/assets' import { ASSETS } from 'constants/assets'
import { DEFAULT_SETTINGS } from 'constants/defaultSettings'
import { DISPLAY_CURRENCY_KEY } from 'constants/localStore'
import { ORACLE_DENOM } from 'constants/oracle' import { ORACLE_DENOM } from 'constants/oracle'
import useCurrentAccount from 'hooks/useCurrentAccount' import useAccountId from 'hooks/useAccountId'
import useLocalStorage from 'hooks/useLocalStorage'
import usePrices from 'hooks/usePrices' import usePrices from 'hooks/usePrices'
import useToggle from 'hooks/useToggle' import useToggle from 'hooks/useToggle'
import useUnclaimedRewards from 'hooks/useUnclaimedRewards' import useUnclaimedRewards from 'hooks/useUnclaimedRewards'
@ -43,8 +40,7 @@ const renderIncentives = (unclaimedRewards: BNCoin[]) => {
} }
export default function RewardsCenter() { export default function RewardsCenter() {
const account = useCurrentAccount() const accountId = useAccountId()
const accountId = account?.id
const [isConfirming, setIsConfirming] = useState(false) const [isConfirming, setIsConfirming] = useState(false)
const [estimatedFee, setEstimatedFee] = useState(defaultFee) const [estimatedFee, setEstimatedFee] = useState(defaultFee)
const [showRewardsCenter, setShowRewardsCenter] = useToggle() const [showRewardsCenter, setShowRewardsCenter] = useToggle()

View File

@ -2,7 +2,7 @@ import useSWR from 'swr'
import getAccount from 'api/accounts/getAccount' import getAccount from 'api/accounts/getAccount'
export default function useAccounts(accountId?: string, suspense?: boolean) { export default function useAccount(accountId?: string, suspense?: boolean) {
return useSWR(`account${accountId}`, () => getAccount(accountId || ''), { return useSWR(`account${accountId}`, () => getAccount(accountId || ''), {
suspense: suspense, suspense: suspense,
revalidateOnFocus: false, revalidateOnFocus: false,