diff --git a/lib/features/chat/services/chat_service.dart b/lib/features/chat/services/chat_service.dart index cceaa9d0..89d65749 100644 --- a/lib/features/chat/services/chat_service.dart +++ b/lib/features/chat/services/chat_service.dart @@ -13,18 +13,18 @@ part 'chat_service.g.dart'; abstract class ChatService { factory ChatService(Dio dio, {String baseUrl}) = _ChatService; - @GET('/api/chat/index') + @GET('/api/v2/chat/index') Future getChatRooms({ @Query('page') required int page, @Query('filters[data][\$conversation_name]') String? query, }); - @GET('/api/chat/show/{uuid}') + @GET('/api/v2/chat/show/{uuid}') Future getChatRoom({ @Path() required String uuid, }); - @POST('/api/chat/message/send/{slug}') + @POST('/api/v2/chat/message/send/{slug}') @MultiPart() Future sendMessage({ @Header('X-Socket-ID') required String socketId, @@ -33,13 +33,13 @@ abstract class ChatService { @Part(name: 'media_data[]', contentType: 'multipart/form-data') List? mediaData, }); - @GET('/api/chat/show/{id}/messages?page={page}') + @GET('/api/v2/chat/show/{id}/messages?page={page}') Future getChatMessages({ @Path() required String id, @Path() required int page, }); - @GET('/api/chat/get_by_user/{user}') + @GET('/api/v2/chat/get_by_user/{user}') Future getChatRoomIdByUserSlug({ @Path() required String user, }); diff --git a/lib/features/notifications/models/notification_model.dart b/lib/features/notifications/models/notification_model.dart index e8489a5a..827a0904 100644 --- a/lib/features/notifications/models/notification_model.dart +++ b/lib/features/notifications/models/notification_model.dart @@ -106,8 +106,7 @@ class DiaryReminderNotification implements BaseNotificationModel { final NotificationType type; @override final bool isRead; - - + DiaryReminderNotification({required this.type, required this.isRead}); factory DiaryReminderNotification.fromJson(Map json, NotificationType type, {bool? isRead}) { @@ -297,6 +296,25 @@ class ChosenPlanFinishedToConsultantNotification implements BaseNotificationMode } } +class ChosenPlanLastDayFinishedForUser implements BaseNotificationModel { + @override + final NotificationType type; + @override + final bool isRead; + + ChosenPlanLastDayFinishedForUser({ + required this.type, + required this.isRead, + }); + + factory ChosenPlanLastDayFinishedForUser.fromJson(Map json, NotificationType type, {bool? isRead}) { + return ChosenPlanLastDayFinishedForUser( + type: type, + isRead: isRead ?? false, + ); + } +} + class UnknownNotification implements BaseNotificationModel { @override final NotificationType type; @@ -323,6 +341,7 @@ enum NotificationType { chosenPlanTomorrowReminderToConsultantNotification, planSubscriptionPaidToAuthor, chosenPlanFinishedToConsultant, + chosenPlanLastDayFinishedForUser, unknown; static NotificationType getTypeFromString(String type) => switch (type) { @@ -339,6 +358,7 @@ enum NotificationType { 'App\\Notifications\\Plan\\ChosenPlanTomorrowReminderToConsultantNotification' => NotificationType.chosenPlanTomorrowReminderToConsultantNotification, 'App\\Notifications\\Plan\\PlanSubscriptionPaidToAuthor' => NotificationType.planSubscriptionPaidToAuthor, 'App\\Notifications\\Plan\\ChosenPlanFinishedToConsultant' => NotificationType.chosenPlanFinishedToConsultant, + 'App\\Notifications\\ChosenPlan\\LastDayFinishedForUser' => NotificationType.chosenPlanLastDayFinishedForUser, _ => NotificationType.unknown, }; } diff --git a/lib/features/notifications/presentation/notifications_cubit/notifications_cubit.dart b/lib/features/notifications/presentation/notifications_cubit/notifications_cubit.dart index 16cf1f40..61eba9a7 100644 --- a/lib/features/notifications/presentation/notifications_cubit/notifications_cubit.dart +++ b/lib/features/notifications/presentation/notifications_cubit/notifications_cubit.dart @@ -42,6 +42,7 @@ class NotificationsCubit extends Cubit { ChosenPlanTomorrowReminderToConsultantNotification.fromJson(notificationJson, type), NotificationType.planSubscriptionPaidToAuthor => PlanSubscriptionPaidToAuthorNotification.fromJson(notificationJson, type), NotificationType.chosenPlanFinishedToConsultant => ChosenPlanFinishedToConsultantNotification.fromJson(notificationJson, type), + NotificationType.chosenPlanLastDayFinishedForUser => ChosenPlanLastDayFinishedForUser.fromJson(notificationJson, type), NotificationType.unknown => UnknownNotification(type: type), }; } catch (e) { diff --git a/lib/features/notifications/presentation/widgets/notification_widget.dart b/lib/features/notifications/presentation/widgets/notification_widget.dart index 83157593..66b6cf18 100644 --- a/lib/features/notifications/presentation/widgets/notification_widget.dart +++ b/lib/features/notifications/presentation/widgets/notification_widget.dart @@ -53,6 +53,7 @@ class NotificationWidget extends StatelessWidget { ChosenPlanFinishedToConsultantNotification() => _ChosenPlanFinishedToConsultantWidget( notification: notification as ChosenPlanFinishedToConsultantNotification, ), + ChosenPlanLastDayFinishedForUser() => Text((notification as ChosenPlanLastDayFinishedForUser).type.toString()), UnknownNotification() => const SizedBox.shrink(), }; } diff --git a/lib/features/notifications/service/notifications_service.dart b/lib/features/notifications/service/notifications_service.dart index 860aab55..ec2aad74 100644 --- a/lib/features/notifications/service/notifications_service.dart +++ b/lib/features/notifications/service/notifications_service.dart @@ -40,6 +40,11 @@ class NotificationsService { PlanSubscriptionPaidToAuthorNotification.fromJson(notificationJson['data'], type, isRead: readDate != null), NotificationType.chosenPlanFinishedToConsultant => ChosenPlanFinishedToConsultantNotification.fromJson(notificationJson['data'], type, isRead: readDate != null), + NotificationType.chosenPlanLastDayFinishedForUser => ChosenPlanLastDayFinishedForUser.fromJson( + notificationJson['data'], + type, + isRead: readDate != null, + ), NotificationType.unknown => UnknownNotification(type: type), }; } catch (e) {