import 'package:fluttertoast/fluttertoast.dart';
import 'package:get/get.dart';
import 'package:hello_doctor_admin_dashboard/app/models/transaction_model.dart';
import 'package:hello_doctor_admin_dashboard/app/models/transaction_table_source.dart';
import 'package:hello_doctor_admin_dashboard/app/services/transaction_service.dart';

class TransactionController extends GetxController
    with StateMixin<List<TransactionModel>> {
  List<TransactionModel>? listTransaction;
  late TransactionTableSource transactionTableSource;
  @override
  void onInit() {
    super.onInit();
  }

  void initializeTransactionTab() async {
    try {
      listTransaction = await TransactionService().getAllTransaction();
      transactionTableSource = TransactionTableSource(listTransaction!);
      change(listTransaction, status: RxStatus.success());
    } catch (e) {
      Fluttertoast.showToast(msg: e.toString());
    }
  }

  @override
  void onReady() {
    super.onReady();
  }

  @override
  void onClose() {
    super.onClose();
  }
}
