61 lines
1.5 KiB
Dart
61 lines
1.5 KiB
Dart
import 'dart:convert';
|
|
|
|
import 'package:sefer_driver/views/widgets/elevated_btn.dart';
|
|
import 'package:get/get.dart';
|
|
|
|
import '../../../constant/box_name.dart';
|
|
import '../../../constant/links.dart';
|
|
import '../../../main.dart';
|
|
import '../../../views/home/Captin/history/history_details_page.dart';
|
|
import '../../functions/crud.dart';
|
|
|
|
class HistoryCaptainController extends GetxController {
|
|
bool isloading = false;
|
|
Map historyData = {};
|
|
Map historyDetailsData = {};
|
|
late String orderID;
|
|
getOrderId(String orderId) {
|
|
orderID = orderId;
|
|
update();
|
|
}
|
|
|
|
getHistory() async {
|
|
isloading = true;
|
|
var res = await CRUD().get(
|
|
link: AppLink.getDriverOrder,
|
|
payload: {'driver_id': box.read(BoxName.driverID)});
|
|
if (res != 'failure') {
|
|
historyData = jsonDecode(res);
|
|
isloading = false;
|
|
update();
|
|
} else {
|
|
Get.defaultDialog(
|
|
title: 'No ride yet'.tr,
|
|
middleText: '',
|
|
barrierDismissible: false,
|
|
confirm: MyElevatedButton(
|
|
title: 'Back'.tr,
|
|
onPressed: () {
|
|
Get.back();
|
|
Get.back();
|
|
}));
|
|
}
|
|
}
|
|
|
|
getHistoryDetails(String orderId) async {
|
|
isloading = true;
|
|
var res = await CRUD()
|
|
.get(link: AppLink.getRideOrderID, payload: {'id': orderId});
|
|
historyDetailsData = jsonDecode(res);
|
|
isloading = false;
|
|
update();
|
|
Get.to(() => HistoryDetailsPage());
|
|
}
|
|
|
|
@override
|
|
void onInit() {
|
|
getHistory();
|
|
super.onInit();
|
|
}
|
|
}
|