github.com/shyftnetwork/go-empyrean@v1.8.3-0.20191127201940-fbfca9338f04/shyftBlockExplorerUI/src/components/table/transactions/transactionRow.js (about)

     1  import React, { Component } from 'react';
     2  import TransactionsTable from './transactionTable';
     3  import classes from './table.css';
     4  import axios from "axios";
     5  import ErrorMessage from './errorMessage';
     6  import {API_URL} from "../../../constants/apiURL";
     7  
     8  class TransactionTable 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_all_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                  const conversion = data.Cost / 10000000000000000000;
    36                  return <TransactionsTable
    37                      key={`${data.TxHash}${i}`}
    38                      age={data.Age}
    39                      txHash={data.TxHash}
    40                      blockNumber={data.BlockNumber}
    41                      to={data.ToGet}
    42                      from={data.From}
    43                      value={data.Amount}
    44                      cost={conversion}
    45                      getBlockTransactions={this.props.getBlockTransactions}
    46                      detailTransactionHandler={this.props.detailTransactionHandler}
    47                      detailAccountHandler={this.props.detailAccountHandler}
    48                  />
    49              })        
    50          }
    51  
    52          let combinedClasses = ['responsive-table', classes.table];
    53          return (
    54              <div>     
    55                  {
    56                      this.state.emptyDataSet === false && this.state.data.length > 0 ?  
    57                          <table key={this.state.data.TxHash} className={combinedClasses.join(' ')}>
    58                              <thead>
    59                                  <tr>
    60                                      <th scope="col" className={classes.thItem}> TxHash </th>
    61                                      <th scope="col" className={classes.thItem}> Block </th>
    62                                      <th scope="col" className={classes.thItem}> Age </th>
    63                                      <th scope="col" className={classes.thItem}> From </th>                      
    64                                      <th scope="col" className={classes.thItem}> To </th>
    65                                      <th scope="col" className={classes.thItem}> Value </th>
    66                                      <th scope="col" className={classes.thItem}> TxFee </th>
    67                                  </tr>
    68                              </thead>
    69                              {table}
    70                          </table>
    71                      : <ErrorMessage />
    72                  } 
    73              </div>           
    74          );
    75      }
    76  }
    77  export default TransactionTable;