Commit 9892f404 authored by isstuev's avatar isstuev

tx type fix

parent 5d536311
...@@ -4,14 +4,18 @@ import React from 'react'; ...@@ -4,14 +4,18 @@ import React from 'react';
import type { TransactionType } from 'types/api/transaction'; import type { TransactionType } from 'types/api/transaction';
export interface Props { export interface Props {
type: TransactionType; types: Array<TransactionType>;
} }
const TxStatus = ({ type }: Props) => { const TYPES_ORDER = [ 'token_creation', 'contract_creation', 'token_transfer', 'contract_call', 'coin_transfer' ];
const TxType = ({ types }: Props) => {
const typeToShow = types.sort((t1, t2) => TYPES_ORDER.indexOf(t1) - TYPES_ORDER.indexOf(t2))[0];
let label; let label;
let colorScheme; let colorScheme;
switch (type) { switch (typeToShow) {
case 'contract_call': case 'contract_call':
label = 'Contract call'; label = 'Contract call';
colorScheme = 'blue'; colorScheme = 'blue';
...@@ -41,4 +45,4 @@ const TxStatus = ({ type }: Props) => { ...@@ -41,4 +45,4 @@ const TxStatus = ({ type }: Props) => {
); );
}; };
export default TxStatus; export default TxType;
...@@ -40,7 +40,7 @@ const TxsListItem = ({ tx, showBlockInfo }: {tx: Transaction; showBlockInfo: boo ...@@ -40,7 +40,7 @@ const TxsListItem = ({ tx, showBlockInfo }: {tx: Transaction; showBlockInfo: boo
<Box width="100%" borderBottom="1px solid" borderColor={ borderColor } _first={{ borderTop: '1px solid', borderColor }}> <Box width="100%" borderBottom="1px solid" borderColor={ borderColor } _first={{ borderTop: '1px solid', borderColor }}>
<Flex justifyContent="space-between" mt={ 4 }> <Flex justifyContent="space-between" mt={ 4 }>
<HStack> <HStack>
{ tx.tx_types.map(item => <TxType key={ item } type={ item }/>) } <TxType types={ tx.tx_types }/>
<TxStatus status={ tx.status } errorText={ tx.status === 'error' ? tx.result : undefined }/> <TxStatus status={ tx.status } errorText={ tx.status === 'error' ? tx.result : undefined }/>
</HStack> </HStack>
<AdditionalInfoButton onClick={ onOpen }/> <AdditionalInfoButton onClick={ onOpen }/>
......
...@@ -76,7 +76,7 @@ const TxsTableItem = ({ tx, showBlockInfo }: {tx: Transaction; showBlockInfo: bo ...@@ -76,7 +76,7 @@ const TxsTableItem = ({ tx, showBlockInfo }: {tx: Transaction; showBlockInfo: bo
</Td> </Td>
<Td> <Td>
<VStack alignItems="start"> <VStack alignItems="start">
{ tx.tx_types.map(item => <TxType key={ item } type={ item }/>) } <TxType types={ tx.tx_types }/>
<TxStatus status={ tx.status } errorText={ tx.status === 'error' ? tx.result : undefined }/> <TxStatus status={ tx.status } errorText={ tx.status === 'error' ? tx.result : undefined }/>
</VStack> </VStack>
</Td> </Td>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment