Merge pull request 'added_unread_allread_notification' (#157) from added_unread_allread_notification into main

Reviewed-on: https://repo.ravanertebat.com/TM/tm_app/pulls/157
This commit is contained in:
a.ghabeli
2025-09-24 08:43:05 +03:30
8 changed files with 227 additions and 105 deletions
@@ -4,7 +4,7 @@ import 'package:tm_app/data/services/notification_service.dart';
class NotificationsRepository {
NotificationsRepository({required NotificationsService notificationsService})
: _notificationsService = notificationsService;
: _notificationsService = notificationsService;
final NotificationsService _notificationsService;
@@ -12,13 +12,20 @@ class NotificationsRepository {
required int limit,
required int offset,
}) async {
return _notificationsService.getNotifications(
return _notificationsService.getNotifications(limit: limit, offset: offset);
}
Future<Result<Map<String, dynamic>>> markAllAsRead() async {
return _notificationsService.markAllAsRead();
}
Future<Result<NotificationResponseModel>> getUnreadNotifications({
required int limit,
required int offset,
}) {
return _notificationsService.getUnreadNotifications(
limit: limit,
offset: offset,
);
}
Future<Result<NotificationResponseModel>> markAllAsRead() async {
return _notificationsService.markAllAsRead();
}
}
+4 -3
View File
@@ -7,10 +7,11 @@ class NotificationApi {
static const String markAllAsRead = '/api/v1/notifications';
static const String markAllAsRead = '/api/v1/notifications/mark';
static const String markAsRead = '/api/v1/notifications/mark-as-read';
static const String tenderApprovalsTender = '/api/v1/notifications';
static String getTenderApprovalById({required String tenderId}) {
return '$tenderApprovalsTender/$tenderId';
static const String unreadNotifications = '/api/v1/notifications?seen=false';
static String getUnreadNotifications({required int limit, required int offset}) {
return '$unreadNotifications?limit=$limit&offset=$offset';
}
}
+18 -5
View File
@@ -1,14 +1,15 @@
// notification_service.dart
import 'dart:convert';
import 'package:tm_app/core/utils/result.dart';
import 'package:tm_app/data/services/api/notification_api.dart';
import 'package:tm_app/data/services/model/notification__response/notification_response_model.dart';
import 'package:tm_app/core/utils/result.dart';
import '../../core/network/network_manager.dart';
class NotificationsService {
NotificationsService({required NetworkManager networkManager})
: _networkManager = networkManager;
: _networkManager = networkManager;
final NetworkManager _networkManager;
Future<Result<NotificationResponseModel>> getNotifications({
@@ -24,11 +25,11 @@ class NotificationsService {
return result;
}
Future<Result<NotificationResponseModel>> markAllAsRead() async {
Future<Result<Map<String, dynamic>>> markAllAsRead() async {
final result = await _networkManager.makeRequest(
NotificationApi.markAllAsRead,
method: 'POST',
(json) => NotificationResponseModel.fromJson(json),
method: 'GET',
(json) => json,
);
return result;
}
@@ -42,6 +43,18 @@ class NotificationsService {
method: 'POST',
(json) => NotificationResponseModel.fromJson(json),
data: data,
);
return result;
}
Future<Result<NotificationResponseModel>> getUnreadNotifications({
required int limit,
required int offset,
}) async {
final result = await _networkManager.makeRequest(
NotificationApi.unreadNotifications,
method: 'GET',
(json) => NotificationResponseModel.fromJson(json),
);
return result;
}