This commit is contained in:
Hamza-Ayed
2024-07-08 00:27:01 +03:00
parent 0a71a194b9
commit a40c1e05e3
13 changed files with 367 additions and 75 deletions

View File

@@ -10,6 +10,7 @@ class DashboardController extends GetxController {
bool isLoading = false;
List dashbord = [];
int creditSMS = 0;
Future getDashBoard() async {
isLoading = true;
update();
@@ -31,8 +32,9 @@ class DashboardController extends GetxController {
}
@override
void onInit() {
void onInit() async {
getDashBoard();
super.onInit();
}
}

View File

@@ -0,0 +1,79 @@
import 'dart:convert';
import 'package:fl_chart/fl_chart.dart';
import 'package:get/get.dart';
import '../../constant/links.dart';
import '../../models/model/passengers_model.dart';
import '../functions/crud.dart';
class StaticController extends GetxController {
Map<String, dynamic> jsonData1 = {};
Map<String, dynamic> jsonData2 = {};
var chartDataPassengers;
var chartDataDrivers;
bool isLoading = false;
String totalMonthlyPassengers = '';
String totalMonthlyDrivers = '';
late List<MonthlyPassengerInstall> passengersData;
late List<MonthlyDriverInstall> driversData;
Future<void> fetch() async {
isLoading = true;
update(); // Notify the observers about the loading state change
var res = await CRUD().get(
link: AppLink.getPassengersStatic,
payload: {},
);
jsonData1 = jsonDecode(res);
var jsonResponse = jsonDecode(res) as Map<String, dynamic>;
isLoading = false;
final List<dynamic> jsonData = jsonResponse['message'];
totalMonthlyPassengers = jsonData[0]['totalMonthly'].toString();
passengersData = jsonData.map<MonthlyPassengerInstall>((item) {
return MonthlyPassengerInstall.fromJson(item);
}).toList();
final List<FlSpot> spots = passengersData
.map((data) => FlSpot(
data.day.toDouble(),
data.totalPassengers.toDouble(),
))
.toList();
chartDataPassengers = spots;
update(); // Notify the observers about the data and loading state change
}
Future<void> fetchDrivers() async {
isLoading = true;
update(); // Notify the observers about the loading state change
var res = await CRUD().get(
link: AppLink.getdriverstotalMonthly,
payload: {},
);
jsonData2 = jsonDecode(res);
var jsonResponse = jsonDecode(res) as Map<String, dynamic>;
isLoading = false;
final List<dynamic> jsonData = jsonResponse['message'];
totalMonthlyDrivers = jsonData[0]['totalMonthly'].toString();
driversData = jsonData.map<MonthlyDriverInstall>((item) {
return MonthlyDriverInstall.fromJson(item);
}).toList();
final List<FlSpot> spots = driversData
.map((data) => FlSpot(
data.day.toDouble(),
data.totalDrivers.toDouble(),
))
.toList();
chartDataDrivers = spots;
update(); // Notify the observers about the data and loading state change
}
Future getAll() async {
await fetch();
await fetchDrivers();
}
}

View File

@@ -4,6 +4,7 @@ import 'package:get/get.dart';
import 'package:http/http.dart' as http;
import '../../../constant/links.dart';
import '../../constant/api_key.dart';
import '../../constant/box_name.dart';
import '../../constant/colors.dart';
import '../../main.dart';
@@ -21,15 +22,13 @@ class PaymobPayout extends GetxController {
};
var body = {
'grant_type': 'password',
'username': 'sefer_api_checker',
'password': '#c3pSwbUxOKpQnr5hHZAgpkSW',
'client_id': 'kmNWU5gKsL8LKVhsJFbOGTEb3YQ5sQhvBoB8pqoW',
'client_secret':
'htV6nFANLDd658ueTEuMrIqwjcXsocMXmBLAYof7FuutBcSxdTdoNqFl3EAvO6zrOgGPLdiMrofNp2V9ASVRpjoSlFjDNRzY7hfPunAJEgf2N5ZUuknN4QniaqIZvaNt'
'username': AK.payMobOutUserName,
'password': AK.payMobOutPassword,
'client_id': AK.payMobOutClient_id,
'client_secret': AK.payMobOutClientSecrret
};
var res = await http.post(
Uri.parse(
'https://stagingpayouts.paymobsolutions.com/api/secure/o/token/'),
Uri.parse('https://payouts.paymobsolutions.com/api/secure/o/token/'),
headers: headers,
body: body,
);
@@ -53,8 +52,7 @@ class PaymobPayout extends GetxController {
"msisdn": msisdn, // "01023456789"
});
var res = await http.post(
Uri.parse(
'https://stagingpayouts.paymobsolutions.com/api/secure/disburse/'),
Uri.parse('https://payouts.paymobsolutions.com/api/secure/disburse/'),
headers: headers,
body: body,
);
@@ -64,7 +62,7 @@ class PaymobPayout extends GetxController {
'rideId': DateTime.now().toIso8601String(),
'amount': ((-1) * (double.parse(dec['amount'])) + 5).toStringAsFixed(0),
'payment_method': 'payout',
'passengerID': 'myself',
'passengerID': 'admin',
'driverID': box.read(BoxName.driverID).toString(),
});
Get.snackbar('Transaction successful'.tr,
@@ -94,8 +92,7 @@ class PaymobPayout extends GetxController {
};
var res = await http
.post(
Uri.parse(
'https://stagingpayouts.paymobsolutions.com/api/secure/disburse/'),
Uri.parse('https://payouts.paymobsolutions.com/api/secure/disburse/'),
headers: headers,
body: body,
)