Skip to content

Commit

Permalink
add trek ratings
Browse files Browse the repository at this point in the history
  • Loading branch information
bastyen committed Jan 5, 2024
1 parent c41275b commit 22de2a3
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 1 deletion.
4 changes: 4 additions & 0 deletions src/components/grw-trek-detail/grw-trek-detail.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -556,6 +556,10 @@ export class GrwTrekDetail {
{this.practice?.name}
</div>
</div>
{this.currentTrek.ratings.map(trekRating => (
<div class="row">{state.ratings.find(rating => rating.id === trekRating).name}</div>
))}
{this.currentTrek.ratings_description && this.currentTrek.ratings_description !== '' && <div class="row">{this.currentTrek.ratings_description}</div>}
</div>
</div>
<div class="divider"></div>
Expand Down
12 changes: 11 additions & 1 deletion src/store/grw-trek-provider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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,
),
])
Expand All @@ -98,6 +103,7 @@ export class GrwTrekProvider {
themes,
cities,
accessibilities,
ratings,
sensitiveAreas,
labels,
sources,
Expand Down Expand Up @@ -157,6 +163,10 @@ export class GrwTrekProvider {
state.accessibilities = accessibilities.results;
}

if (ratings) {
state.ratings = ratings.results;
}

if (sensitiveAreas) {
state.currentSensitiveAreas = sensitiveAreas.results;
}
Expand Down
3 changes: 3 additions & 0 deletions src/store/store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import {
TouristicEvents,
TouristicEventTypes,
TouristicEvent,
Ratings,
} from 'types/types';

const { state, onChange, reset } = createStore<{
Expand All @@ -48,6 +49,7 @@ const { state, onChange, reset } = createStore<{
labels: Labels;
districts: Districts;
sources: Sources;
ratings: Ratings;
accessibilities: Accessibilities;
accessibilitiesLevel: accessibilitiesLevel;
poiTypes: PoiTypes;
Expand Down Expand Up @@ -100,6 +102,7 @@ const { state, onChange, reset } = createStore<{
labels: null,
districts: null,
sources: null,
ratings: null,
accessibilities: null,
accessibilitiesLevel: null,
poiTypes: null,
Expand Down
9 changes: 9 additions & 0 deletions src/types/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ export type Trek = {
cities?: string[];
information_desks?: number[];
children?: number[];
ratings?: number[];
ratings_description?: string;
};

export type Attachments = Attachment[];
Expand Down Expand Up @@ -313,3 +315,10 @@ export type Options = {
};

export type mode = 'treks' | 'touristicContents' | 'touristicEvents';

export type Ratings = Rating[];

export type Rating = {
id: number;
name: string;
};

0 comments on commit 22de2a3

Please sign in to comment.