import 'package:get/get.dart';
import 'package:gifunavi/model/gps_data.dart';
import 'package:gifunavi/utils/database_gps.dart';
import 'package:gifunavi/pages/index/index_controller.dart';

class GpsController extends GetxController {
  final gpsData = <GpsData>[].obs;

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

  void loadGpsData() async {
    final teamName = Get.find<IndexController>().currentUser[0]["user"]['team_name'];
    final eventCode = Get.find<IndexController>().currentUser[0]["user"]["event_code"];
    GpsDatabaseHelper db = GpsDatabaseHelper.instance;
    var data = await db.getGPSData(teamName, eventCode);
    gpsData.value = data;
  }
}