Skip to content

Commit

Permalink
ajout des labels de categories en retour de recherche, quand on arriv…
Browse files Browse the repository at this point in the history
…e à mapper
  • Loading branch information
WoWo79 committed Oct 29, 2024
1 parent 6458bbe commit a5f97a8
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,8 @@ export class CategorieRechercheManager {
any_transport: 'Tout mode de déplacement',
};

public static getLabel(cat: CategorieRecherche): string {
return CategorieRechercheManager.labels[cat];
public static getLabel(cat: string): string {
return CategorieRechercheManager.labels[cat] || cat;
}

public static isDefault(cat: CategorieRecherche): boolean {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ export class ResultatRecherche {
description_more?: string;
phone?: string;
categories?: string[];
categories_labels?: string[];
openhours_more_infos?: string;
open_hours?: OpenHour[];

Expand All @@ -82,7 +83,6 @@ export class ResultatRecherche {
this.temps_prepa_min = res.temps_prepa_min;
this.distance_metres = res.distance_metres;
this.impact_carbone_kg = res.impact_carbone_kg;

this.est_favoris = false;
this.nombre_favoris = 0;
this.emoji = res.emoji;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@ import { ApiProperty } from '@nestjs/swagger';
import { ResultatRecherche } from '../../../../domain/bibliotheque_services/recherche/resultatRecherche';
import { Day } from '../../../../domain/bibliotheque_services/types/days';
import { FruitLegume } from '../../../service/fruits/fruitEtLegumesServiceManager';
import {
CategorieRecherche,
CategorieRechercheManager,
} from '../../../../domain/bibliotheque_services/recherche/categorieRecherche';

export class OpenHourAPI {
@ApiProperty({ enum: Day }) jour: Day;
Expand Down Expand Up @@ -42,6 +46,7 @@ export class ResultatRechercheAPI {
@ApiProperty() description_more: string;
@ApiProperty() phone: string;
@ApiProperty() categories: string[];
@ApiProperty() categories_labels: string[];
@ApiProperty() openhours_more_infos: string;
@ApiProperty({ type: [OpenHourAPI] }) open_hours: OpenHourAPI[];
@ApiProperty() longitude: number;
Expand Down Expand Up @@ -71,13 +76,16 @@ export class ResultatRechercheAPI {
description: res.description,
description_more: res.description_more,
phone: res.phone,
categories: res.categories,
categories: res.categories ? res.categories : [],
openhours_more_infos: res.openhours_more_infos,
open_hours: res.open_hours,
latitude: res.latitude,
longitude: res.longitude,
ingredients: res.ingredients,
etapes_recette: res.etapes_recette,
categories_labels: res.categories
? res.categories.map((c) => CategorieRechercheManager.getLabel(c))
: [],
};
}
}
Expand Down
2 changes: 2 additions & 0 deletions test/integration/api/recherchServices.controller.int-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,7 @@ describe('RechercheServices (API test)', () => {
impact_carbone_kg: 1,
image_url: 'https://',
categories: ['a'],
categories_labels: ['a'],
commitment: 'hahaha',
description: 'description',
description_more: 'description more',
Expand Down Expand Up @@ -305,6 +306,7 @@ describe('RechercheServices (API test)', () => {
description_more: 'plus de description',
phone: '061294875272',
categories: [],
categories_labels: [],
openhours_more_infos: 'sauf le mardi',
open_hours: [{ jour: 'lundi', heures: '10h-18h' }],
latitude: 40,
Expand Down

0 comments on commit a5f97a8

Please sign in to comment.