import 'package:flutter/material.dart';
import 'package:get/get.dart';

import '../../app.dart';

class SubcategoryController extends GetxController {
  int PAGE_SIZE = 10;

  @override
  void onInit() {
    debugPrint('HorizontalScrollableProductsController: onInit()');
    super.onInit();
  }

  Future<List<ProductModel>> fetchProducts(int currPage) async {
    debugPrint('currPage: $currPage');
    try {
      final Map<String, dynamic> params = {
        'locale': await getLocale(),
        'currency': 'tmt',
        'page': currPage,
        'limit': PAGE_SIZE,
        // 'featured': 1,
      };

      return await ProductApi.get(params);
    } catch (e) {
      debugPrint('error fetchProducts: $e ');
      throw e;
    }
  }
}
