// lib/features/eta/eta_service.dart
// Llama a GET /eta?address_id=X via dio.
// La respuesta NUNCA contiene coordenadas (validado en backend + RLS).
 
import 'package:dio/dio.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import '../../core/dio_client.dart';
import 'eta_model.dart';
 
class EtaService {
  final Dio _dio;
  EtaService(this._dio);
 
  Future<EtaResponse> fetchEta(String addressId) async {
    final response = await _dio.get<Map<String, dynamic>>(
      '/eta',
      queryParameters: {'address_id': addressId},
    );
    return EtaResponse.fromJson(response.data!);
  }
}
 
final etaServiceProvider = Provider<EtaService>(
  (ref) => EtaService(ref.read(dioProvider)),
);