import 'package:get/get.dart';

import '../views/model/FAQS.dart';

class FaqsFirstController extends GetxController {
  late SendingMoney sendMoney;
  final searchText = ''.obs;
  RxList<Question> filteredListQuestions = <Question>[].obs;
  @override
  onInit() {
    super.onInit();
    sendMoney = Get.arguments;
    filteredListQuestions.value = sendMoney.questions;
    debounce(searchText, (_) => filterListQuestions(), time: const Duration(milliseconds: 300));
  }

  void filterListQuestions() {
    if (searchText.value.isEmpty) {
      filteredListQuestions.value = sendMoney.questions;
    } else {
      filteredListQuestions.value = sendMoney.questions
          .where((question) =>
          question.title.toLowerCase().contains(searchText.value.toLowerCase()))
          .toList();
    }
  }
}
