b3ce40da7f
* frontend-monorepo-629: Made nav consistent with TFE and added focus-visible states * frontend-monorepo-629: Header icons working * frontend-monorepo-629: Tweak of header spacing * frontend-monorepo-629: Text styles and spacing on all routes bar governance * frontend-monorepo-629: Minor tweaks to font styles * frontend-monorepo-629: Removed import from older solution * frontend-monorepo-629: Evened up wallet padding to better suit the new button shadow styles * frontend-monorepo-629: White text and mono font where needed in the eth wallet * frontend-monorepo-629: Set only page header to use alpha lyrae * frontend-monorepo-629: More use of mono font for balances and some text alignment * frontend-monorepo-629: Keypair name element only rendered when name present * frontend-monorepo-629: Stopped header title overflow on small screens * frontend-monorepo-629: Button height established with padding to allow longer button text without overflow * frontend-monorepo-629: Mobile wallet title/key alignment improved for mobile * frontend-monorepo-629: Associated vega in wallet dark mode on * frontend-monorepo-629: Removed redundant classes on eth wallet connect button * frontend-monorepo-629: Vega wallet spacing tweaks
55 lines
1.6 KiB
TypeScript
55 lines
1.6 KiB
TypeScript
import React from 'react';
|
|
import { Callout, Loader } from '@vegaprotocol/ui-toolkit';
|
|
import { useTranslation } from 'react-i18next';
|
|
import { Link } from '@vegaprotocol/ui-toolkit';
|
|
import { useEnvironment } from '@vegaprotocol/environment';
|
|
|
|
export const TransactionPending = ({
|
|
hash,
|
|
heading,
|
|
footer,
|
|
body,
|
|
confirmations,
|
|
requiredConfirmations,
|
|
}: {
|
|
hash: string;
|
|
confirmations: number | null;
|
|
requiredConfirmations: number | null;
|
|
heading?: React.ReactElement | string;
|
|
footer?: React.ReactElement | string;
|
|
body?: React.ReactElement | string;
|
|
}) => {
|
|
const { ETHERSCAN_URL } = useEnvironment();
|
|
const { t } = useTranslation();
|
|
const remainingConfirmations = React.useMemo(() => {
|
|
if (requiredConfirmations) {
|
|
return Math.max(0, requiredConfirmations - (confirmations || 0));
|
|
}
|
|
return 0;
|
|
}, [confirmations, requiredConfirmations]);
|
|
const title = React.useMemo(() => {
|
|
const defaultTitle = heading || t('Transaction in progress');
|
|
if (remainingConfirmations > 0) {
|
|
return `${defaultTitle}. ${t('blockCountdown', {
|
|
amount: remainingConfirmations,
|
|
})}`;
|
|
}
|
|
return defaultTitle;
|
|
}, [heading, remainingConfirmations, t]);
|
|
return (
|
|
<Callout icon={<Loader size="small" />} title={title}>
|
|
{body && <p data-testid="transaction-pending-body">{body}</p>}
|
|
<p>
|
|
<Link
|
|
title={t('View transaction on Etherscan')}
|
|
target="_blank"
|
|
href={`${ETHERSCAN_URL}/tx/${hash}`}
|
|
>
|
|
{hash}
|
|
</Link>
|
|
</p>
|
|
{footer && <p data-testid="transaction-pending-footer">{footer}</p>}
|
|
</Callout>
|
|
);
|
|
};
|