Unverified Commit a3ad5631 authored by Gautier D's avatar Gautier D Committed by Florent Chehab
Browse files

refacto(frontend): modify campus and city in MainMap

parent 0268d12e
......@@ -14,3 +14,4 @@ database.db-journal
.idea
npm-debug.log
.env
.history
......@@ -15,25 +15,21 @@ const MAIN_MAP_ID = uuid();
function MainMap() {
const [listUnivSel] = useSelectedUniversities();
const mainCampusesSelection = useMemo(() => {
const univSelection = useMemo(() => {
const out = [];
const mainCampuses = UniversityService.getMainCampuses();
const universities = UniversityService.getUniversities();
mainCampuses.forEach(campus => {
const univ = UniversityService.getUniversityById(campus.university);
if (campus && univ) {
const { city, country } = UniversityService.getUnivCityAndCountry(
univ.id
);
universities.forEach(university => {
const univ = UniversityService.getUniversityById(university.id);
if (univ) {
out.push({
univName: univ.name,
univLogoUrl: univ.logo,
cityName: city.name,
countryName: country.name,
lat: parseFloat(campus.lat),
lon: parseFloat(campus.lon),
cityName: univ.city,
countryName: univ.country,
lat: parseFloat(univ.main_campus_lat),
lon: parseFloat(univ.main_campus_lon),
univId: univ.id,
selected:
listUnivSel === null ||
......@@ -46,7 +42,7 @@ function MainMap() {
}, [listUnivSel]);
// create all the markers
return <BaseMap id={MAIN_MAP_ID} campuses={mainCampusesSelection} />;
return <BaseMap id={MAIN_MAP_ID} universities={univSelection} />;
}
MainMap.propTypes = {};
......
......@@ -98,9 +98,9 @@ class UniversityService {
* @returns {object} Object with city and country instance of the university (main campus)
*/
getUnivCityAndCountry(univId) {
const univMainCampus = this.getCampusForUnivId(univId);
const city = CityService.getCityForCityId(univMainCampus.city);
const country = CountryService.getCountryForCountryId(city.country);
const univ = this.getUniversityById(univId);
const city = univ.city;
const country = univ.country;
return {
city,
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment