feat(explorer): complete transfer status
This commit is contained in:
parent
cb0dd17839
commit
5803d6e890
@ -1,10 +1,13 @@
|
|||||||
import { t } from '@vegaprotocol/i18n';
|
import { t } from '@vegaprotocol/i18n';
|
||||||
import { headerClasses, wrapperClasses } from '../transfer-details';
|
import { headerClasses, wrapperClasses } from '../transfer-details';
|
||||||
import { Icon, Loader } from '@vegaprotocol/ui-toolkit';
|
import { Icon, Loader } from '@vegaprotocol/ui-toolkit';
|
||||||
|
import type { IconName } from '@vegaprotocol/ui-toolkit';
|
||||||
import type { ApolloError } from '@apollo/client';
|
import type { ApolloError } from '@apollo/client';
|
||||||
|
import { TransferStatus, TransferStatusMapping } from '@vegaprotocol/types';
|
||||||
|
import { IconNames } from '@blueprintjs/icons';
|
||||||
|
|
||||||
interface TransferStatusProps {
|
interface TransferStatusProps {
|
||||||
status: string;
|
status: TransferStatus | undefined;
|
||||||
error: ApolloError | undefined;
|
error: ApolloError | undefined;
|
||||||
loading: boolean;
|
loading: boolean;
|
||||||
}
|
}
|
||||||
@ -22,19 +25,58 @@ export function TransferStatusView({ status, loading }: TransferStatusProps) {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<div className={wrapperClasses}>
|
<div className={wrapperClasses}>
|
||||||
<h2 className={headerClasses}>{t('Status')}</h2>
|
<h2 className={headerClasses}>{t('Transfer Status')}</h2>
|
||||||
<div className="relative block rounded-lg py-6 text-center p-6">
|
<div className="relative block rounded-lg py-6 text-center p-6">
|
||||||
{loading ? (
|
{loading ? (
|
||||||
<Loader />
|
<Loader />
|
||||||
) : (
|
) : (
|
||||||
<>
|
<>
|
||||||
<p className="leading-10 my-2">
|
<p className="leading-10 my-2">
|
||||||
<Icon name="tick" className="text-green-500" />
|
<Icon
|
||||||
|
name={getIconForStatus(status)}
|
||||||
|
className={getColourForStatus(status)}
|
||||||
|
/>
|
||||||
</p>
|
</p>
|
||||||
<p className="leading-10 my-2">{status}</p>
|
<p className="leading-10 my-2">{TransferStatusMapping[status]}</p>
|
||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Simple mapping from status to icon name
|
||||||
|
* @param status TransferStatus
|
||||||
|
* @returns IconName
|
||||||
|
*/
|
||||||
|
export function getIconForStatus(status: TransferStatus): IconName {
|
||||||
|
switch (status) {
|
||||||
|
case TransferStatus.STATUS_PENDING:
|
||||||
|
return IconNames.TIME;
|
||||||
|
case TransferStatus.STATUS_DONE:
|
||||||
|
return IconNames.TICK;
|
||||||
|
case TransferStatus.STATUS_REJECTED:
|
||||||
|
return IconNames.CROSS;
|
||||||
|
default:
|
||||||
|
return IconNames.TIME;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Simple mapping from status to colour
|
||||||
|
* @param status TransferStatus
|
||||||
|
* @returns string Tailwind classname
|
||||||
|
*/
|
||||||
|
export function getColourForStatus(status: TransferStatus): string {
|
||||||
|
switch (status) {
|
||||||
|
case TransferStatus.STATUS_PENDING:
|
||||||
|
return 'text-yellow-500';
|
||||||
|
case TransferStatus.STATUS_DONE:
|
||||||
|
return 'text-green-500';
|
||||||
|
case TransferStatus.STATUS_REJECTED:
|
||||||
|
return 'text-red-500';
|
||||||
|
default:
|
||||||
|
return 'text-yellow-500';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -20,8 +20,6 @@ interface TransferDetailsProps {
|
|||||||
transfer: Transfer;
|
transfer: Transfer;
|
||||||
from: string;
|
from: string;
|
||||||
id: string;
|
id: string;
|
||||||
// If set, all blocks except the status one are hidden
|
|
||||||
statusOnly?: boolean;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -30,12 +28,7 @@ interface TransferDetailsProps {
|
|||||||
*
|
*
|
||||||
* @param transfer A recurring transfer object
|
* @param transfer A recurring transfer object
|
||||||
*/
|
*/
|
||||||
export function TransferDetails({
|
export function TransferDetails({ transfer, from, id }: TransferDetailsProps) {
|
||||||
transfer,
|
|
||||||
from,
|
|
||||||
id,
|
|
||||||
statusOnly = false,
|
|
||||||
}: TransferDetailsProps) {
|
|
||||||
const recurring = transfer.recurring;
|
const recurring = transfer.recurring;
|
||||||
|
|
||||||
// Currently all this is passed in to TransferStatus, but the extra details
|
// Currently all this is passed in to TransferStatus, but the extra details
|
||||||
@ -50,18 +43,14 @@ export function TransferDetails({
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="flex gap-5 flex-wrap">
|
<div className="flex gap-5 flex-wrap">
|
||||||
{statusOnly ? null : (
|
<TransferParticipants from={from} transfer={transfer} />
|
||||||
<>
|
|
||||||
<TransferParticipants from={from} transfer={transfer} />
|
|
||||||
{recurring ? <TransferRepeat recurring={transfer.recurring} /> : null}
|
|
||||||
{recurring && recurring.dispatchStrategy ? (
|
|
||||||
<TransferRewards recurring={transfer.recurring} />
|
|
||||||
) : null}
|
|
||||||
</>
|
|
||||||
)}
|
|
||||||
{status ? (
|
{status ? (
|
||||||
<TransferStatusView status={status} error={error} loading={loading} />
|
<TransferStatusView status={status} error={error} loading={loading} />
|
||||||
) : null}
|
) : null}
|
||||||
|
{recurring ? <TransferRepeat recurring={transfer.recurring} /> : null}
|
||||||
|
{recurring && recurring.dispatchStrategy ? (
|
||||||
|
<TransferRewards recurring={transfer.recurring} />
|
||||||
|
) : null}
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -171,7 +171,6 @@ export const TxProposal = ({ txData, pubKey, blockData }: TxProposalProps) => {
|
|||||||
{transfer && (
|
{transfer && (
|
||||||
<div className="mt-8">
|
<div className="mt-8">
|
||||||
<TransferDetails
|
<TransferDetails
|
||||||
statusOnly={false}
|
|
||||||
transfer={transfer}
|
transfer={transfer}
|
||||||
from={from || ''}
|
from={from || ''}
|
||||||
id={deterministicId}
|
id={deterministicId}
|
||||||
|
Loading…
Reference in New Issue
Block a user