Revert "fix: make error handling consistent for useTranches"

This reverts commit 357cbc45f8.
This commit is contained in:
Dexter 2022-05-25 09:41:04 +01:00
parent 357cbc45f8
commit 14f84608dd
4 changed files with 10 additions and 49 deletions

View File

@ -10,15 +10,15 @@ import type { RouteChildProps } from '..';
import Claim from './claim';
import { ClaimRestricted } from './claim-restricted';
import { isRestricted } from './lib/is-restricted';
import { Callout, Intent, Splash } from '@vegaprotocol/ui-toolkit';
import { Splash } from '@vegaprotocol/ui-toolkit';
const ClaimIndex = ({ name }: RouteChildProps) => {
useDocumentTitle(name);
const { t } = useTranslation();
const { account } = useWeb3React();
const { tranches, loading, error } = useTranches();
const { tranches } = useTranches();
if (loading || !tranches) {
if (!tranches) {
return (
<Splash>
<SplashLoader />
@ -26,14 +26,6 @@ const ClaimIndex = ({ name }: RouteChildProps) => {
);
}
if (error) {
return (
<Callout intent={Intent.Danger} title={t('errorLoadingTranches')}>
{error}
</Callout>
);
}
let content = null;
if (!account) {

View File

@ -1,18 +1,12 @@
import { useTranslation } from 'react-i18next';
import {
Callout,
EtherscanLink,
Intent,
Splash,
} from '@vegaprotocol/ui-toolkit';
import { EtherscanLink } from '@vegaprotocol/ui-toolkit';
import { KeyValueTable, KeyValueTableRow } from '@vegaprotocol/ui-toolkit';
import { ADDRESSES } from '../../../config';
import { useTranches } from '../../../hooks/use-tranches';
import type { BigNumber } from '../../../lib/bignumber';
import { formatNumber } from '../../../lib/format-number';
import { TokenDetailsCirculating } from './token-details-circulating';
import { SplashLoader } from '../../../components/splash-loader';
export const TokenDetails = ({
totalSupply,
@ -23,24 +17,7 @@ export const TokenDetails = ({
}) => {
const { t } = useTranslation();
const { tranches, loading, error } = useTranches();
if (error) {
return (
<Callout intent={Intent.Danger} title={t('errorLoadingTranches')}>
{error}
</Callout>
);
}
if (!tranches || loading) {
return (
<Splash>
<SplashLoader />
</Splash>
);
}
const { tranches } = useTranches();
return (
<KeyValueTable className={'token-details'}>
<KeyValueTableRow>

View File

@ -28,7 +28,7 @@ const RedemptionRouter = () => {
appState: { trancheBalances },
} = useAppState();
const { account } = useWeb3React();
const { tranches, error, loading } = useTranches();
const { tranches, error } = useTranches();
React.useEffect(() => {
const run = (address: string) => {
@ -59,7 +59,7 @@ const RedemptionRouter = () => {
);
}
if (!tranches || loading) {
if (!tranches) {
return (
<Splash>
<SplashLoader />

View File

@ -6,14 +6,14 @@ import { SplashLoader } from '../../components/splash-loader';
import { useDocumentTitle } from '../../hooks/use-document-title';
import { useTranches } from '../../hooks/use-tranches';
import type { RouteChildProps } from '..';
import { Callout, Intent, Splash } from '@vegaprotocol/ui-toolkit';
import { Splash } from '@vegaprotocol/ui-toolkit';
const TrancheRouter = ({ name }: RouteChildProps) => {
useDocumentTitle(name);
const { t } = useTranslation();
const { tranches, error, loading } = useTranches();
const { tranches } = useTranches();
if (!tranches || loading) {
if (!tranches) {
return (
<Splash>
<SplashLoader />
@ -21,14 +21,6 @@ const TrancheRouter = ({ name }: RouteChildProps) => {
);
}
if (error) {
return (
<Callout intent={Intent.Danger} title={t('errorLoadingTranches')}>
{error}
</Callout>
);
}
return (
<>
<Heading title={t('pageTitleTranches')} />