modif console.log & modif maj
This commit is contained in:
parent
1e8610182c
commit
99e109b056
3 changed files with 14 additions and 5 deletions
|
|
@ -106,5 +106,8 @@
|
|||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"cli": {
|
||||
"analytics": false
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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) => {
|
||||
|
|
|
|||
|
|
@ -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<any>(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;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue