Skip to content
Snippets Groups Projects
MemberList.js 1.07 KiB
Newer Older
  • Learn to ignore specific revisions
  • meskio's avatar
    meskio committed
    import React from "react";
    import { Table } from "react-bootstrap";
    import Fetcher from "./Fetcher";
    import { printMoney } from "./util";
    
    
    class MemberList extends React.Component {
    
    meskio's avatar
    meskio committed
      constructor(props) {
        super(props);
        this.state = {
          members: [],
        };
      }
    
    meskio's avatar
    meskio committed
      render() {
        const entries = this.state.members.map((member) => {
          return (
            <tr key={member.num}>
              <td>{member.num}</td>
              <td>{member.name}</td>
              <td>{member.email}</td>
    
    meskio's avatar
    meskio committed
              <td>{member.phone}</td>
    
    meskio's avatar
    meskio committed
              <td>{printMoney(member.balance)} </td>
            </tr>
          );
        });
    
    meskio's avatar
    meskio committed
        return (
          <Fetcher
            url="/api/member"
            onFetch={(members) => this.setState({ members })}
          >
            <Table striped bordered hover>
              <thead>
                <tr>
                  <th>Numero</th>
                  <th>Nombre</th>
                  <th>Email</th>
    
    meskio's avatar
    meskio committed
                  <th>Telefono</th>
    
    meskio's avatar
    meskio committed
                  <th>Saldo</th>
                </tr>
              </thead>
              <tbody>{entries}</tbody>
            </Table>
          </Fetcher>
        );
      }
    
    }
    
    export default MemberList;