add new featurs like realtime 2026-5-10-25
This commit is contained in:
59
lib/controller/admin/financial_v2_controller.dart
Normal file
59
lib/controller/admin/financial_v2_controller.dart
Normal file
@@ -0,0 +1,59 @@
|
||||
import 'dart:convert';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:sefer_admin1/constant/links.dart';
|
||||
import 'package:sefer_admin1/controller/functions/crud.dart';
|
||||
import '../../print.dart';
|
||||
|
||||
class FinancialV2Controller extends GetxController {
|
||||
bool isLoading = true;
|
||||
|
||||
Map<String, dynamic> stats = {};
|
||||
List<dynamic> settlements = [];
|
||||
|
||||
@override
|
||||
void onInit() {
|
||||
super.onInit();
|
||||
fetchAllFinancials();
|
||||
}
|
||||
|
||||
Future<void> fetchAllFinancials() async {
|
||||
isLoading = true;
|
||||
update();
|
||||
|
||||
await Future.wait([
|
||||
fetchStats(),
|
||||
fetchSettlements(),
|
||||
]);
|
||||
|
||||
isLoading = false;
|
||||
update();
|
||||
}
|
||||
|
||||
Future<void> fetchStats() async {
|
||||
try {
|
||||
var res = await CRUD().get(link: AppLink.financialStatsV2, payload: {});
|
||||
if (res != 'failure' && res != null) {
|
||||
var d = res is String ? jsonDecode(res) : res;
|
||||
if (d['status'] == 'success') {
|
||||
stats = d['data'];
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
Log.print('Error fetching financial stats: $e');
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> fetchSettlements() async {
|
||||
try {
|
||||
var res = await CRUD().get(link: AppLink.settlementsV2, payload: {});
|
||||
if (res != 'failure' && res != null) {
|
||||
var d = res is String ? jsonDecode(res) : res;
|
||||
if (d['status'] == 'success') {
|
||||
settlements = d['data'];
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
Log.print('Error fetching settlements: $e');
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user