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 ...@@ -14,3 +14,4 @@ database.db-journal
.idea .idea
npm-debug.log npm-debug.log
.env .env
.history
...@@ -15,25 +15,21 @@ const MAIN_MAP_ID = uuid(); ...@@ -15,25 +15,21 @@ const MAIN_MAP_ID = uuid();
function MainMap() { function MainMap() {
const [listUnivSel] = useSelectedUniversities(); const [listUnivSel] = useSelectedUniversities();
const mainCampusesSelection = useMemo(() => { const univSelection = useMemo(() => {
const out = []; const out = [];
const mainCampuses = UniversityService.getMainCampuses(); const universities = UniversityService.getUniversities();
mainCampuses.forEach(campus => { universities.forEach(university => {
const univ = UniversityService.getUniversityById(campus.university); const univ = UniversityService.getUniversityById(university.id);
if (campus && univ) {
const { city, country } = UniversityService.getUnivCityAndCountry(
univ.id
);
if (univ) {
out.push({ out.push({
univName: univ.name, univName: univ.name,
univLogoUrl: univ.logo, univLogoUrl: univ.logo,
cityName: city.name, cityName: univ.city,
countryName: country.name, countryName: univ.country,
lat: parseFloat(campus.lat), lat: parseFloat(univ.main_campus_lat),
lon: parseFloat(campus.lon), lon: parseFloat(univ.main_campus_lon),
univId: univ.id, univId: univ.id,
selected: selected:
listUnivSel === null || listUnivSel === null ||
...@@ -46,7 +42,7 @@ function MainMap() { ...@@ -46,7 +42,7 @@ function MainMap() {
}, [listUnivSel]); }, [listUnivSel]);
// create all the markers // create all the markers
return <BaseMap id={MAIN_MAP_ID} campuses={mainCampusesSelection} />; return <BaseMap id={MAIN_MAP_ID} universities={univSelection} />;
} }
MainMap.propTypes = {}; MainMap.propTypes = {};
......
...@@ -98,9 +98,9 @@ class UniversityService { ...@@ -98,9 +98,9 @@ class UniversityService {
* @returns {object} Object with city and country instance of the university (main campus) * @returns {object} Object with city and country instance of the university (main campus)
*/ */
getUnivCityAndCountry(univId) { getUnivCityAndCountry(univId) {
const univMainCampus = this.getCampusForUnivId(univId); const univ = this.getUniversityById(univId);
const city = CityService.getCityForCityId(univMainCampus.city); const city = univ.city;
const country = CountryService.getCountryForCountryId(city.country); const country = univ.country;
return { return {
city, city,
......
Markdown is supported
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