forked from blockscout/frontend
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathTxType.tsx
62 lines (52 loc) · 1.45 KB
/
TxType.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
import React from 'react';
import type { TransactionType } from 'types/api/transaction';
import Tag from 'ui/shared/chakra/Tag';
export interface Props {
types: Array<TransactionType>;
isLoading?: boolean;
}
const TYPES_ORDER = [ 'rootstock_remasc', 'rootstock_bridge', 'token_creation', 'contract_creation', 'token_transfer', 'contract_call', 'coin_transfer' ];
const TxType = ({ types, isLoading }: Props) => {
const typeToShow = types.sort((t1, t2) => TYPES_ORDER.indexOf(t1) - TYPES_ORDER.indexOf(t2))[0];
let label;
let colorScheme;
switch (typeToShow) {
case 'contract_call':
label = 'Contract call';
colorScheme = 'blue';
break;
case 'contract_creation':
label = 'Contract creation';
colorScheme = 'blue';
break;
case 'token_transfer':
label = 'Token transfer';
colorScheme = 'orange';
break;
case 'token_creation':
label = 'Token creation';
colorScheme = 'orange';
break;
case 'coin_transfer':
label = 'Coin transfer';
colorScheme = 'orange';
break;
case 'rootstock_remasc':
label = 'REMASC';
colorScheme = 'blue';
break;
case 'rootstock_bridge':
label = 'Bridge';
colorScheme = 'blue';
break;
default:
label = 'Transaction';
colorScheme = 'purple';
}
return (
<Tag colorScheme={ colorScheme } isLoading={ isLoading }>
{ label }
</Tag>
);
};
export default TxType;