add auth, format
This commit is contained in:
@@ -66,7 +66,7 @@ class NotificationLocalDataSource {
|
||||
'data': {
|
||||
'current_tier': 'gold',
|
||||
'next_tier': 'platinum',
|
||||
'points_needed': 2250
|
||||
'points_needed': 2250,
|
||||
},
|
||||
'is_read': true,
|
||||
'is_pushed': true,
|
||||
@@ -128,17 +128,20 @@ class NotificationLocalDataSource {
|
||||
|
||||
/// Get notifications by category
|
||||
Future<List<Map<String, dynamic>>> getNotificationsByCategory(
|
||||
String category) async {
|
||||
String category,
|
||||
) async {
|
||||
await Future.delayed(const Duration(milliseconds: 200));
|
||||
|
||||
if (category == 'general') {
|
||||
return _mockNotifications
|
||||
.where((n) =>
|
||||
!(n['type'] as String).toLowerCase().contains('order') ||
|
||||
(n['type'] as String).toLowerCase().contains('loyalty') ||
|
||||
(n['type'] as String).toLowerCase().contains('promotion') ||
|
||||
(n['type'] as String).toLowerCase().contains('event') ||
|
||||
(n['type'] as String).toLowerCase().contains('birthday'))
|
||||
.where(
|
||||
(n) =>
|
||||
!(n['type'] as String).toLowerCase().contains('order') ||
|
||||
(n['type'] as String).toLowerCase().contains('loyalty') ||
|
||||
(n['type'] as String).toLowerCase().contains('promotion') ||
|
||||
(n['type'] as String).toLowerCase().contains('event') ||
|
||||
(n['type'] as String).toLowerCase().contains('birthday'),
|
||||
)
|
||||
.toList();
|
||||
} else if (category == 'order') {
|
||||
return _mockNotifications
|
||||
@@ -159,8 +162,9 @@ class NotificationLocalDataSource {
|
||||
Future<void> markAsRead(String notificationId) async {
|
||||
await Future.delayed(const Duration(milliseconds: 150));
|
||||
|
||||
final index = _mockNotifications
|
||||
.indexWhere((n) => n['notification_id'] == notificationId);
|
||||
final index = _mockNotifications.indexWhere(
|
||||
(n) => n['notification_id'] == notificationId,
|
||||
);
|
||||
if (index != -1) {
|
||||
_mockNotifications[index]['is_read'] = true;
|
||||
_mockNotifications[index]['read_at'] = DateTime.now().toIso8601String();
|
||||
|
||||
@@ -21,7 +21,7 @@ class NotificationModel {
|
||||
isRead: json['is_read'] as bool? ?? false,
|
||||
isPushed: json['is_pushed'] as bool? ?? false,
|
||||
createdAt: DateTime.parse(json['created_at'] as String),
|
||||
readAt: json['read_at'] != null
|
||||
readAt: json['read_at'] != null
|
||||
? DateTime.parse(json['read_at'] as String)
|
||||
: null,
|
||||
);
|
||||
|
||||
@@ -21,7 +21,9 @@ class NotificationRepositoryImpl implements NotificationRepository {
|
||||
Future<List<Notification>> getAllNotifications() async {
|
||||
final jsonList = await localDataSource.getAllNotifications();
|
||||
return jsonList.map((json) => NotificationModel.fromJson(json)).toList()
|
||||
..sort((a, b) => b.createdAt.compareTo(a.createdAt)); // Sort by newest first
|
||||
..sort(
|
||||
(a, b) => b.createdAt.compareTo(a.createdAt),
|
||||
); // Sort by newest first
|
||||
}
|
||||
|
||||
@override
|
||||
|
||||
Reference in New Issue
Block a user