File indexing completed on 2025-05-04 05:30:59

0001 import React, { useState } from 'react';
0002 const Support = (props) => {
0003   const [typed, setTyped] = useState(100);
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       const result = props.supporters.filter(s => (s.section_support_tier >= left && s.section_support_tier < right));
0022       let url = props.baseUrlStore+'/support-predefined?section_id='+props.section.section_id;
0023             url = url+'&amount_predefined='+tmp;
0024       return (
0025         <div className="tier-container" key={index}>
0026           <span>{result.length + ' Supporters'}</span>
0027           <div className="join">
0028             <a href={url}>Join ${t} Tier</a>
0029           </div>
0030         </div>
0031       );
0032     }
0033   );
0034 
0035   let result = props.supporters.filter(s => s.section_support_tier >= 100);
0036   let othertiers;
0037   let o;
0038 
0039     const x = result.map((s, index) => {
0040       return (
0041         <li key={index}>
0042           <a href={props.baseUrlStore + '/u/' + s.username}><img src={s.profile_image_url}></img></a>
0043         </li>
0044       )
0045     }
0046     );
0047     o = <ul>{x}</ul>
0048 
0049     let url = props.baseUrlStore + '/support-predefined?section_id=' + props.section.section_id;
0050     url = url + '&amount_predefined=' + typed;
0051 
0052     othertiers = (
0053       <div className="tier-container">
0054         {o &&
0055           <span>{x.length} Supporters </span>
0056         }
0057 
0058         <div className="join">
0059           <div>
0060             $<input className="free-amount" onChange={onChangeFreeamount} value={typed}></input><span>or more</span>
0061           </div>
0062           <div>
0063             <a href={url} id="free-amount-link" >Join </a>
0064           </div>
0065         </div>
0066       </div>
0067     )
0068 
0069   return (
0070     <div className="support-container">
0071         <div className="tiers">
0072           <h5>Tiers</h5>
0073         </div>
0074         {container}
0075         {othertiers}
0076       </div>
0077   )
0078 }
0079 
0080 export default Support
0081