import 'dart:convert';

import 'package:Intaleq/constant/style.dart';
import 'package:Intaleq/views/widgets/elevated_btn.dart';
import 'package:get/get.dart';

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

class RideAvailableController extends GetxController {
  bool isLoading = false;
  Map rideAvailableMap = {};
  getRideAvailable() async {
    isLoading = true;
    var res = await CRUD().get(link: AppLink.getRideWaiting, payload: {});
    if (res != 'failure') {
      rideAvailableMap = jsonDecode(res);
      isLoading = false;
      update();
    } else {
      Get.defaultDialog(
          title: 'No Rides now!'.tr,
          middleText: '',
          titleStyle: AppStyle.title,
          confirm: MyElevatedButton(
              title: 'Ok'.tr,
              onPressed: () {
                Get.back();
                Get.back();
              }));
    }
  }

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