forked from eatvio/eatvio_app
feat: Implement comprehensive navigation logic for various notification types within the NotificationWidget.
This commit is contained in:
@@ -215,6 +215,8 @@ class ChosenPlanStartedToConsultantNotification implements BaseNotificationModel
|
||||
final bool isRead;
|
||||
final String planName;
|
||||
final String customerName;
|
||||
final int planId;
|
||||
final int customerId;
|
||||
@override
|
||||
final DateTime createdAt;
|
||||
ChosenPlanStartedToConsultantNotification({
|
||||
@@ -222,6 +224,8 @@ class ChosenPlanStartedToConsultantNotification implements BaseNotificationModel
|
||||
required this.isRead,
|
||||
required this.planName,
|
||||
required this.customerName,
|
||||
required this.planId,
|
||||
required this.customerId,
|
||||
required this.createdAt,
|
||||
});
|
||||
|
||||
@@ -231,6 +235,8 @@ class ChosenPlanStartedToConsultantNotification implements BaseNotificationModel
|
||||
isRead: isRead ?? false,
|
||||
planName: json['plan_name'],
|
||||
customerName: json['client_name'],
|
||||
planId: json['plan_id'] ?? 0,
|
||||
customerId: json['client_id'] ?? 0,
|
||||
createdAt: parseDate(createdAt ?? json['created_at'] ?? DateTime.now().toIso8601String()),
|
||||
);
|
||||
}
|
||||
@@ -420,6 +426,7 @@ class CommentReplied implements BaseNotificationModel {
|
||||
final String author;
|
||||
final int authorId;
|
||||
final int parentCommentId;
|
||||
final int? commentId;
|
||||
@override
|
||||
final DateTime createdAt;
|
||||
|
||||
@@ -431,6 +438,7 @@ class CommentReplied implements BaseNotificationModel {
|
||||
required this.author,
|
||||
required this.authorId,
|
||||
required this.parentCommentId,
|
||||
this.commentId,
|
||||
required this.isRead,
|
||||
required this.createdAt,
|
||||
});
|
||||
@@ -444,6 +452,7 @@ class CommentReplied implements BaseNotificationModel {
|
||||
author: json['author'],
|
||||
authorId: json['author_id'],
|
||||
parentCommentId: json['parrent_comment_id'],
|
||||
commentId: json['comment_id'],
|
||||
isRead: isRead ?? false,
|
||||
createdAt: parseDate(createdAt ?? json['created_at'] ?? DateTime.now().toIso8601String()),
|
||||
);
|
||||
@@ -504,6 +513,7 @@ class EntityCommented implements BaseNotificationModel {
|
||||
final String authorName;
|
||||
final int authorId;
|
||||
final String authorSlug;
|
||||
final int? commentId;
|
||||
@override
|
||||
final DateTime createdAt;
|
||||
|
||||
@@ -517,6 +527,7 @@ class EntityCommented implements BaseNotificationModel {
|
||||
required this.authorName,
|
||||
required this.authorId,
|
||||
required this.authorSlug,
|
||||
this.commentId,
|
||||
required this.isRead,
|
||||
required this.createdAt,
|
||||
});
|
||||
@@ -532,6 +543,7 @@ class EntityCommented implements BaseNotificationModel {
|
||||
authorName: json['author_name'],
|
||||
authorId: json['author_id'],
|
||||
authorSlug: json['author_slug'],
|
||||
commentId: json['comment_id'],
|
||||
isRead: isRead ?? false,
|
||||
createdAt: parseDate(createdAt ?? json['created_at'] ?? DateTime.now().toIso8601String()),
|
||||
);
|
||||
@@ -831,7 +843,15 @@ class UnknownNotification implements BaseNotificationModel {
|
||||
@override
|
||||
final DateTime createdAt;
|
||||
|
||||
UnknownNotification({required this.type, this.isRead = true, DateTime? createdAt}) : createdAt = createdAt ?? DateTime.fromMillisecondsSinceEpoch(0);
|
||||
UnknownNotification({required this.type, this.isRead = true, required this.createdAt});
|
||||
|
||||
factory UnknownNotification.fromJson(Map<String, dynamic> json, NotificationType type, {bool? isRead, String? createdAt}) {
|
||||
return UnknownNotification(
|
||||
type: type,
|
||||
isRead: isRead ?? false,
|
||||
createdAt: parseDate(createdAt ?? json['created_at'] ?? DateTime.now().toIso8601String()),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class DietCancelledNotification implements BaseNotificationModel {
|
||||
@@ -1015,16 +1035,28 @@ class StayOnTrackToAuthorNotification implements BaseNotificationModel {
|
||||
final bool isRead;
|
||||
final String planName;
|
||||
final String clientName;
|
||||
final int planId;
|
||||
final int clientId;
|
||||
@override
|
||||
final DateTime createdAt;
|
||||
|
||||
StayOnTrackToAuthorNotification({required this.type, required this.planName, required this.clientName, required this.isRead, required this.createdAt});
|
||||
StayOnTrackToAuthorNotification({
|
||||
required this.type,
|
||||
required this.planName,
|
||||
required this.clientName,
|
||||
required this.planId,
|
||||
required this.clientId,
|
||||
required this.isRead,
|
||||
required this.createdAt,
|
||||
});
|
||||
|
||||
factory StayOnTrackToAuthorNotification.fromJson(Map<String, dynamic> json, NotificationType type, {bool? isRead, String? createdAt}) {
|
||||
return StayOnTrackToAuthorNotification(
|
||||
type: type,
|
||||
planName: json['plan_name'] ?? '',
|
||||
clientName: json['client_name'] ?? '',
|
||||
planId: json['plan_id'] ?? 0,
|
||||
clientId: json['client_id'] ?? 0,
|
||||
isRead: isRead ?? false,
|
||||
createdAt: parseDate(createdAt ?? json['created_at'] ?? DateTime.now().toIso8601String()),
|
||||
);
|
||||
@@ -1326,16 +1358,28 @@ class StayOnTrackToCustomerNotification implements BaseNotificationModel {
|
||||
final bool isRead;
|
||||
final String planName;
|
||||
final String consultantName;
|
||||
final int planId;
|
||||
final int consultantId;
|
||||
@override
|
||||
final DateTime createdAt;
|
||||
|
||||
StayOnTrackToCustomerNotification({required this.type, required this.planName, required this.consultantName, required this.isRead, required this.createdAt});
|
||||
StayOnTrackToCustomerNotification({
|
||||
required this.type,
|
||||
required this.planName,
|
||||
required this.consultantName,
|
||||
required this.planId,
|
||||
required this.consultantId,
|
||||
required this.isRead,
|
||||
required this.createdAt,
|
||||
});
|
||||
|
||||
factory StayOnTrackToCustomerNotification.fromJson(Map<String, dynamic> json, NotificationType type, {bool? isRead, String? createdAt}) {
|
||||
return StayOnTrackToCustomerNotification(
|
||||
type: type,
|
||||
planName: json['plan_name'] ?? '',
|
||||
consultantName: json['consultant_name'] ?? '',
|
||||
planId: json['plan_id'] ?? 0,
|
||||
consultantId: json['consultant_id'] ?? 0,
|
||||
isRead: isRead ?? false,
|
||||
createdAt: parseDate(createdAt ?? json['created_at'] ?? DateTime.now().toIso8601String()),
|
||||
);
|
||||
@@ -1652,14 +1696,16 @@ class ProductStatusUpdatedForAuthorNotification implements BaseNotificationModel
|
||||
final String productName;
|
||||
final String oldStatus;
|
||||
final String newStatus;
|
||||
final String status; // Added to capture single status if old/new aren't provided
|
||||
@override
|
||||
final DateTime createdAt;
|
||||
|
||||
ProductStatusUpdatedForAuthorNotification({
|
||||
required this.type,
|
||||
required this.productName,
|
||||
required this.oldStatus,
|
||||
required this.newStatus,
|
||||
this.oldStatus = '',
|
||||
this.newStatus = '',
|
||||
this.status = '',
|
||||
required this.isRead,
|
||||
required this.createdAt,
|
||||
});
|
||||
@@ -1670,6 +1716,7 @@ class ProductStatusUpdatedForAuthorNotification implements BaseNotificationModel
|
||||
productName: json['product_name'] ?? '',
|
||||
oldStatus: json['old_status'] ?? '',
|
||||
newStatus: json['new_status'] ?? '',
|
||||
status: json['status'] ?? '',
|
||||
isRead: isRead ?? false,
|
||||
createdAt: parseDate(createdAt ?? json['created_at'] ?? DateTime.now().toIso8601String()),
|
||||
);
|
||||
@@ -1724,6 +1771,309 @@ class PersonalDietIsDefinedToCustomerNotification implements BaseNotificationMod
|
||||
}
|
||||
}
|
||||
|
||||
// New Model Classes for Comprehensive Support
|
||||
|
||||
class ConsultantEducationUpdatedNotification implements BaseNotificationModel {
|
||||
@override
|
||||
final NotificationType type;
|
||||
@override
|
||||
final bool isRead;
|
||||
@override
|
||||
final DateTime createdAt;
|
||||
final String consultantName;
|
||||
|
||||
ConsultantEducationUpdatedNotification({
|
||||
required this.type,
|
||||
required this.isRead,
|
||||
required this.createdAt,
|
||||
required this.consultantName,
|
||||
});
|
||||
|
||||
factory ConsultantEducationUpdatedNotification.fromJson(Map<String, dynamic> json, NotificationType type, {bool? isRead, String? createdAt}) {
|
||||
return ConsultantEducationUpdatedNotification(
|
||||
type: type,
|
||||
isRead: isRead ?? false,
|
||||
createdAt: parseDate(createdAt ?? json['created_at'] ?? DateTime.now().toIso8601String()),
|
||||
consultantName: json['consultant_name'] ?? '',
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class ComplaintRegisteredNotification implements BaseNotificationModel {
|
||||
@override
|
||||
final NotificationType type;
|
||||
@override
|
||||
final bool isRead;
|
||||
@override
|
||||
final DateTime createdAt;
|
||||
final String complaintType;
|
||||
final String entityName;
|
||||
|
||||
ComplaintRegisteredNotification({
|
||||
required this.type,
|
||||
required this.isRead,
|
||||
required this.createdAt,
|
||||
required this.complaintType,
|
||||
required this.entityName,
|
||||
});
|
||||
|
||||
factory ComplaintRegisteredNotification.fromJson(Map<String, dynamic> json, NotificationType type, {bool? isRead, String? createdAt}) {
|
||||
return ComplaintRegisteredNotification(
|
||||
type: type,
|
||||
isRead: isRead ?? false,
|
||||
createdAt: parseDate(createdAt ?? json['created_at'] ?? DateTime.now().toIso8601String()),
|
||||
complaintType: json['complaint_type'] ?? '',
|
||||
entityName: json['entity_name'] ?? '',
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class ContentUnpublishedNotification implements BaseNotificationModel {
|
||||
@override
|
||||
final NotificationType type;
|
||||
@override
|
||||
final bool isRead;
|
||||
@override
|
||||
final DateTime createdAt;
|
||||
final String reason;
|
||||
final String entityName;
|
||||
|
||||
ContentUnpublishedNotification({
|
||||
required this.type,
|
||||
required this.isRead,
|
||||
required this.createdAt,
|
||||
required this.reason,
|
||||
required this.entityName,
|
||||
});
|
||||
|
||||
factory ContentUnpublishedNotification.fromJson(Map<String, dynamic> json, NotificationType type, {bool? isRead, String? createdAt}) {
|
||||
return ContentUnpublishedNotification(
|
||||
type: type,
|
||||
isRead: isRead ?? false,
|
||||
createdAt: parseDate(createdAt ?? json['created_at'] ?? DateTime.now().toIso8601String()),
|
||||
reason: json['reason'] ?? '',
|
||||
entityName: json['entity_name'] ?? '',
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class FinanceQuestionCreatedNotification implements BaseNotificationModel {
|
||||
@override
|
||||
final NotificationType type;
|
||||
@override
|
||||
final bool isRead;
|
||||
@override
|
||||
final DateTime createdAt;
|
||||
final String questionText;
|
||||
|
||||
FinanceQuestionCreatedNotification({
|
||||
required this.type,
|
||||
required this.isRead,
|
||||
required this.createdAt,
|
||||
required this.questionText,
|
||||
});
|
||||
|
||||
factory FinanceQuestionCreatedNotification.fromJson(Map<String, dynamic> json, NotificationType type, {bool? isRead, String? createdAt}) {
|
||||
return FinanceQuestionCreatedNotification(
|
||||
type: type,
|
||||
isRead: isRead ?? false,
|
||||
createdAt: parseDate(createdAt ?? json['created_at'] ?? DateTime.now().toIso8601String()),
|
||||
questionText: json['question_text'] ?? '',
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class NewChatMessageNotification implements BaseNotificationModel {
|
||||
@override
|
||||
final NotificationType type;
|
||||
@override
|
||||
final bool isRead;
|
||||
@override
|
||||
final DateTime createdAt;
|
||||
final String senderName;
|
||||
final String messagePreview;
|
||||
final int chatId;
|
||||
|
||||
NewChatMessageNotification({
|
||||
required this.type,
|
||||
required this.isRead,
|
||||
required this.createdAt,
|
||||
required this.senderName,
|
||||
required this.messagePreview,
|
||||
required this.chatId,
|
||||
});
|
||||
|
||||
factory NewChatMessageNotification.fromJson(Map<String, dynamic> json, NotificationType type, {bool? isRead, String? createdAt}) {
|
||||
return NewChatMessageNotification(
|
||||
type: type,
|
||||
isRead: isRead ?? false,
|
||||
createdAt: parseDate(createdAt ?? json['created_at'] ?? DateTime.now().toIso8601String()),
|
||||
senderName: json['sender_name'] ?? '',
|
||||
messagePreview: json['message_preview'] ?? '',
|
||||
chatId: json['chat_id'] ?? 0,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class CompleteRegistrationNotification implements BaseNotificationModel {
|
||||
@override
|
||||
final NotificationType type;
|
||||
@override
|
||||
final bool isRead;
|
||||
@override
|
||||
final DateTime createdAt;
|
||||
|
||||
CompleteRegistrationNotification({
|
||||
required this.type,
|
||||
required this.isRead,
|
||||
required this.createdAt,
|
||||
});
|
||||
|
||||
factory CompleteRegistrationNotification.fromJson(Map<String, dynamic> json, NotificationType type, {bool? isRead, String? createdAt}) {
|
||||
return CompleteRegistrationNotification(
|
||||
type: type,
|
||||
isRead: isRead ?? false,
|
||||
createdAt: parseDate(createdAt ?? json['created_at'] ?? DateTime.now().toIso8601String()),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class ChosenDietExpiredNotification implements BaseNotificationModel {
|
||||
@override
|
||||
final NotificationType type;
|
||||
@override
|
||||
final bool isRead;
|
||||
@override
|
||||
final DateTime createdAt;
|
||||
final String dietName;
|
||||
|
||||
ChosenDietExpiredNotification({
|
||||
required this.type,
|
||||
required this.isRead,
|
||||
required this.createdAt,
|
||||
required this.dietName,
|
||||
});
|
||||
|
||||
factory ChosenDietExpiredNotification.fromJson(Map<String, dynamic> json, NotificationType type, {bool? isRead, String? createdAt}) {
|
||||
return ChosenDietExpiredNotification(
|
||||
type: type,
|
||||
isRead: isRead ?? false,
|
||||
createdAt: parseDate(createdAt ?? json['created_at'] ?? DateTime.now().toIso8601String()),
|
||||
dietName: json['diet_name'] ?? '',
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class MotivateUserNotification implements BaseNotificationModel {
|
||||
@override
|
||||
final NotificationType type;
|
||||
@override
|
||||
final bool isRead;
|
||||
@override
|
||||
final DateTime createdAt;
|
||||
final String message;
|
||||
|
||||
MotivateUserNotification({
|
||||
required this.type,
|
||||
required this.isRead,
|
||||
required this.createdAt,
|
||||
required this.message,
|
||||
});
|
||||
|
||||
factory MotivateUserNotification.fromJson(Map<String, dynamic> json, NotificationType type, {bool? isRead, String? createdAt}) {
|
||||
return MotivateUserNotification(
|
||||
type: type,
|
||||
isRead: isRead ?? false,
|
||||
createdAt: parseDate(createdAt ?? json['created_at'] ?? DateTime.now().toIso8601String()),
|
||||
message: json['message'] ?? '',
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class CommentComplaintNotification implements BaseNotificationModel {
|
||||
@override
|
||||
final NotificationType type;
|
||||
@override
|
||||
final bool isRead;
|
||||
@override
|
||||
final DateTime createdAt;
|
||||
final String commentPreview;
|
||||
final String reason;
|
||||
|
||||
CommentComplaintNotification({
|
||||
required this.type,
|
||||
required this.isRead,
|
||||
required this.createdAt,
|
||||
required this.commentPreview,
|
||||
required this.reason,
|
||||
});
|
||||
|
||||
factory CommentComplaintNotification.fromJson(Map<String, dynamic> json, NotificationType type, {bool? isRead, String? createdAt}) {
|
||||
return CommentComplaintNotification(
|
||||
type: type,
|
||||
isRead: isRead ?? false,
|
||||
createdAt: parseDate(createdAt ?? json['created_at'] ?? DateTime.now().toIso8601String()),
|
||||
commentPreview: json['comment_preview'] ?? '',
|
||||
reason: json['reason'] ?? '',
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class CommentDeletedNotification implements BaseNotificationModel {
|
||||
@override
|
||||
final NotificationType type;
|
||||
@override
|
||||
final bool isRead;
|
||||
@override
|
||||
final DateTime createdAt;
|
||||
final String commentPreview;
|
||||
|
||||
CommentDeletedNotification({
|
||||
required this.type,
|
||||
required this.isRead,
|
||||
required this.createdAt,
|
||||
required this.commentPreview,
|
||||
});
|
||||
|
||||
factory CommentDeletedNotification.fromJson(Map<String, dynamic> json, NotificationType type, {bool? isRead, String? createdAt}) {
|
||||
return CommentDeletedNotification(
|
||||
type: type,
|
||||
isRead: isRead ?? false,
|
||||
createdAt: parseDate(createdAt ?? json['created_at'] ?? DateTime.now().toIso8601String()),
|
||||
commentPreview: json['comment_preview'] ?? '',
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class UserSubscribedNotification implements BaseNotificationModel {
|
||||
@override
|
||||
final NotificationType type;
|
||||
@override
|
||||
final bool isRead;
|
||||
@override
|
||||
final DateTime createdAt;
|
||||
final String subscriberName;
|
||||
final int subscriberId;
|
||||
|
||||
UserSubscribedNotification({
|
||||
required this.type,
|
||||
required this.isRead,
|
||||
required this.createdAt,
|
||||
required this.subscriberName,
|
||||
required this.subscriberId,
|
||||
});
|
||||
|
||||
factory UserSubscribedNotification.fromJson(Map<String, dynamic> json, NotificationType type, {bool? isRead, String? createdAt}) {
|
||||
return UserSubscribedNotification(
|
||||
type: type,
|
||||
isRead: isRead ?? false,
|
||||
createdAt: parseDate(createdAt ?? json['created_at'] ?? DateTime.now().toIso8601String()),
|
||||
subscriberName: json['subscriber_name'] ?? '',
|
||||
subscriberId: json['subscriber_id'] ?? 0,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
enum NotificationType {
|
||||
// Diet related
|
||||
dietCancelled,
|
||||
@@ -1731,6 +2081,7 @@ enum NotificationType {
|
||||
dietExpired,
|
||||
dietWillStartedIn,
|
||||
dietCanNotBeStarted,
|
||||
chosenDietExpired, // New
|
||||
|
||||
// Plan related
|
||||
personalDietCreationNeeded,
|
||||
@@ -1760,12 +2111,17 @@ enum NotificationType {
|
||||
// Comments
|
||||
entityCommented,
|
||||
commentReplied,
|
||||
commentComplaint, // New
|
||||
commentDeleted, // New
|
||||
|
||||
// Profile
|
||||
phoneChanged,
|
||||
consultantEducationUpdated, // New
|
||||
completeRegistration, // New
|
||||
|
||||
// Subscription
|
||||
subscription,
|
||||
userSubscribed, // New
|
||||
|
||||
// Badges
|
||||
badgeAwarded,
|
||||
@@ -1773,16 +2129,21 @@ enum NotificationType {
|
||||
|
||||
// Consultant
|
||||
consultantRequestStarted,
|
||||
motivateUser, // New
|
||||
|
||||
// Complaints
|
||||
clientCloseComplaintSuccess,
|
||||
complaintToModerationForUser,
|
||||
complaintRegistered, // New
|
||||
contentUnpublished, // New
|
||||
contentUnpublishedComplaint, // New
|
||||
|
||||
// Finance
|
||||
clientRefundSuccess,
|
||||
consultantRefundSuccess,
|
||||
clientRejectSuccess,
|
||||
consultantRejectSuccess,
|
||||
financeQuestionCreated, // New
|
||||
|
||||
// Score
|
||||
scoreAdded,
|
||||
@@ -1794,6 +2155,9 @@ enum NotificationType {
|
||||
// Diary
|
||||
diaryReminderForUsers,
|
||||
|
||||
// Chat
|
||||
newChatMessage, // New
|
||||
|
||||
// Legacy types (keeping for backward compatibility)
|
||||
planSubscriptionStartedToAuthor,
|
||||
planSubscriptionCanceledToAuthor,
|
||||
@@ -1865,7 +2229,23 @@ enum NotificationType {
|
||||
'stay-on-track-to-customer' => NotificationType.stayOnTrackToCustomer,
|
||||
'diary-reminder-for-users' => NotificationType.diaryReminderForUsers,
|
||||
'personal-diet-is-defined-to-customer' => NotificationType.personalDietIsDefinedToCustomer,
|
||||
|
||||
|
||||
// New additions
|
||||
'consultant-education-updated' => NotificationType.consultantEducationUpdated,
|
||||
'complaint-registered' => NotificationType.complaintRegistered,
|
||||
'content-unpublished' => NotificationType.contentUnpublished,
|
||||
'content-unpublished-complaint' => NotificationType.contentUnpublishedComplaint,
|
||||
'finance-question-created' => NotificationType.financeQuestionCreated,
|
||||
'new-chat-message' => NotificationType.newChatMessage,
|
||||
'complete-registration' => NotificationType.completeRegistration,
|
||||
'chosen-diet-expired' => NotificationType.chosenDietExpired,
|
||||
'motivate-user' => NotificationType.motivateUser,
|
||||
'comment-complaint' => NotificationType.commentComplaint,
|
||||
'comment-deleted' => NotificationType.commentDeleted,
|
||||
'user-subscribed' => NotificationType.userSubscribed,
|
||||
// 'diary-reminder' => NotificationType.diaryReminder, // Already legacy? Check if it maps to diaryReminderNotification
|
||||
'meal-reminder' => NotificationType.mealReminder, // Maps to legacy if string matches? No, legacy was App\\...
|
||||
|
||||
// Legacy mapping
|
||||
'App\\Notifications\\Plan\\PlanSubscriptionStartedToAuthor' => NotificationType.planSubscriptionStartedToAuthor,
|
||||
'App\\Notifications\\Plan\\PlanSubscriptionCanceledToAuthor' => NotificationType.planSubscriptionCanceledToAuthor,
|
||||
|
||||
Reference in New Issue
Block a user