File indexing completed on 2025-05-04 05:31:00
0001 import React ,{useState,useEffect} from 'react' 0002 import ProductsContainer from './ProductsContainer'; 0003 0004 const Pling = (props) => { 0005 const [user, setUser] = useState({}); 0006 const [products, setProducts] = useState([]); 0007 const [baseUrlStore, setBaseUrlStore] = useState(window.config.baseUrlStore); 0008 useEffect(() => { 0009 loadData(); 0010 },[]); 0011 const loadData = () => { 0012 0013 0014 fetch(`/json/pling?username=${props.username}`, { 0015 mode: 'cors', 0016 credentials: 'include' 0017 }) 0018 .then(response => response.json()) 0019 .then(data => { 0020 let items = data; 0021 if (items && typeof(items.user) != "undefined") 0022 { 0023 setUser(items.user); 0024 setProducts(items.products); 0025 } 0026 }); 0027 0028 } 0029 0030 0031 return ( 0032 <div className="sub-system-container"> 0033 <div className="header">Pling : <a href={baseUrlStore+'/u/'+user.username}>{user.username} </a> 0034 { 0035 user.username && 0036 <img src={user.avatar}></img> 0037 } 0038 </div> 0039 0040 <div> 0041 0042 <ProductsContainer baseUrlStore={baseUrlStore} title="Products" products={products}/> 0043 </div> 0044 </div> 0045 ) 0046 } 0047 0048 export default Pling;