mirrored_repositories/flutter_schedule_app/lib/modules/home
import 'package:get/get.dart';
import '../../../data/models/event_model.dart';
import '../services/home_services.dart';

class HomeController extends GetxController {
  final HomeRepository _repo = HomeRepository();
  RxList<EventModel> currentEvents = RxList([]);
  RxList<EventModel> expiredEvents = RxList([]);
  RxList<EventModel> nextEvents = RxList([]);

  RxBool isLoading = RxBool(false);

  @override
  void onInit() {
    getFilteredEvents();
    super.onInit();
  }

  Future<void> getFilteredEvents() async {
    isLoading.value = true;
    final res = await _repo.getFilteredEvents();
    if (res != null) {
      currentEvents.value = res.current;
      nextEvents.value = res.next;
      expiredEvents.value = res.expired;
    }
    isLoading.value = false;
  }
}
