frontend/components/panels/LocationLinks.js
function LocationLinks(props) {
  const elements = props.locations.map((location, index, locations) => {
    let buildingName;
    if (location.match(/\d+\s*$/i)) {
      buildingName = location.replace(/\d+\s*$/i, '');
    } else {
      buildingName = location;
    }

    let optionalComma = null;
    if (index !== locations.length - 1) {
      optionalComma = ', ';
    }

    if (location.toUpperCase() === 'TBA' || location.toUpperCase() === 'LOCATION TBA') {
      if (locations.length > 1) {
        return null;
      }

      return location;
    }

    if (location.toUpperCase() === 'BOSTON DEPT') {
      return (
        <span key='Boston DEPT'>
          TBA &nbsp;(Boston Campus)
        </span>
      );
    }

    // The <a> tag needs to be on one line, or else react will insert spaces in the generated HTML.
    // And we only want spaces between these span elements, and not after the location and the comma.
    // eg YMCA, Hurting Hall and not YMCA , Hurting Hall
    return (
      <span key={ location }>
        <a target='_blank' rel='noopener noreferrer' href={ `https://maps.google.com/?q=${macros.collegeName} ${buildingName}` }>
          {location}
        </a>
        {optionalComma}
      </span>
    );
  });

  return (
    <span>
      {elements}
    </span>
  );
}
function LocationLinks(props) {
  const elements = props.locations.map((location, index, locations) => {
    let buildingName;
    if (location.match(/\d+\s*$/i)) {
      buildingName = location.replace(/\d+\s*$/i, '');
    } else {
      buildingName = location;
    }

    let optionalComma = null;
    if (index !== locations.length - 1) {
      optionalComma = ', ';
    }

    if (location.toUpperCase() === 'TBA' || location.toUpperCase() === 'LOCATION TBA') {
      if (locations.length > 1) {
        return null;
      }

      return location;
    }

    if (location.toUpperCase() === 'BOSTON DEPT') {
      return (
        <span key='Boston DEPT'>
          TBA &nbsp;(Boston Campus)
        </span>
      );
    }

    // The <a> tag needs to be on one line, or else react will insert spaces in the generated HTML.
    // And we only want spaces between these span elements, and not after the location and the comma.
    // eg YMCA, Hurting Hall and not YMCA , Hurting Hall
    return (
      <span key={ location }>
        <a target='_blank' rel='noopener noreferrer' href={ `https://maps.google.com/?q=${macros.collegeName} ${buildingName}` }>
          {location}
        </a>
        {optionalComma}
      </span>
    );
  });

  return (
    <span>
      {elements}
    </span>
  );
}
function LocationLinks ( props ) { const elements = props . locations . map ( ( location , index , locations ) => { let buildingName ; if ( location . match ( / \d+\s*$ / i ) ) { buildingName = location . replace ( / \d+\s*$ / i , '' ) ; } else { buildingName = location ; } let optionalComma = null ; if ( index !== locations . length - 1 ) { optionalComma = ', ' ; } if ( location . toUpperCase ( ) === 'TBA' || location . toUpperCase ( ) === 'LOCATION TBA' ) { if ( locations . length > 1 ) { return null ; } return location ; } if ( location . toUpperCase ( ) === 'BOSTON DEPT' ) { return ( < span key = 'Boston DEPT' > 
          TBA &nbsp;(Boston Campus)
         < / span > ) ; } // The <a> tag needs to be on one line, or else react will insert spaces in the generated HTML. // And we only want spaces between these span elements, and not after the location and the comma. // eg YMCA, Hurting Hall and not YMCA , Hurting Hall return ( < span key = { location } > < a target = '_blank' rel = 'noopener noreferrer' href = { ` ${ macros . collegeName } ${ buildingName } ` } > { location } < / a > { optionalComma } < / span > ) ; } ) ; return ( < span > { elements } < / span > ) ; }
Calculate the Google Maps links from a given section. This is used in both the mobile section panel and the desktop section panel.
Calculate the Google Maps links from a given section . This is used in both the mobile section panel and the desktop section panel .