import 'package:get/get.dart';

import '../../service/ai_service/api_service.dart';

class AiSearchController extends GetxController {
  final AiSearchService service = AiSearchService();

  RxBool loading = false.obs;
  RxMap<String, dynamic> result = <String, dynamic>{}.obs;

  Future<void> search(String query) async {
    try {
      loading.value = true;

      final data = await service.search(query);

      result.value = data;
    } catch (e) {
      Get.snackbar(
        "Error",
        e.toString(),
      );
    } finally {
      loading.value = false;
    }
  }
}