File indexing completed on 2025-01-26 05:27:59
0001 import React, { useState } from 'react'; 0002 const Support = (props) => { 0003 const [typed, setTyped] = useState(); 0004 const tiers = [0.99, 2, 5, 10, 20, 50]; 0005 const limits = [2, 5, 10, 20, 50, 100]; 0006 0007 const onChangeFreeamount = event => { 0008 setTyped(event.target.value); 0009 } 0010 0011 const container = tiers.map((t, index) => { 0012 let c; 0013 let tmp = t; 0014 let left, right; 0015 if (index == 0) { 0016 left = 0; 0017 } else { 0018 left = limits[index - 1]; 0019 } 0020 right = limits[index]; 0021 0022 const result = props.supporters.filter(s => (s.section_support_tier >= left && s.section_support_tier < right)); 0023 let url = this.props.baseUrlStore+'/support-predefined?section_id='+props.section.section_id; 0024 url = url+'&amount_predefined='+tmp; 0025 return ( 0026 <div className="tier-container" key={index}> 0027 <span>{result.length + ' Supporters'}</span> 0028 <div className="join"> 0029 <a href={url}>Join ${t} Tier</a> 0030 </div> 0031 </div> 0032 ); 0033 } 0034 ); 0035 0036 let result = props.supporters.filter(s => s.section_support_tier >= 100); 0037 let othertiers; 0038 let o; 0039 0040 const x = result.map((s, index) => { 0041 return ( 0042 <li key={index}> 0043 <a href={props.baseUrlStore + '/u/' + s.username}><img src={s.profile_image_url}></img></a> 0044 </li> 0045 ) 0046 } 0047 ); 0048 o = <ul>{x}</ul> 0049 0050 let url = props.baseUrlStore + '/support-predefined?section_id=' + props.section.section_id; 0051 url = url + '&amount_predefined=' + typed; 0052 0053 othertiers = ( 0054 <div className="tier-container"> 0055 {o && 0056 <span>{x.length} Supporters </span> 0057 } 0058 0059 <div className="join"> 0060 <div> 0061 $<input className="free-amount" onChange={onChangeFreeamount}></input><span>100 or more</span> 0062 </div> 0063 <div> 0064 <a href={url} id="free-amount-link" >Join </a> 0065 </div> 0066 </div> 0067 </div> 0068 ) 0069 0070 return ( 0071 <div className="support-container"> 0072 <div className="tiers"> 0073 <h5>Tiers</h5> 0074 </div> 0075 {container} 0076 {othertiers} 0077 </div> 0078 ) 0079 } 0080 0081 export default Support 0082