feat(app): clean architecture with typed repositories, DTO models and calendar event logos
This commit is contained in:
@@ -2,11 +2,12 @@ import 'package:finlytic_app/core/network/api_client.dart';
|
||||
import 'package:finlytic_app/features/admin/models/admin_user_model.dart';
|
||||
import 'package:finlytic_app/features/admin/models/admin_create_user_request_dto.dart';
|
||||
import 'package:finlytic_app/features/admin/models/admin_update_user_request_dto.dart';
|
||||
import 'package:finlytic_app/features/admin/models/service_setting_dto.dart';
|
||||
|
||||
class AdminRepository {
|
||||
final ApiClient apiClient;
|
||||
|
||||
AdminRepository({required this.apiClient});
|
||||
const AdminRepository({required this.apiClient});
|
||||
|
||||
Future<List<AdminUserModel>> fetchUsers() async {
|
||||
try {
|
||||
@@ -17,8 +18,7 @@ class AdminRepository {
|
||||
}
|
||||
return [];
|
||||
} catch (e) {
|
||||
print('Error fetching admin users: $e');
|
||||
throw Exception('Nutzer konnten nicht geladen werden');
|
||||
throw Exception('Nutzer konnten nicht geladen werden: $e');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -35,4 +35,29 @@ class AdminRepository {
|
||||
throw Exception('Aktualisieren fehlgeschlagen');
|
||||
}
|
||||
}
|
||||
|
||||
Future<Map<String, List<ServiceSettingDto>>> fetchSettings() async {
|
||||
final res = await apiClient.get('/api/v1/admin/settings');
|
||||
if (res.statusCode == 200 && res.data != null && res.data is Map<String, dynamic>) {
|
||||
final map = res.data as Map<String, dynamic>;
|
||||
final result = <String, List<ServiceSettingDto>>{};
|
||||
map.forEach((k, v) {
|
||||
if (v is List) {
|
||||
result[k] = v
|
||||
.whereType<Map<String, dynamic>>()
|
||||
.map((item) => ServiceSettingDto.fromJson(item))
|
||||
.toList();
|
||||
}
|
||||
});
|
||||
return result;
|
||||
}
|
||||
return {};
|
||||
}
|
||||
|
||||
Future<void> updateServiceSettings(String serviceName, Map<String, String> settings) async {
|
||||
final res = await apiClient.put('/api/v1/admin/settings/$serviceName', data: settings);
|
||||
if (res.statusCode != 200 && res.statusCode != 204) {
|
||||
throw Exception('Einstellungen konnten nicht gespeichert werden');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user