{"size": 1948, "ext": "js", "max_stars_repo_path": "client/src/components/admin/AdminListProducts.js", "max_stars_repo_name": "vegapool/bntee", "max_stars_repo_stars_event_min_datetime": "2021-02-18T20:18:38.000Z", "max_stars_repo_stars_event_max_datetime": "2021-05-18T08:29:01.000Z", "max_issues_repo_path": "client/src/components/admin/AdminListProducts.js", "max_issues_repo_name": "vegapool/bntee", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "client/src/components/admin/AdminListProducts.js", "max_forks_repo_name": "vegapool/bntee", "max_forks_repo_forks_event_min_datetime": "2021-06-19T15:41:19.000Z", "max_forks_repo_forks_event_max_datetime": "2022-02-11T17:29:22.000Z"}
{"max_stars_count": 2, "max_issues_count": null, "max_forks_count": 2, "avg_line_length": 23.1904761905, "max_line_length": 90, "alphanum_fraction": 0.4378850103}
import React, {Component} from 'react';
import {Container, Row, Col, Table} from 'react-bootstrap';
import { Link } from 'react-router-dom';
import {withRouter} from 'react-router-dom';

class AdminListProducts extends Component {
  editProduct = (productItem) => {
    const {history} = this.props;
    history.replace(`/admin/products/${productItem._id}`)
  }
  render() {
  const {products} = this.props;
  let productList = <span />;
  if (products.length > 0) {
    const self = this;
    productList = <tbody>{products.map(function(pItem, pIdx){
      return (
        <tr onClick={()=>self.editProduct(pItem)}>
        <td>
          {pIdx + 1}
        </td>
         <td>
           {pItem.productName}
         </td>
         <td>
           {pItem.tokenAddress}
         </td>
         <td>
           {pItem.tokenSymbol}
         </td>
         <td>
           {pItem.poolAddress}
         </td>
        </tr>
        )
    })}</tbody>
  }
  return (
    <div>
      <div className="product-info">
          <Row>
            <Col lg={8}>
              <div className="table-header">
              Products
              </div>
            </Col>
            <Col lg={4}>
              <Link to="/admin/product/add" className="action-link">Add new product</Link>
            </Col>
          </Row>
      </div>    
      <Table className="product-table">
        <thead>
          <tr>
            <th>
            </th>
            <th>
              Name
            </th>
            <th>
              Token Address
            </th>
            <th>
              Token Symbol
            </th>
            <th>
              Pool Address
            </th>
            <th>
              Circulating supply
            </th>
            <th>
              Current price
            </th>
          </tr>
        </thead>
          {productList}
      </Table>
    </div>  
    )
  }
}

export default withRouter(AdminListProducts);