2022-04-20 19:37:44 +00:00
|
|
|
import { useWeb3React } from '@web3-react/core';
|
|
|
|
import { useTranslation } from 'react-i18next';
|
|
|
|
|
|
|
|
import { EthConnectPrompt } from '../../components/eth-connect-prompt';
|
|
|
|
import { Heading } from '../../components/heading';
|
|
|
|
import { SplashLoader } from '../../components/splash-loader';
|
|
|
|
import { useDocumentTitle } from '../../hooks/use-document-title';
|
|
|
|
import { useTranches } from '../../hooks/use-tranches';
|
|
|
|
import type { RouteChildProps } from '..';
|
|
|
|
import Claim from './claim';
|
|
|
|
import { ClaimRestricted } from './claim-restricted';
|
|
|
|
import { isRestricted } from './lib/is-restricted';
|
2022-05-25 09:50:38 +00:00
|
|
|
import { Callout, Intent, Splash } from '@vegaprotocol/ui-toolkit';
|
2022-04-20 19:37:44 +00:00
|
|
|
|
|
|
|
const ClaimIndex = ({ name }: RouteChildProps) => {
|
|
|
|
useDocumentTitle(name);
|
|
|
|
const { t } = useTranslation();
|
|
|
|
const { account } = useWeb3React();
|
2022-05-25 09:50:38 +00:00
|
|
|
const { tranches, loading, error } = useTranches();
|
2022-04-20 19:37:44 +00:00
|
|
|
|
2022-05-25 09:50:38 +00:00
|
|
|
if (loading || !tranches) {
|
2022-04-20 19:37:44 +00:00
|
|
|
return (
|
|
|
|
<Splash>
|
|
|
|
<SplashLoader />
|
|
|
|
</Splash>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2022-05-25 09:50:38 +00:00
|
|
|
if (error) {
|
|
|
|
return (
|
|
|
|
<Callout intent={Intent.Danger} title={t('errorLoadingTranches')}>
|
|
|
|
{error}
|
|
|
|
</Callout>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2022-04-20 19:37:44 +00:00
|
|
|
let content = null;
|
|
|
|
|
|
|
|
if (!account) {
|
|
|
|
content = (
|
|
|
|
<EthConnectPrompt>
|
|
|
|
<p data-testid="eth-connect-prompt">
|
|
|
|
{t(
|
|
|
|
"Use the Ethereum wallet you want to send your tokens to. You'll also need enough Ethereum to pay gas."
|
|
|
|
)}
|
|
|
|
</p>
|
|
|
|
</EthConnectPrompt>
|
|
|
|
);
|
|
|
|
} else {
|
|
|
|
content = isRestricted() ? (
|
|
|
|
<ClaimRestricted />
|
|
|
|
) : (
|
|
|
|
<Claim address={account} tranches={tranches} />
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
return (
|
|
|
|
<>
|
|
|
|
<Heading title={t('pageTitleClaim')} />
|
|
|
|
{content}
|
|
|
|
</>
|
|
|
|
);
|
|
|
|
};
|
|
|
|
|
|
|
|
export default ClaimIndex;
|