import 'package:cheminova/controller/get_place_order_service.dart';
import 'package:cheminova/controller/product_service.dart';
import 'package:cheminova/models/oder_place_model.dart';
import 'package:cheminova/models/product_model1.dart';
import 'package:get/get.dart';


class GetPlacedOrderController extends GetxController {
  final GetOrderPlacedServcie _getOrderPlacedServcie = GetOrderPlacedServcie();
  var products = <PlacedOrderModel>[].obs;

  int _currentPage = 1;
  bool isLoading = false;

  @override
  void onInit() {
    super.onInit();

  }

  Future<void> getOrder(String id) async {
    if (isLoading) return;
    isLoading = true;
    try {

      final fetchedProducts = await _getOrderPlacedServcie.getPlacedOrder();


      if (fetchedProducts != null) {

        products.addAll(fetchedProducts);
      }
    } catch (e) {
      print("Error fetching products: $e");
    } finally {
      isLoading = false;
      update();
    }
  }
}
