/**************************************************/
/** REMOTE SCHOOL SELECTION
/**************************************************/
class UniversityLinks extends React.Component {
  constructor(props) {
    super()
    this.state = { loaded:false, data:[] }
  }
  componentDidMount() {
    callDb("/api/build.php?school=all", this);
  }
  render() {
    let linksLeft, linksRight, loading = 'Loading...';
    if(this.state.loaded){
      let sArr = this.state.data;
      loading = '';

      linksLeft = sArr.map(function(y, key) {
        if(sArr.length / 2 > key){
          return <div key={y.SchoolID}><Link to={'/transfer/'+y.SchoolID}>{y.Name}</Link></div>
        }
      })

      linksRight = sArr.map(function(y, key) {
        if(sArr.length / 2 <= key){
          return <div key={y.SchoolID}><Link to={'/transfer/'+y.SchoolID}>{y.Name}</Link></div>
        }
      })
    }
    return (
      <div className="main row">
        <div className="col-lg-3">
          <Sidebar />
        </div>
        <div className="col-lg-9">
          <h1>Transfer Equivalencies</h1>
          <p>If you do not see the institution you are looking for, please contact the Office of the Registrar at <a href="mailto:registrar@svsu.edu">registrar@svsu.edu</a>. Thank you.</p>
          <h2>Select Institution</h2>
          <div className="links row">
            <div className="col-12">{ loading }</div>
            <div className="col-6">{ linksLeft }</div>
            <div className="col-6">{ linksRight }</div>
          </div>
        </div>
      </div>
    )
  }
}
