import 'dart:convert';

import 'package:get/get.dart';
import 'package:Intaleq/constant/box_name.dart';
import 'package:Intaleq/constant/links.dart';
import 'package:Intaleq/controller/functions/crud.dart';
import 'package:Intaleq/main.dart';

class OrderHistoryController extends GetxController {
  List<dynamic> orderHistoryListPassenger = [];
  bool isloading = true;

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

  Future getOrderHistoryByPassenger() async {
    var res = await CRUD().get(link: AppLink.getRides, payload: {
      'passenger_id': box.read(BoxName.passengerID).toString(),
    });
    if (res.toString() == 'failure') {
      // Get.snackbar('failure', 'message');
      isloading = false;
      update();
    } else {
      var jsonDecoded = jsonDecode(res);

      orderHistoryListPassenger = jsonDecoded['data'];
      isloading = false;
      update();
    }
  }
}
