File indexing completed on 2025-01-26 05:27:59
0001 import React, { Component } from 'react'; 0002 import ProductGit from './ProductGit'; 0003 0004 class ProductsGitContainer extends React.Component { 0005 constructor(props){ 0006 super(props); 0007 this.gitUrl = '/json/gitlabnewprojects'; 0008 this.gitUserUrl = '/json/gitlabfetchuser?username='; 0009 this.state = {items:[]}; 0010 } 0011 0012 componentDidMount() { 0013 fetch(this.gitUrl) 0014 .then(response => response.json()) 0015 .then(data => { 0016 data.map((fi,index) => { 0017 let url = this.gitUserUrl+fi.namespace.name; 0018 return fetch(url) 0019 .then(response => response.json()) 0020 .then(data => { 0021 fi.user_avatar_url = data[0].avatar_url; 0022 let items = this.state.items.concat(fi); 0023 this.setState({items:items}); 0024 }) 0025 }); 0026 }); 0027 } 0028 0029 render(){ 0030 let container; 0031 container = <div> <h1> git-container </h1></div> 0032 if (this.state.items){ 0033 const items = this.state.items.sort(function(a,b){ 0034 return new Date(b.created_at) - new Date(a.created_at); 0035 }); 0036 const products = items.map((product,index) => ( 0037 <li key={index}> 0038 <ProductGit product={product}/> 0039 </li> 0040 )); 0041 container = <ul>{products}</ul> 0042 } 0043 return ( 0044 <div className="panelContainer"> 0045 <div className="title"> <a href={this.props.urlCode+"/explore/projects"}>Git-Projects</a></div> 0046 {container} 0047 </div> 0048 ) 0049 } 0050 } 0051 0052 export default ProductsGitContainer;