diff --git a/src/components/grw-trek-detail/grw-trek-detail.tsx b/src/components/grw-trek-detail/grw-trek-detail.tsx index 4dc9278..7ee4e9e 100644 --- a/src/components/grw-trek-detail/grw-trek-detail.tsx +++ b/src/components/grw-trek-detail/grw-trek-detail.tsx @@ -556,6 +556,10 @@ export class GrwTrekDetail { {this.practice?.name} + {this.currentTrek.ratings.map(trekRating => ( +
{state.ratings.find(rating => rating.id === trekRating).name}
+ ))} + {this.currentTrek.ratings_description && this.currentTrek.ratings_description !== '' &&
{this.currentTrek.ratings_description}
}
diff --git a/src/store/grw-trek-provider.tsx b/src/store/grw-trek-provider.tsx index 6914a44..9d30e09 100644 --- a/src/store/grw-trek-provider.tsx +++ b/src/store/grw-trek-provider.tsx @@ -52,6 +52,11 @@ export class GrwTrekProvider { ? fetch(`${state.api}trek_accessibility/?language=${state.language}${this.portals ? '&portals='.concat(this.portals) : ''}&fields=id,name,pictogram`, this.init) : new Response('null'), ); + requests.push( + !state.ratings + ? fetch(`${state.api}trek_rating/?language=${state.language}${this.portals ? '&portals='.concat(this.portals) : ''}&fields=id,name`, this.init) + : new Response('null'), + ); Promise.all([ ...requests, fetch( @@ -85,7 +90,7 @@ export class GrwTrekProvider { fetch(`${state.api}touristicevent/?language=${state.language}&near_trek=${this.trekId}&published=true&fields=id,name,attachments,type,geometry&page_size=999`, this.init), fetch(`${state.api}touristicevent_type/?language=${state.language}&published=true&fields=id,type,pictogram&page_size=999`, this.init), fetch( - `${state.api}trek/${this.trekId}/?language=${state.language}&published=true&fields=id,name,attachments,description,description_teaser,difficulty,duration,ascent,length_2d,practice,themes,route,geometry,gpx,kml,pdf,parking_location,departure,departure_city,arrival,cities,ambiance,access,public_transport,advice,advised_parking,gear,labels,source,points_reference,disabled_infrastructure,accessibility_level,accessibility_slope,accessibility_width,accessibility_signage,accessibility_covering,accessibility_exposure,accessibility_advice,accessibilities,information_desks,children`, + `${state.api}trek/${this.trekId}/?language=${state.language}&published=true&fields=id,name,attachments,description,description_teaser,difficulty,duration,ascent,length_2d,practice,themes,route,geometry,gpx,kml,pdf,parking_location,departure,departure_city,arrival,cities,ambiance,access,public_transport,advice,advised_parking,gear,labels,source,points_reference,disabled_infrastructure,accessibility_level,accessibility_slope,accessibility_width,accessibility_signage,accessibility_covering,accessibility_exposure,accessibility_advice,accessibilities,ratings,ratings_description,information_desks,children`, this.init, ), ]) @@ -98,6 +103,7 @@ export class GrwTrekProvider { themes, cities, accessibilities, + ratings, sensitiveAreas, labels, sources, @@ -157,6 +163,10 @@ export class GrwTrekProvider { state.accessibilities = accessibilities.results; } + if (ratings) { + state.ratings = ratings.results; + } + if (sensitiveAreas) { state.currentSensitiveAreas = sensitiveAreas.results; } diff --git a/src/store/store.ts b/src/store/store.ts index 345c627..a577557 100644 --- a/src/store/store.ts +++ b/src/store/store.ts @@ -26,6 +26,7 @@ import { TouristicEvents, TouristicEventTypes, TouristicEvent, + Ratings, } from 'types/types'; const { state, onChange, reset } = createStore<{ @@ -48,6 +49,7 @@ const { state, onChange, reset } = createStore<{ labels: Labels; districts: Districts; sources: Sources; + ratings: Ratings; accessibilities: Accessibilities; accessibilitiesLevel: accessibilitiesLevel; poiTypes: PoiTypes; @@ -100,6 +102,7 @@ const { state, onChange, reset } = createStore<{ labels: null, districts: null, sources: null, + ratings: null, accessibilities: null, accessibilitiesLevel: null, poiTypes: null, diff --git a/src/types/types.ts b/src/types/types.ts index 6a399df..cf7d936 100644 --- a/src/types/types.ts +++ b/src/types/types.ts @@ -46,6 +46,8 @@ export type Trek = { cities?: string[]; information_desks?: number[]; children?: number[]; + ratings?: number[]; + ratings_description?: string; }; export type Attachments = Attachment[]; @@ -313,3 +315,10 @@ export type Options = { }; export type mode = 'treks' | 'touristicContents' | 'touristicEvents'; + +export type Ratings = Rating[]; + +export type Rating = { + id: number; + name: string; +};