Advertisement
Guest User

Untitled

a guest
Jan 24th, 2018
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import React from 'react';
  2. import {Well, Table, Button} from 'react-bootstrap';
  3. import FontAwesome from 'react-fontawesome';
  4.  
  5. /*
  6. TableAdmin:
  7. buttons = un arreglo de botones que tienen los parámetros ['text, href, className']
  8. headers = un arregloque contiene las cabeceras de la tabla
  9. nameClass= una clase
  10. contents = un arreglo de contenidos
  11.  
  12. ObjectRow:
  13. rows: un arreglo que contiene los campos de una fila
  14. icons: un arreglo que contiene los iconos de una fila
  15.  
  16. */
  17.  
  18. const ObjectRow = ({  rows = [],  icons = []  }) => {
  19.     return (
  20.         <tr>
  21.             {
  22.                 rows.length ? (
  23.                     rows.map((row, i) => <td key={`row${i}`}> {row} </td>)
  24.                 ) : (null)
  25.             }
  26.             {
  27.                 icons.length ? (
  28.                   <td> 
  29.                     {
  30.                         icons.map((icon, i) => <Button href={icon[1]}><FontAwesome key={`icon${i}`} className={'icon '+icon[2]} name={icon[0]}  /></Button>)
  31.                     }  
  32.                   </td>
  33.                 ) : (null)
  34.             }
  35.         </tr>
  36.     );
  37. };
  38.  
  39. const TableAdmin = ({  headers = [], buttons = [], nameClass, contents = [], iconsRow = [] }) => {
  40.     return [
  41.         <div>
  42.             <Table responsive striped className={nameClass}>
  43.                 <thead>
  44.                     <tr>
  45.                         {
  46.                             headers.length ? (
  47.                                 headers.map((header, i) => <th key={`header${i}`}> {header} </th>)
  48.                             ) : (null)
  49.                         }
  50.                     </tr>
  51.                 </thead>
  52.                 <tbody>
  53.                     {
  54.                         console.log(iconsRow),
  55.                         contents.map((content, i) => <ObjectRow rows={content} icons={iconsRow}   /> )
  56.                     }
  57.                 </tbody>
  58.             </Table>
  59.                  <div className="text-center">
  60.                     {
  61.                         buttons.length ? (
  62.                             buttons.map((button, i) => <Button   key={`button${i}`}  className={button[2]} href={button[1]} >   {button[0]} </Button>)
  63.                         ) : (null)
  64.                     }
  65.                 </div>
  66.         </div>
  67.     ];
  68. };
  69.  
  70. export default TableAdmin;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement