Update: 2026-05-08 00:52:01
This commit is contained in:
@@ -9,7 +9,6 @@ class CompaniesManagementController extends GetxController {
|
||||
|
||||
var isLoading = true.obs;
|
||||
var companies = <Map<String, dynamic>>[].obs;
|
||||
var employees = <Map<String, dynamic>>[].obs;
|
||||
|
||||
@override
|
||||
void onInit() {
|
||||
@@ -32,9 +31,23 @@ class CompaniesManagementController extends GetxController {
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> updateCompany(String id, Map<String, dynamic> data) async {
|
||||
try {
|
||||
data['id'] = id;
|
||||
final response = await _dio.post('companies/update', data: data);
|
||||
if (response.data['success'] == true) {
|
||||
await fetchCompanies();
|
||||
AppSnackbar.showSuccess('نجاح', 'تم تحديث بيانات الشركة');
|
||||
}
|
||||
} catch (e) {
|
||||
AppLogger.error('Failed to update company', e);
|
||||
AppSnackbar.showError('خطأ', 'تعذر تحديث الشركة');
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> deleteCompany(String id) async {
|
||||
try {
|
||||
final response = await _dio.delete('companies/$id');
|
||||
final response = await _dio.post('companies/delete', data: {'id': id});
|
||||
if (response.data['success'] == true) {
|
||||
companies.removeWhere((c) => c['id'] == id);
|
||||
AppSnackbar.showSuccess('نجاح', 'تم حذف الشركة بنجاح');
|
||||
|
||||
Reference in New Issue
Block a user