import 'package:cheminova/controller/get_delivered_service.dart';
import 'package:cheminova/models/get_delivered_model.dart';
import 'package:get/get.dart';
import 'package:shared_preferences/shared_preferences.dart';

class GetDeliveredController extends GetxController{
  var isLoading = true.obs; // Tracks the loading state
  var productProcessingRDList = <GetDeliveredModel>[].obs; // List of products
  // Fetch the products from the API
  Future<void> getRDDeliveredInvoiceProduct() async {
    try {
      SharedPreferences prefs = await SharedPreferences.getInstance();
      String? token = prefs.getString('token');
      isLoading(true); // Start loading
      final  response = await GetDeliveredService().getRDDeliveredProduct(token!); // Fetch products from API
      if (response != null) {
        productProcessingRDList.assignAll(response); // Assign products to the observable list
      }
    } finally {
      isLoading(false); // End loading
    }
  }
}