diff --git a/angular.json b/angular.json index 7d2c67e..5d27e79 100644 --- a/angular.json +++ b/angular.json @@ -106,5 +106,8 @@ } } } + }, + "cli": { + "analytics": false } } diff --git a/src/app/components/cars/car-form/car-form.component.ts b/src/app/components/cars/car-form/car-form.component.ts index c2af2ec..1f2a0f9 100644 --- a/src/app/components/cars/car-form/car-form.component.ts +++ b/src/app/components/cars/car-form/car-form.component.ts @@ -29,10 +29,7 @@ export class CarFormComponent { } } - saveCar() { - // Vérifie que l'objet car a les bonnes propriétés - console.log('Car avant image:', this.car); - + saveCar() { // Récupération de l'image via l'API const { marque, modele, couleur } = this.car; this.carService.getCarImage(marque, modele, couleur).subscribe((imageUrl) => { diff --git a/src/app/services/car.service.ts b/src/app/services/car.service.ts index 4cd0ea9..e35aee9 100644 --- a/src/app/services/car.service.ts +++ b/src/app/services/car.service.ts @@ -18,6 +18,10 @@ export class CarService { constructor(private http: HttpClient) { } + private capitalizeFirstLetter(text: string): string { + return text.charAt(0).toUpperCase() + text.slice(1).toLowerCase(); + } + getCars(): Car[] { return this.cars; } @@ -34,7 +38,6 @@ export class CarService { return this.http.get(apiUrl).pipe( map((res) => { - console.log('Réponse de l\'API Google Custom Search:', res); // Ajout d'un log pour vérifier la réponse de l'API return res.items?.[0]?.link || 'https://via.placeholder.com/100x60?text=Voiture'; }), catchError((error: HttpErrorResponse) => { @@ -47,12 +50,18 @@ export class CarService { addCar(car: Car) { car.id = Date.now(); + car.marque = this.capitalizeFirstLetter(car.marque); + car.modele = this.capitalizeFirstLetter(car.modele); + car.couleur = this.capitalizeFirstLetter(car.couleur); this.cars.push(car); } updateCar(updatedCar: Car) { const index = this.cars.findIndex(c => c.id === updatedCar.id); if (index !== -1) { + updatedCar.marque = this.capitalizeFirstLetter(updatedCar.marque); + updatedCar.modele = this.capitalizeFirstLetter(updatedCar.modele); + updatedCar.couleur = this.capitalizeFirstLetter(updatedCar.couleur); this.cars[index] = updatedCar; } }