Skip to content

Commit

Permalink
Use near_trek instead of trek filter for POIs and sensitiveAreas
Browse files Browse the repository at this point in the history
  • Loading branch information
dtrucs committed Dec 28, 2023
1 parent 38d72e0 commit 94363be
Show file tree
Hide file tree
Showing 6 changed files with 4 additions and 8 deletions.
2 changes: 1 addition & 1 deletion frontend/src/modules/poi/connector.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { adaptPoi } from './adapter';
import { fetchPois } from './api';
import { Poi } from './interface';

export const getPois = async (id: number, language: string, key = 'trek'): Promise<Poi[]> => {
export const getPois = async (id: number, language: string, key = 'near_trek'): Promise<Poi[]> => {
const pageSize = getGlobalConfig().maxPoiPerPage;
const [rawPois, poiTypes] = await Promise.all([
fetchPois({ language, [key]: id, page_size: pageSize }),
Expand Down
1 change: 0 additions & 1 deletion frontend/src/modules/poi/interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ export interface RawPoi {
name: string;
description: string;
type: number;
trek: number;
attachments: RawAttachment[];
geometry: RawPointGeometry3D;
}
Expand Down
4 changes: 1 addition & 3 deletions frontend/src/modules/poi/mocks/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ export const mockPois = (): PoisResponse => ({
previous: null,
results: [
{
trek: 3,
description:
"<span>Pour esp&eacute;rer apercevoir cet oiseau, partir la nuit au printemps, parcourir un grand d&eacute;nivel&eacute; afin d'arriver sur son terrain de pr&eacute;dilection &agrave; plus de 2000 m voire 3000 m d'altitude avant le lever du jour et l&agrave;, entendre le chant guttural&nbsp;caract&eacute;ristique qui trahit sa pr&eacute;sence. Mais pour le voir, il faudra bien ouvrir les yeux ou se munir d'une paire de jumelles. Et alors l&agrave;, quel bonheur&nbsp;! Le lagop&egrave;de alpin est l'esp&egrave;ce arctique par excellence, menac&eacute;e entre autre par le r&eacute;chauffement climatique. Il fait partie des esp&egrave;ces &agrave; prot&eacute;ger dans le c&oelig;ur du Parc national des Ecrins.</span>",
name: 'Lagopède alpin',
Expand Down Expand Up @@ -48,7 +47,6 @@ export const mockPois = (): PoisResponse => ({
},
},
{
trek: 4,
description: 'Test refuge',
name: 'Refuge de la Lavey',
id: 3,
Expand All @@ -67,7 +65,7 @@ export const mockPoiRoute = (times: number, trekId: number): void =>
route: '/poi/',
mockData: mockPois(),
additionalQueries: {
trek: trekId,
near_trek: trekId,
fields: 'id,name,description,attachments,type,geometry',
page_size: getGlobalConfig().maxPoiPerPage,
},
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/modules/sensitiveArea/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export const fetchSensitiveAreas = (
id: number,
query: APIQuery,
): Promise<APIResponseForList<RawSensitiveArea>> => {
const typeKey = type.startsWith('outdoor') ? `near_${type.toLowerCase()}` : 'trek';
const typeKey = `near_${type.toLowerCase()}`;
const params = { ...query, period: 'ignore', [typeKey]: id };
return GeotrekAPI.get('/sensitivearea/', { params }).then(r => r.data);
};
2 changes: 1 addition & 1 deletion frontend/src/modules/sensitiveArea/mocks/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ export const mockSensitiveAreaRoute = (times: number): void =>
mockData: mockSensitiveAreasResponse(),
additionalQueries: {
period: 'ignore',
trek: 2,
near_trek: 2,
},
times,
});
1 change: 0 additions & 1 deletion frontend/src/services/api/interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ export interface APIQuery {
omit?: string;
page?: number;
page_size?: number;
trek?: number;
near_trek?: number;
period?: string;
q?: string;
Expand Down

0 comments on commit 94363be

Please sign in to comment.