SHARE
TWEET

Untitled

a guest Apr 18th, 2019 69 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import React from 'react';
  2.  
  3. const Summary = (props) => {
  4.  
  5.     String.prototype.capitalize = function() {
  6.         return this.charAt(0).toUpperCase() + this.slice(1);
  7.     }
  8.  
  9.     const result = props.testResponse.reduce((summary, item) => {
  10.         summary[item.service] = summary[item.service] || [];
  11.         summary[item.service].push(item);
  12.         return summary;
  13.       }, []);
  14.  
  15.     console.log(result);
  16.  
  17.     const summaryItems = Object.keys(result).forEach(key => {
  18.         <h5>{ key.capitalize() }</h5>
  19.         result[key].map((item, id) => (
  20.             <table class="table table-bordered table-hover">
  21.               <tbody>
  22.                 <tr>
  23.                   <th scope="row">{id}</th>
  24.                   <td>{ item.name }</td>
  25.                   {item.data.result ? <td>{item.data.result.supported ? "Supported" : "Not supported"}</td>: (null)}
  26.                 </tr>
  27.               </tbody>
  28.             </table>
  29.             ))
  30.         }
  31.     );
  32.  
  33.     // const summaryItems = props.testResponse.map((item, id) => (
  34.     //     <tr>
  35.     //     <th scope="row">{id}</th>
  36.     //     <td>{ item.name }</td>
  37.     //     {item.data.result ? <td>{item.data.result.supported ? "Supported" : "Not supported"}</td>: (null)}
  38.     //     </tr>
  39.     // ))
  40.  
  41.     return ( { summaryItems } )
  42. }
  43.  
  44. export default Summary;
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top