import 'dart:convert';

import 'package:get/get.dart';

import '../../constant/colors.dart';
import '../../constant/links.dart';
import '../print.dart';
import 'functions/crud.dart';

class Driverthebest extends GetxController {
  bool isLoading = false;
  List driver = [];
  getBestDriver() async {
    var res = await CRUD().get(link: AppLink.getBestDriver, payload: {});
    if (res != 'failure') {
      driver = jsonDecode(res)['message'];
      // Log.print('driver: ${driver}');
      update();
    } else {
      Get.snackbar('error', '', backgroundColor: AppColor.redColor);
    }
  }

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

class DriverTheBestGizaController extends GetxController {
  bool isLoading = false;
  List driver = [];
  getBestDriver() async {
    var res = await CRUD().get(link: AppLink.getBestDriverGiza, payload: {});
    if (res != 'failure') {
      driver = jsonDecode(res)['message'];

      update();
    } else {
      Get.snackbar('error', '', backgroundColor: AppColor.redColor);
    }
  }

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

class DriverTheBestAlexandriaController extends GetxController {
  bool isLoading = false;
  List driver = [];
  getBestDriver() async {
    var res =
        await CRUD().get(link: AppLink.getBestDriverAlexandria, payload: {});
    if (res != 'failure') {
      driver = jsonDecode(res)['message'];
      update();
    } else {
      Get.snackbar('error', '', backgroundColor: AppColor.redColor);
    }
  }

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