import 'package:cheminova/controller/product_stock_service.dart';
import 'package:cheminova/controller/update_stock_service.dart';
import 'package:cheminova/models/product_stock_model.dart';
import 'package:get/get.dart';
import 'package:shared_preferences/shared_preferences.dart';

class UpdateStockController extends GetxController{


  Future<void> updateProductStock(List<ProductStockModel>  reason) async {
    try {
      SharedPreferences prefs = await SharedPreferences.getInstance();
      String? token = prefs.getString('token'); // Get the token

      if (token == null || token.isEmpty) {
        throw Exception("Token is missing. Please login again.");
      }

     // Show loading indicator

      // Call the service function and pass the token, orderId, and reason
      await UpdateStockService().UpdateStockProduct(token, reason);

      // Optionally refresh the data or show success message
      print("UpdateStockService process complete.");
    } catch (e) {
      print("Error: $e");
    } finally {

    }
  }
}