Guest User

Untitled

a guest
Oct 19th, 2017
160
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import React, { Component } from 'react'
  2. import '@shopify/polaris/styles.css';
  3. import '../../custom.css';
  4. import '@shopify/polaris/bootstrap.css';
  5. import '@shopify/polaris/datatable.css';
  6. import {Link} from 'react-router-dom';
  7. import '@shopify/polaris/datatable';
  8. import $ from 'jquery';
  9. import jQuery from 'jquery';
  10. import Griddle from 'griddle-react';
  11. import {Page, Card, Badge, Button, Layout, FormLayout, TextField, DisplayText, Select, Pagination} from '@shopify/polaris';
  12. // import NavBar from '../Navbar'
  13. var thisclass = '';
  14. var employessData = [];
  15. export default class Employeestable extends Component {
  16.     state = { parentChecked: '', vuid: '', stateReady: false}
  17.     constructor(props){
  18.         super(props);
  19.         var result = '';
  20.         this.state = {
  21.            
  22.         };
  23.         thisclass = this;
  24.         this.addlocalid = this.addlocalid.bind(this);
  25.       }
  26.     componentDidMount(){
  27.         employessData = thisclass.props.data;
  28.        
  29.         thisclass.setState({
  30.             stateReady: true
  31.         })
  32.  
  33.  
  34.         var self = this;
  35.         $('#mytableEmp').dataTable({
  36.             "columnDefs": [
  37.                 { "width": "20px", "targets": 0 }
  38.             ],
  39.             "pagingType": "numbers",
  40.             "bAutoWidth": false,
  41.             "bDestroy": true,      
  42.             "fnDrawCallback": function() {             
  43.                 self.forceUpdate();        
  44.             }
  45.         });
  46.         $('#checkboxhead').removeAttr('area-sort').removeClass('sorting_asc');
  47.         $(".checkAllCBEmp").click(function () {
  48.             $('#mytableEmp tbody input[type="checkbox"]').prop('checked', this.checked);
  49.         });
  50.  
  51.         $("#searchtabletb").on("keyup", function() {
  52.             var value = $(this).val();
  53.             value = value.toLowerCase();
  54.             console.log(value);
  55.             $("#mytableEmp tr").each(function(index) {
  56.                 if (index != 0) {
  57.                     var row = $(this);
  58.  
  59.                     var id = row.find("td").text();
  60.                     id = id.toLowerCase();
  61.                     if (id.indexOf(value) === -1) {
  62.                         $(this).hide();
  63.                     }
  64.                     else {
  65.                         $(this).show();
  66.                     }
  67.                 }
  68.             });
  69.         });
  70.        
  71.  
  72.  
  73.     }
  74.   render () {
  75.    
  76.     return (
  77.      
  78.                
  79.                 <table className="table table-stripped" id="mytableEmp">
  80.                   <thead>
  81.                     <tr className="table-head-row">
  82.                       <th id="checkboxhead" className="firsttd">
  83.                         <div className="round-cb">
  84.                             <input type="checkbox" id="cb1_emp" className="checkAllCBEmp" />
  85.                             <label htmlFor="cb1_emp"></label>
  86.                         </div>
  87.                       </th>
  88.                       <th>Title</th>
  89.                       <th>Type</th>
  90.                       <th>Created on</th>
  91.                       <th>From</th>
  92.                       <th>To</th>
  93.                       <th>Processed</th>
  94.                       <th>Amount</th>
  95.                       <th>Status</th>
  96.                       <th id="detailarrowhead" className="lasttd"></th>
  97.                     </tr>
  98.                   </thead>
  99.                   <tbody>
  100.                   {
  101.                     this.state.stateReady ?
  102.                         employessData.map((heading, index) => {
  103.                         return(<tr role="row" className="tablerow" key={index}>
  104.                           <td className="firsttd">
  105.                             <div className="round-cb">
  106.                                 <input type="checkbox" value="cb1" id={heading.userId} />
  107.                                 <label htmlFor={heading.userId}></label>
  108.                             </div>
  109.                           </td>
  110.                           <td>
  111.                            
  112.                             <div className="emp-avatar">
  113.                                 <img src={heading.profile_picture} />
  114.                             </div>
  115.                            
  116.                             <div className="emp-title-div">
  117.                              <div className="emp-title">
  118.                                <div>
  119.                                  {heading.name}
  120.                                </div>
  121.                              </div>
  122.                            </div>
  123.                           </td>
  124.                           <td>c</td>
  125.                           <td>Texto 2</td>
  126.                           <td>Texto 2</td>
  127.                           <td>Texto 2</td>
  128.                           <td>Texto 2</td>
  129.                           <td>Texto 2</td>
  130.                           <td><span className="badge badge-red">Rejected</span></td>
  131.                           <td className="lasttd"><Link to="/emp-profile" className="table-details-btn" onClick={() => {this.addlocalid(heading.userId)}}>View User</Link></td>
  132.                         </tr>)
  133.                     })
  134.                     :
  135.                     ""
  136.                   }
  137.                    
  138.                    
  139.                    
  140.                   </tbody>
  141.                 </table>
  142.                
  143.     )
  144.   }
  145. }
Add Comment
Please, Sign In to add comment