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

import '../../Data/Repository/Customers/getCustomerbytenantidrepository.dart';
import '../../Model/Response/Customers/GetCustomerById/GetCustomerByTenantId.dart';

class CustomerController extends GetxController{

  RxBool progress = true.obs;


  List <GetCustomerByTenantIdDetails> getCustomerBytenantId =[];

  GetCustomersByTenantIdRepository getCustomersByNumberTenantIdRepository = GetCustomersByTenantIdRepository();

  TextEditingController searchController = TextEditingController();

  getCustomerByTenantId()async {
    GetCustomerByTenantId? result = await getCustomersByNumberTenantIdRepository.getCustomerByTenantId();
    getCustomerByTenantIdResult(result!);
  }

  RxBool hasLoadedCustomerOnce = false.obs;

  getCustomerByTenantIdResult(GetCustomerByTenantId data) {
    if (!hasLoadedCustomerOnce.value) {
      progress.value = true;
      update();
    }

    getCustomerBytenantId = data.details ?? [];
    progress.value = false;
    hasLoadedCustomerOnce.value = true;
    update();
  }


  @override
  void onInit() {
    // TODO: implement onInit
    super.onInit();
  }
}