import 'package:flutter/foundation.dart';
import '/models/models.dart';
import '/services/repo_service.dart';

class PropinaViewModel extends ChangeNotifier {
  final RepoService _repoService = RepoService();

  Future<void> guardarPropina(Propinas propina) async {
    try {
      await _repoService.guardar(propina);
    } catch (e) {
      print('Error al guardar la propina: $e');
    }
  }

  Future<List<Propinas>> obtenerPropinasPorPedido(int idPedido) async {
    try {
      return await _repoService.obtenerTodos<Propinas>(
        where: 'idPedido = ?',
        whereArgs: [idPedido],
      );
    } catch (e) {
      print('Error al obtener propinas: $e');
      return [];
    }
  }
}
