import 'dart:io';

import 'package:garage/car/service/image_service.dart';
import 'package:garage/utils/item_service.dart';

import '../model/car.dart';

class CarService extends ItemService<Car> {
  final imageService = ImageService();

  CarService({required super.collectionName, required super.fromJson});

  Future<String?> updatePhoto(File? photo, String carId) async {
    if (photo != null) {
      var photoUrl = await imageService.uploadImageToStorage(photo, carId);
      return photoUrl;
    }
    return null;
  }

  Future<void> deletePhoto(String carId) async {
    final photoUrl =
        "https://firebasestorage.googleapis.com/v0/b/garage-pata.appspot.com/o/car_images%2F${carId}_car.jpg?alt=media&token=41474050-b327-4f94-95be-30bc2e57f6ea";
    imageService.deleteImage(photoUrl);
  }
}
