Merge remote-tracking branch 'upstream/main' into feat/notifications-3054-payment-feed

# Conflicts:
#	test/features/notifications/models/notification_model_test.dart
This commit is contained in:
2026-11-24 11:27:13 +03:00
844 changed files with 30440 additions and 7009 deletions

View File

@@ -1,13 +1,17 @@
import 'package:dio/dio.dart';
import 'package:eatvio_app/core/error_reporting/api_response_error_reporter.dart';
import 'package:eatvio_app/features/notifications/models/notification_model.dart';
class NotificationsService {
final Dio dio;
NotificationsService(this.dio);
final ApiResponseErrorReporter? responseErrors;
static const _endpoint = '/api/profile/notifications';
NotificationsService(this.dio, {this.responseErrors});
Future<Map<String, dynamic>?> getNotifications({required int page}) async {
final response = await dio.get('$_endpoint?page=$page');
try {
final response = await dio.get('/api/profile/notifications?page=$page');
if (response.statusCode == 200) {
final data = response.data['data'] as List<dynamic>;
@@ -413,6 +417,12 @@ class NotificationsService {
isRead: readDate != null,
createdAt: createdAt,
),
NotificationType.personalDietIsDefinedToAuthor => PersonalDietIsDefinedToAuthorNotification.fromJson(
notificationJson['data'],
type,
isRead: readDate != null,
createdAt: createdAt,
),
NotificationType.consultantEducationUpdated => ConsultantEducationUpdatedNotification.fromJson(
notificationJson['data'],
type,
@@ -499,7 +509,14 @@ class NotificationsService {
),
NotificationType.unknown => UnknownNotification(type: type, createdAt: parseDate(createdAt)),
};
} catch (e) {
} catch (error, stackTrace) {
responseErrors?.report(
error,
stackTrace,
method: response.requestOptions.method,
statusCode: response.statusCode,
endpoint: _endpoint,
);
return UnknownNotification(type: NotificationType.unknown, createdAt: DateTime.now());
}
}).toList();
@@ -516,7 +533,14 @@ class NotificationsService {
};
}
return null;
} catch (e) {
} catch (error, stackTrace) {
responseErrors?.report(
error,
stackTrace,
method: response.requestOptions.method,
statusCode: response.statusCode,
endpoint: _endpoint,
);
rethrow;
}
}