import 'package:eatvio_app/features/feed/models/feed_blog_post_model.dart'; sealed class BaseNotificationModel { abstract final NotificationType type; abstract final bool isRead; } class PlanSubscriptionStartedToAuthorNotification implements BaseNotificationModel { @override final NotificationType type; @override final bool isRead; final String planName; final String customerName; final String chatId; PlanSubscriptionStartedToAuthorNotification({ required this.type, required this.planName, required this.customerName, required this.chatId, required this.isRead, }); factory PlanSubscriptionStartedToAuthorNotification.fromJson(Map json, NotificationType type, {bool? isRead}) { return PlanSubscriptionStartedToAuthorNotification( type: type, planName: json['plan_name'], customerName: json['user_name'], chatId: json['chat_id'], isRead: isRead ?? false, ); } } class PlanSubscriptionCanceledToAuthorNotification implements BaseNotificationModel { @override final NotificationType type; @override final bool isRead; final String planName; final String customerName; PlanSubscriptionCanceledToAuthorNotification({ required this.type, required this.planName, required this.customerName, required this.isRead, }); factory PlanSubscriptionCanceledToAuthorNotification.fromJson(Map json, NotificationType type, {bool? isRead}) { return PlanSubscriptionCanceledToAuthorNotification( type: type, planName: json['plan_name'], customerName: json['user_name'], isRead: isRead ?? false, ); } } class ChosenPlanStartedToClientNotification implements BaseNotificationModel { @override final NotificationType type; @override final bool isRead; final String planName; final int planId; ChosenPlanStartedToClientNotification({ required this.type, required this.planName, required this.planId, required this.isRead, }); factory ChosenPlanStartedToClientNotification.fromJson(Map json, NotificationType type, {bool? isRead}) { return ChosenPlanStartedToClientNotification( type: type, planName: json['plan_name'], planId: json['plan_id'], isRead: isRead ?? false, ); } } class ChosenPlanTomorrowReminderToClientNotification implements BaseNotificationModel { @override final NotificationType type; @override final bool isRead; final String planName; ChosenPlanTomorrowReminderToClientNotification({ required this.type, required this.planName, required this.isRead, }); factory ChosenPlanTomorrowReminderToClientNotification.fromJson(Map json, NotificationType type, {bool? isRead}) { return ChosenPlanTomorrowReminderToClientNotification(type: type, planName: json['plan_name'], isRead: isRead ?? false); } } class DiaryReminderNotification implements BaseNotificationModel { @override final NotificationType type; @override final bool isRead; DiaryReminderNotification({required this.type, required this.isRead}); factory DiaryReminderNotification.fromJson(Map json, NotificationType type, {bool? isRead}) { return DiaryReminderNotification(type: type, isRead: isRead ?? false); } } class ConsultantLeftCommentNotification implements BaseNotificationModel { @override final NotificationType type; @override final bool isRead; final DateTime date; ConsultantLeftCommentNotification({ required this.type, required this.date, required this.isRead, }); factory ConsultantLeftCommentNotification.fromJson(Map json, NotificationType type, {bool? isRead}) { return ConsultantLeftCommentNotification( type: type, date: parseDate(json['diary_date']), isRead: isRead ?? false, ); } } class PersonalizedDietIsDefinedNotification implements BaseNotificationModel { @override final NotificationType type; @override final bool isRead; PersonalizedDietIsDefinedNotification({ required this.type, required this.isRead, }); factory PersonalizedDietIsDefinedNotification.fromJson(Map json, NotificationType type, {bool? isRead}) { return PersonalizedDietIsDefinedNotification( type: type, isRead: isRead ?? false, ); } } class ChosenPlanFinishedToClientNotification implements BaseNotificationModel { @override final NotificationType type; @override final bool isRead; final String planName; ChosenPlanFinishedToClientNotification({ required this.type, required this.planName, required this.isRead, }); factory ChosenPlanFinishedToClientNotification.fromJson(Map json, NotificationType type, {bool? isRead}) { return ChosenPlanFinishedToClientNotification( type: type, planName: json['plan_name'], isRead: isRead ?? false, ); } } class PlanSubscriptionCanceledToCustomerNotification implements BaseNotificationModel { @override final NotificationType type; @override final bool isRead; final String planName; PlanSubscriptionCanceledToCustomerNotification({ required this.type, required this.planName, required this.isRead, }); factory PlanSubscriptionCanceledToCustomerNotification.fromJson(Map json, NotificationType type, {bool? isRead}) { return PlanSubscriptionCanceledToCustomerNotification( type: type, planName: json['plan_name'], isRead: isRead ?? false, ); } } class ChosenPlanStartedToConsultantNotification implements BaseNotificationModel { @override final NotificationType type; @override final bool isRead; final String planName; final String customerName; ChosenPlanStartedToConsultantNotification({ required this.type, required this.isRead, required this.planName, required this.customerName, }); factory ChosenPlanStartedToConsultantNotification.fromJson(Map json, NotificationType type, {bool? isRead}) { return ChosenPlanStartedToConsultantNotification( type: type, isRead: isRead ?? false, planName: json['plan_name'], customerName: json['client_name'], ); } } class ChosenPlanTomorrowReminderToConsultantNotification implements BaseNotificationModel { @override final NotificationType type; @override final bool isRead; final String planName; final String customerName; ChosenPlanTomorrowReminderToConsultantNotification({ required this.type, required this.planName, required this.customerName, required this.isRead, }); factory ChosenPlanTomorrowReminderToConsultantNotification.fromJson(Map json, NotificationType type, {bool? isRead}) { return ChosenPlanTomorrowReminderToConsultantNotification( type: type, planName: json['plan_name'], customerName: json['client_name'], isRead: isRead ?? false, ); } } class PlanSubscriptionPaidToAuthorNotification implements BaseNotificationModel { @override final NotificationType type; @override final bool isRead; final String planName; final String customerName; PlanSubscriptionPaidToAuthorNotification({ required this.type, required this.isRead, required this.planName, required this.customerName, }); factory PlanSubscriptionPaidToAuthorNotification.fromJson(Map json, NotificationType type, {bool? isRead}) { return PlanSubscriptionPaidToAuthorNotification( type: type, isRead: isRead ?? false, planName: json['plan_name'], customerName: json['user_name'], ); } } class ChosenPlanFinishedToConsultantNotification implements BaseNotificationModel { @override final NotificationType type; @override final bool isRead; final String planName; final String customerName; final int planId; ChosenPlanFinishedToConsultantNotification({ required this.type, required this.planName, required this.customerName, required this.planId, required this.isRead, }); factory ChosenPlanFinishedToConsultantNotification.fromJson(Map json, NotificationType type, {bool? isRead}) { return ChosenPlanFinishedToConsultantNotification( type: type, planName: json['plan_name'], customerName: json['client_name'], planId: json['plan_id'], isRead: isRead ?? false, ); } } class UnknownNotification implements BaseNotificationModel { @override final NotificationType type; @override final bool isRead; UnknownNotification({ required this.type, this.isRead = true, }); } enum NotificationType { planSubscriptionStartedToAuthor, planSubscriptionCanceledToAuthor, chosenPlanStartedToClientNotification, chosenPlanTomorrowReminderToClientNotification, diaryReminderNotification, consultantLeftComment, personalizedDietIsDefined, chosenPlanFinishedToClient, planSubscriptionCanceledToCustomer, chosenPlanStartedToConsultantNotification, chosenPlanTomorrowReminderToConsultantNotification, planSubscriptionPaidToAuthor, chosenPlanFinishedToConsultant, unknown; static NotificationType getTypeFromString(String type) => switch (type) { 'App\\Notifications\\Plan\\PlanSubscriptionStartedToAuthor' => NotificationType.planSubscriptionStartedToAuthor, 'App\\Notifications\\Plan\\PlanSubscriptionCanceledToAuthor' => NotificationType.planSubscriptionCanceledToAuthor, 'App\\Notifications\\Plan\\ChosenPlanStartedToClientNotification' => NotificationType.chosenPlanStartedToClientNotification, 'App\\Notifications\\Plan\\ChosenPlanTomorrowReminderToClientNotification' => NotificationType.chosenPlanStartedToClientNotification, 'App\\Notifications\\DiaryReminderNotification' => NotificationType.diaryReminderNotification, 'App\\Notifications\\Plan\\ConsultantLeftComment' => NotificationType.consultantLeftComment, 'App\\Notifications\\Plan\\PersonalizedDietIsDefined' => NotificationType.personalizedDietIsDefined, 'App\\Notifications\\Plan\\ChosenPlanFinishedToClient' => NotificationType.chosenPlanFinishedToClient, 'App\\Notifications\\Plan\\PlanSubscriptionCanceledToCustomer' => NotificationType.planSubscriptionCanceledToCustomer, 'App\\Notifications\\Plan\\ChosenPlanStartedToConsultantNotification' => NotificationType.chosenPlanStartedToConsultantNotification, 'App\\Notifications\\Plan\\ChosenPlanTomorrowReminderToConsultantNotification' => NotificationType.chosenPlanTomorrowReminderToConsultantNotification, 'App\\Notifications\\Plan\\PlanSubscriptionPaidToAuthor' => NotificationType.planSubscriptionPaidToAuthor, 'App\\Notifications\\Plan\\ChosenPlanFinishedToConsultant' => NotificationType.chosenPlanFinishedToConsultant, _ => NotificationType.unknown, }; }