@studyportals/fawkes 9.0.1-4 → 9.0.1-6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,5 +1,6 @@
1
1
  import { areasAll } from '@studyportals/static-domain-data/areas/areas';
2
2
  import { areaGetPath } from '@studyportals/static-domain-data/areas/area-get-path';
3
+ import { countryGetIdFromIsoCode } from '@studyportals/static-domain-data/countries/country-get-id-from-iso-code';
3
4
  import { FilterKey } from '@studyportals/search-filters/server-side';
4
5
  export class AreaPresenter {
5
6
  filterKey = FilterKey.AREA;
@@ -18,13 +19,14 @@ export class AreaPresenter {
18
19
  const areas = [];
19
20
  areasAll.forEach((area) => {
20
21
  const path = areaGetPath(area.id);
22
+ const countryId = countryGetIdFromIsoCode(area.countryIso);
21
23
  if (path === null) {
22
24
  return;
23
25
  }
24
26
  areas.push({
25
27
  id: area.id,
26
28
  path,
27
- countryId: area.countryId
29
+ countryId: countryId || ""
28
30
  });
29
31
  });
30
32
  return areas;
@@ -33,6 +35,6 @@ export class AreaPresenter {
33
35
  return this.fragments;
34
36
  }
35
37
  isPartOfGivenCountries(areaId, countries) {
36
- return areasAll.some(a => a.id === areaId && countries.includes(a.countryId));
38
+ return areasAll.some(a => a.id === areaId && countries.includes(a.countryIso));
37
39
  }
38
40
  }
@@ -2,6 +2,7 @@ import { FilterKey } from '@studyportals/search-filters/server-side';
2
2
  import { countriesExtendedAll } from '@studyportals/static-domain-data/countries/countries-extended';
3
3
  import { countryGetIsoCodePath } from '@studyportals/static-domain-data/countries/country-get-iso-path';
4
4
  import { areaGetPath } from '@studyportals/static-domain-data/areas/area-get-path';
5
+ import { countryGetIdFromIsoCode } from '@studyportals/static-domain-data/countries/country-get-id-from-iso-code';
5
6
  export class CityPresenter {
6
7
  filterKey = FilterKey.CITY;
7
8
  searchApiClient;
@@ -44,11 +45,12 @@ export class CityPresenter {
44
45
  const useAreaPath = areaPath && areaPath.trim() !== '';
45
46
  // AreaPath do also includes country, for that reason, we do not need to add countryPath if area exists
46
47
  const cityPath = `${useAreaPath ? areaPath : countryPath}/${city.virtualPath}`;
48
+ const countryId = countryGetIdFromIsoCode(country?.iso || "") || "";
47
49
  return {
48
50
  id: city.id.toString(),
49
51
  path: cityPath,
50
52
  areaId: useAreaPath ? city.areaId?.toString() : null,
51
- countryId: country ? country.id.toString() : '',
53
+ countryId,
52
54
  };
53
55
  }
54
56
  }
@@ -1,5 +1,6 @@
1
1
  import { countriesExtendedAll } from '@studyportals/static-domain-data/countries/countries-extended';
2
2
  import { countryGetIsoCodePath } from '@studyportals/static-domain-data/countries/country-get-iso-path';
3
+ import { countryGetIdFromIsoCode } from '@studyportals/static-domain-data/countries/country-get-id-from-iso-code';
3
4
  import { FilterKey } from '@studyportals/search-filters/server-side';
4
5
  export class CountryPresenter {
5
6
  filterKey = FilterKey.COUNTRY;
@@ -20,16 +21,19 @@ export class CountryPresenter {
20
21
  if (!country.iso) {
21
22
  return;
22
23
  }
24
+ const countryId = countryGetIdFromIsoCode(country.iso);
23
25
  const path = countryGetIsoCodePath(country.iso);
24
26
  if (path === null) {
25
27
  return;
26
28
  }
27
29
  countries.push({
28
- id: country.id,
30
+ id: countryId || "",
29
31
  iso: country.iso,
30
32
  path
31
33
  });
32
34
  });
35
+ //eslint-disable-next-line no-console
36
+ console.log('generated country fragments', countries);
33
37
  return countries;
34
38
  }
35
39
  getFragments() {
@@ -16,7 +16,7 @@ export class OnlyCountriesDisciplineCountryRule {
16
16
  const allowedCountryIds = this.getAllowedCountryIds();
17
17
  //eslint-disable-next-line no-console
18
18
  console.log('allowed country ids', Array.from(allowedCountryIds));
19
- return Promise.resolve(allowedCountryIds.has(selectedCountry));
19
+ return Promise.resolve(allowedCountryIds.includes(selectedCountry));
20
20
  }
21
21
  forSitemapGenerator(filterKeyValues) {
22
22
  const selectedCountries = filterKeyValues.get(FilterKey.COUNTRY);
@@ -27,13 +27,13 @@ export class OnlyCountriesDisciplineCountryRule {
27
27
  if (!selectedCountry) {
28
28
  return Promise.resolve(false);
29
29
  }
30
- return Promise.resolve(this.getAllowedCountryIds().has(selectedCountry));
30
+ return Promise.resolve(this.getAllowedCountryIds().includes(selectedCountry));
31
31
  }
32
32
  getAllowedCountryIds() {
33
- return new Set(CountryPresenter.getInstance()
33
+ return Array.from(new Set(CountryPresenter.getInstance()
34
34
  .getFragments()
35
35
  .filter((country) => this.allowedCountryIsos.includes(country.iso))
36
- .map((country) => country.id));
36
+ .map((country) => country.id)));
37
37
  }
38
38
  getDescription() {
39
39
  return 'Country is one of the allowed countries for discipline and country pages';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@studyportals/fawkes",
3
- "version": "9.0.1-4",
3
+ "version": "9.0.1-6",
4
4
  "description": "A package to centralize SEO related logic for SBLP and Sitemap Generator.",
5
5
  "files": [
6
6
  "./dist"
@@ -94,7 +94,7 @@
94
94
  "@studyportals/ranking-api-interface": "^2.4.0",
95
95
  "@studyportals/search-api-interface": "5.9.3-0",
96
96
  "@studyportals/search-filters": "^6.3.1",
97
- "@studyportals/static-domain-data": "^6.1.0"
97
+ "@studyportals/static-domain-data": "^7.2.0"
98
98
  },
99
99
  "optionalDependencies": {
100
100
  "@rollup/rollup-linux-x64-gnu": "4.24.0"