github.com/shyftnetwork/go-empyrean@v1.8.3-0.20191127201940-fbfca9338f04/shyftBlockExplorerUI/src/components/table/internalTransactions/internalRow.js (about) 1 import React, { Component } from 'react'; 2 import InternalTable from './internalTable'; 3 import classes from './table.css'; 4 import axios from "axios"; 5 import {API_URL} from "../../../constants/apiURL"; 6 import ErrorMessage from './errorMessage'; 7 8 class InternalTransactionsTable extends Component { 9 constructor(props) { 10 super(props); 11 this.state = { 12 data: [], 13 emptyDataSet: true 14 }; 15 } 16 17 async componentDidMount() { 18 try { 19 const response = await axios.get(`${API_URL}/get_internal_transactions/`); 20 if(response.data === "\n") { 21 this.setState({emptyDataSet: true}) 22 } else { 23 this.setState({emptyDataSet: false}) 24 } 25 await this.setState({data: response.data}); 26 } catch (err) { 27 console.log(err); 28 } 29 } 30 31 render() { 32 let table; 33 if(this.state.emptyDataSet === false && this.state.data.length > 0 ) { 34 table = this.state.data.map((data, i) => { 35 return <InternalTable 36 key={`${data.TxHash}${i}`} 37 Hash={data.Hash} 38 Action={data.Action} 39 To={data.To} 40 From= {data.From} 41 Gas={data.Gas} 42 GasUsed={data.GasUsed} 43 ID={data.ID} 44 Input={data.Input} 45 Output={data.Output} 46 Time={data.Time} 47 Value={data.Value} 48 detailInternalHandler={this.props.detailInternalHandler} 49 /> 50 }); 51 } 52 53 let combinedClasses = ['responsive-table', classes.table]; 54 return ( 55 <div> 56 { 57 this.state.emptyDataSet === false && this.state.data.length > 0 ? 58 <table className={combinedClasses.join(' ')}> 59 <thead> 60 <tr> 61 <th scope="col" className={classes.thItem}> Block Hash </th> 62 <th scope="col" className={classes.thItem}> Action </th> 63 <th scope="col" className={classes.thItem}> To </th> 64 <th scope="col" className={classes.thItem}> From </th> 65 <th scope="col" className={classes.thItem}> Gas </th> 66 <th scope="col" className={classes.thItem}> Gas Used</th> 67 <th scope="col" className={classes.thItem}> ID </th> 68 <th scope="col" className={classes.thItem}> Input </th> 69 <th scope="col" className={classes.thItem}> Output </th> 70 <th scope="col" className={classes.thItem}> Time </th> 71 <th scope="col" className={classes.thItem}> Value </th> 72 </tr> 73 </thead> 74 {table} 75 </table> 76 : <ErrorMessage /> 77 } 78 </div> 79 ); 80 } 81 } 82 export default InternalTransactionsTable;