forked from eatvio/eatvio_app
Compare commits
2 Commits
main
...
feat/notif
| Author | SHA1 | Date | |
|---|---|---|---|
| 280263b419 | |||
| c6915a0d94 |
4
android/.kotlin/errors/errors-1729261970802.log
Normal file
4
android/.kotlin/errors/errors-1729261970802.log
Normal file
@@ -0,0 +1,4 @@
|
||||
kotlin version: 2.0.20
|
||||
error message: The daemon has terminated unexpectedly on startup attempt #1 with error code: 0. The daemon process output:
|
||||
1. Kotlin compile daemon is ready
|
||||
|
||||
4
android/.kotlin/errors/errors-1733227862976.log
Normal file
4
android/.kotlin/errors/errors-1733227862976.log
Normal file
@@ -0,0 +1,4 @@
|
||||
kotlin version: 2.0.21
|
||||
error message: The daemon has terminated unexpectedly on startup attempt #1 with error code: 0. The daemon process output:
|
||||
1. Kotlin compile daemon is ready
|
||||
|
||||
82
android/.kotlin/errors/errors-1737375866289.log
Normal file
82
android/.kotlin/errors/errors-1737375866289.log
Normal file
@@ -0,0 +1,82 @@
|
||||
kotlin version: 2.0.21
|
||||
error message: Daemon compilation failed: null
|
||||
java.lang.Exception
|
||||
at org.jetbrains.kotlin.daemon.common.CompileService$CallResult$Error.get(CompileService.kt:69)
|
||||
at org.jetbrains.kotlin.daemon.common.CompileService$CallResult$Error.get(CompileService.kt:65)
|
||||
at org.jetbrains.kotlin.compilerRunner.GradleKotlinCompilerWork.compileWithDaemon(GradleKotlinCompilerWork.kt:240)
|
||||
at org.jetbrains.kotlin.compilerRunner.GradleKotlinCompilerWork.compileWithDaemonOrFallbackImpl(GradleKotlinCompilerWork.kt:159)
|
||||
at org.jetbrains.kotlin.compilerRunner.GradleKotlinCompilerWork.run(GradleKotlinCompilerWork.kt:111)
|
||||
at org.jetbrains.kotlin.compilerRunner.GradleCompilerRunnerWithWorkers$GradleKotlinCompilerWorkAction.execute(GradleCompilerRunnerWithWorkers.kt:76)
|
||||
at org.gradle.workers.internal.DefaultWorkerServer.execute(DefaultWorkerServer.java:63)
|
||||
at org.gradle.workers.internal.NoIsolationWorkerFactory$1$1.create(NoIsolationWorkerFactory.java:66)
|
||||
at org.gradle.workers.internal.NoIsolationWorkerFactory$1$1.create(NoIsolationWorkerFactory.java:62)
|
||||
at org.gradle.internal.classloader.ClassLoaderUtils.executeInClassloader(ClassLoaderUtils.java:100)
|
||||
at org.gradle.workers.internal.NoIsolationWorkerFactory$1.lambda$execute$0(NoIsolationWorkerFactory.java:62)
|
||||
at org.gradle.workers.internal.AbstractWorker$1.call(AbstractWorker.java:44)
|
||||
at org.gradle.workers.internal.AbstractWorker$1.call(AbstractWorker.java:41)
|
||||
at org.gradle.internal.operations.DefaultBuildOperationRunner$CallableBuildOperationWorker.execute(DefaultBuildOperationRunner.java:209)
|
||||
at org.gradle.internal.operations.DefaultBuildOperationRunner$CallableBuildOperationWorker.execute(DefaultBuildOperationRunner.java:204)
|
||||
at org.gradle.internal.operations.DefaultBuildOperationRunner$2.execute(DefaultBuildOperationRunner.java:66)
|
||||
at org.gradle.internal.operations.DefaultBuildOperationRunner$2.execute(DefaultBuildOperationRunner.java:59)
|
||||
at org.gradle.internal.operations.DefaultBuildOperationRunner.execute(DefaultBuildOperationRunner.java:166)
|
||||
at org.gradle.internal.operations.DefaultBuildOperationRunner.execute(DefaultBuildOperationRunner.java:59)
|
||||
at org.gradle.internal.operations.DefaultBuildOperationRunner.call(DefaultBuildOperationRunner.java:53)
|
||||
at org.gradle.workers.internal.AbstractWorker.executeWrappedInBuildOperation(AbstractWorker.java:41)
|
||||
at org.gradle.workers.internal.NoIsolationWorkerFactory$1.execute(NoIsolationWorkerFactory.java:59)
|
||||
at org.gradle.workers.internal.DefaultWorkerExecutor.lambda$submitWork$0(DefaultWorkerExecutor.java:174)
|
||||
at java.base/java.util.concurrent.FutureTask.run(Unknown Source)
|
||||
at org.gradle.internal.work.DefaultConditionalExecutionQueue$ExecutionRunner.runExecution(DefaultConditionalExecutionQueue.java:194)
|
||||
at org.gradle.internal.work.DefaultConditionalExecutionQueue$ExecutionRunner.access$700(DefaultConditionalExecutionQueue.java:127)
|
||||
at org.gradle.internal.work.DefaultConditionalExecutionQueue$ExecutionRunner$1.run(DefaultConditionalExecutionQueue.java:169)
|
||||
at org.gradle.internal.Factories$1.create(Factories.java:31)
|
||||
at org.gradle.internal.work.DefaultWorkerLeaseService.withLocks(DefaultWorkerLeaseService.java:263)
|
||||
at org.gradle.internal.work.DefaultWorkerLeaseService.runAsWorkerThread(DefaultWorkerLeaseService.java:127)
|
||||
at org.gradle.internal.work.DefaultWorkerLeaseService.runAsWorkerThread(DefaultWorkerLeaseService.java:132)
|
||||
at org.gradle.internal.work.DefaultConditionalExecutionQueue$ExecutionRunner.runBatch(DefaultConditionalExecutionQueue.java:164)
|
||||
at org.gradle.internal.work.DefaultConditionalExecutionQueue$ExecutionRunner.run(DefaultConditionalExecutionQueue.java:133)
|
||||
at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source)
|
||||
at java.base/java.util.concurrent.FutureTask.run(Unknown Source)
|
||||
at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:64)
|
||||
at org.gradle.internal.concurrent.AbstractManagedExecutor$1.run(AbstractManagedExecutor.java:48)
|
||||
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
|
||||
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
|
||||
at java.base/java.lang.Thread.run(Unknown Source)
|
||||
Caused by: java.nio.file.DirectoryNotEmptyException: C:\Users\Alex\AppData\Local\Temp\kotlin-backups16986209765282043117
|
||||
at java.base/sun.nio.fs.WindowsFileSystemProvider.implDelete(Unknown Source)
|
||||
at java.base/sun.nio.fs.AbstractFileSystemProvider.delete(Unknown Source)
|
||||
at java.base/java.nio.file.Files.delete(Unknown Source)
|
||||
at org.jetbrains.kotlin.incremental.RecoverableCompilationTransaction$cleanupStash$2$1$1.invoke(CompilationTransaction.kt:244)
|
||||
at org.jetbrains.kotlin.incremental.RecoverableCompilationTransaction$cleanupStash$2$1$1.invoke(CompilationTransaction.kt:244)
|
||||
at org.jetbrains.kotlin.incremental.RecoverableCompilationTransaction.cleanupStash$lambda$11$lambda$10$lambda$9(CompilationTransaction.kt:244)
|
||||
at java.base/java.util.stream.ForEachOps$ForEachOp$OfRef.accept(Unknown Source)
|
||||
at java.base/java.util.ArrayList.forEach(Unknown Source)
|
||||
at java.base/java.util.stream.SortedOps$RefSortingSink.end(Unknown Source)
|
||||
at java.base/java.util.stream.Sink$ChainedReference.end(Unknown Source)
|
||||
at java.base/java.util.stream.AbstractPipeline.copyInto(Unknown Source)
|
||||
at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(Unknown Source)
|
||||
at java.base/java.util.stream.ForEachOps$ForEachOp.evaluateSequential(Unknown Source)
|
||||
at java.base/java.util.stream.ForEachOps$ForEachOp$OfRef.evaluateSequential(Unknown Source)
|
||||
at java.base/java.util.stream.AbstractPipeline.evaluate(Unknown Source)
|
||||
at java.base/java.util.stream.ReferencePipeline.forEach(Unknown Source)
|
||||
at org.jetbrains.kotlin.incremental.RecoverableCompilationTransaction.cleanupStash(CompilationTransaction.kt:244)
|
||||
at org.jetbrains.kotlin.incremental.RecoverableCompilationTransaction.close(CompilationTransaction.kt:254)
|
||||
at org.jetbrains.kotlin.incremental.IncrementalCompilerRunner.tryCompileIncrementally(IncrementalCompilerRunner.kt:747)
|
||||
at org.jetbrains.kotlin.incremental.IncrementalCompilerRunner.compile(IncrementalCompilerRunner.kt:120)
|
||||
at org.jetbrains.kotlin.daemon.CompileServiceImplBase.execIncrementalCompiler(CompileServiceImpl.kt:675)
|
||||
at org.jetbrains.kotlin.daemon.CompileServiceImplBase.access$execIncrementalCompiler(CompileServiceImpl.kt:92)
|
||||
at org.jetbrains.kotlin.daemon.CompileServiceImpl.compile(CompileServiceImpl.kt:1660)
|
||||
at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(Unknown Source)
|
||||
at java.base/java.lang.reflect.Method.invoke(Unknown Source)
|
||||
at java.rmi/sun.rmi.server.UnicastServerRef.dispatch(Unknown Source)
|
||||
at java.rmi/sun.rmi.transport.Transport$1.run(Unknown Source)
|
||||
at java.rmi/sun.rmi.transport.Transport$1.run(Unknown Source)
|
||||
at java.base/java.security.AccessController.doPrivileged(Unknown Source)
|
||||
at java.rmi/sun.rmi.transport.Transport.serviceCall(Unknown Source)
|
||||
at java.rmi/sun.rmi.transport.tcp.TCPTransport.handleMessages(Unknown Source)
|
||||
at java.rmi/sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0(Unknown Source)
|
||||
at java.rmi/sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.lambda$run$0(Unknown Source)
|
||||
at java.base/java.security.AccessController.doPrivileged(Unknown Source)
|
||||
at java.rmi/sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(Unknown Source)
|
||||
... 3 more
|
||||
|
||||
|
||||
4
android/.kotlin/errors/errors-1740999625028.log
Normal file
4
android/.kotlin/errors/errors-1740999625028.log
Normal file
@@ -0,0 +1,4 @@
|
||||
kotlin version: 2.0.21
|
||||
error message: The daemon has terminated unexpectedly on startup attempt #1 with error code: 0. The daemon process output:
|
||||
1. Kotlin compile daemon is ready
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import 'dart:developer';
|
||||
|
||||
import 'package:dio/dio.dart';
|
||||
import 'package:eatvio_app/core/firebase_api.dart';
|
||||
import 'package:eatvio_app/core/prefs.dart';
|
||||
import 'package:eatvio_app/core/prefs_keys.dart';
|
||||
@@ -10,7 +9,6 @@ import 'package:eatvio_app/core/utils/toasts.dart';
|
||||
import 'package:eatvio_app/features/auth/presentation/bloc/auth_cubit/auth_state.dart';
|
||||
import 'package:eatvio_app/features/auth/repositories/auth_repository.dart';
|
||||
import 'package:eatvio_app/features/profile/repositories/profile_repository.dart';
|
||||
import 'package:eatvio_app/generated/l10n.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:eatvio_app/core/error_reporting/report_from.dart';
|
||||
import 'package:flutter_native_splash/flutter_native_splash.dart';
|
||||
@@ -44,25 +42,6 @@ class AuthCubit extends Cubit<AuthState> {
|
||||
} catch (e, st) {
|
||||
await reportFrom(e, st, this);
|
||||
log(e.toString());
|
||||
if (e is DioException && e.response?.statusCode == 429) {
|
||||
final response = e.response;
|
||||
final data = response?.data;
|
||||
final error = data is Map ? data['error'] : null;
|
||||
final retryAfter =
|
||||
response?.headers.value('retry-after') ??
|
||||
(error is Map ? error['retry_after']?.toString() : null);
|
||||
final serverMessage = error is Map && error['message'] is String
|
||||
? error['message'] as String
|
||||
: data is Map && data['message'] is String
|
||||
? data['message'] as String
|
||||
: null;
|
||||
final message = retryAfter != null && retryAfter.isNotEmpty
|
||||
? S.current.too_many_login_attempts(int.tryParse(retryAfter) ?? 0)
|
||||
: serverMessage ?? S.current.too_many_login_attempts_no_retry;
|
||||
showErrorToast(message);
|
||||
emit(AuthState.error(errorMessage: message));
|
||||
return false;
|
||||
}
|
||||
showErrorToast('Неверный адрес электронной почты или пароль');
|
||||
emit(AuthState.error(errorMessage: '$e'));
|
||||
return false;
|
||||
|
||||
@@ -8,10 +8,7 @@ class ResetPasswordCubit extends Cubit<ResetPasswordState> {
|
||||
|
||||
ResetPasswordCubit({required this.resetPasswordRepository}) : super(const ResetPasswordState.empty());
|
||||
|
||||
String? get errorMessage => resetPasswordRepository.lastError;
|
||||
|
||||
Future<void> trySendEmailCode(String email) async {
|
||||
resetPasswordRepository.clearError();
|
||||
emit(const ResetPasswordState.loadingSendEmailCode());
|
||||
try {
|
||||
if (await resetPasswordRepository.sendEmailCodeForPasswordChange(email)) {
|
||||
@@ -26,7 +23,6 @@ class ResetPasswordCubit extends Cubit<ResetPasswordState> {
|
||||
}
|
||||
|
||||
Future<void> tryResetPassword(String email, String code, String password, String passwordConfirmation) async {
|
||||
resetPasswordRepository.clearError();
|
||||
emit(const ResetPasswordState.loadingResetPassword());
|
||||
try {
|
||||
if (await resetPasswordRepository.confirmPasswordChange(code, password, passwordConfirmation, email)) {
|
||||
|
||||
@@ -108,10 +108,10 @@ class _ForgetPasswordScreenState extends State<ForgetPasswordScreen> {
|
||||
showSuccessToast('Код на почту успешно отправлен');
|
||||
}
|
||||
if (state is ResetPasswordStateCodeSendError) {
|
||||
showErrorToast(context.read<ResetPasswordCubit>().errorMessage ?? 'Ошибка отправки кода. Проверьте правильность ввёдной почты');
|
||||
showErrorToast('Ошибка отправки кода. Проверьте правильность ввёдной почты');
|
||||
}
|
||||
if (state is ResetPasswordStateResetPasswordError) {
|
||||
showErrorToast(context.read<ResetPasswordCubit>().errorMessage ?? 'Ошибка смены пароля. Проверьте правильность ввёднного кода и совпадение пароля');
|
||||
showErrorToast('Ошибка смены пароля. Проверьте правильность ввёднного кода и совпадение пароля');
|
||||
}
|
||||
if (state is ResetPasswordStateResetPassowrdSuccess) {
|
||||
GoRouter.of(context).pop();
|
||||
|
||||
@@ -7,41 +7,6 @@ class ResetPasswordRepository {
|
||||
required this.resetPasswordService,
|
||||
});
|
||||
|
||||
String? _lastError;
|
||||
|
||||
String? get lastError => _lastError;
|
||||
|
||||
void clearError() {
|
||||
_lastError = null;
|
||||
}
|
||||
|
||||
void _readError(dynamic data) {
|
||||
_lastError = null;
|
||||
if (data is! Map) {
|
||||
return;
|
||||
}
|
||||
|
||||
final errors = data['errors'];
|
||||
if (errors is Map) {
|
||||
final passwordErrors = errors['password'];
|
||||
if (passwordErrors is List && passwordErrors.isNotEmpty) {
|
||||
_lastError = passwordErrors.join('\n');
|
||||
return;
|
||||
}
|
||||
for (final value in errors.values) {
|
||||
if (value is List && value.isNotEmpty) {
|
||||
_lastError = value.join('\n');
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
final message = data['message'];
|
||||
if (message is String) {
|
||||
_lastError = message;
|
||||
}
|
||||
}
|
||||
|
||||
Future<bool> sendEmailCodeForPasswordChange(String email) async {
|
||||
final response = await resetPasswordService.sendEmailCodeForPasswordChange(
|
||||
data: {
|
||||
@@ -50,10 +15,8 @@ class ResetPasswordRepository {
|
||||
);
|
||||
int statusCode = response.response.statusCode ?? 0;
|
||||
if (statusCode >= 200 && statusCode < 300) {
|
||||
_lastError = null;
|
||||
return true;
|
||||
} else {
|
||||
_readError(response.response.data);
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -75,10 +38,8 @@ class ResetPasswordRepository {
|
||||
);
|
||||
int statusCode = response.response.statusCode ?? 0;
|
||||
if (statusCode >= 200 && statusCode < 300) {
|
||||
_lastError = null;
|
||||
return true;
|
||||
} else {
|
||||
_readError(response.response.data);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -1011,6 +1011,125 @@ class MealReminderNotification implements BaseNotificationModel {
|
||||
}
|
||||
}
|
||||
|
||||
/// Данные уведомления: в API-ленте лежат во вложенном `data`, а в realtime-событии могут быть в корне.
|
||||
Map<String, dynamic> _notificationData(Map<String, dynamic> json) {
|
||||
final data = json['data'];
|
||||
return data is Map<String, dynamic> ? data : json;
|
||||
}
|
||||
|
||||
DateTime? parseOptionalDate(dynamic value) {
|
||||
if (value == null) {
|
||||
return null;
|
||||
}
|
||||
final raw = value.toString();
|
||||
if (raw.isEmpty) {
|
||||
return null;
|
||||
}
|
||||
return DateTime.tryParse(raw)?.toLocal();
|
||||
}
|
||||
|
||||
class ClientPlanPaymentRequiredNotification implements BaseNotificationModel {
|
||||
@override
|
||||
final NotificationType type;
|
||||
@override
|
||||
final bool isRead;
|
||||
final String planName;
|
||||
final int planId;
|
||||
final String authorName;
|
||||
final int authorId;
|
||||
final String authorPhotoPath;
|
||||
final String chatId;
|
||||
final String chatUrl;
|
||||
final DateTime? startDate;
|
||||
final DateTime? paymentDeadlineAt;
|
||||
@override
|
||||
final DateTime createdAt;
|
||||
|
||||
ClientPlanPaymentRequiredNotification({
|
||||
required this.type,
|
||||
required this.isRead,
|
||||
required this.planName,
|
||||
required this.planId,
|
||||
required this.authorName,
|
||||
required this.authorId,
|
||||
required this.authorPhotoPath,
|
||||
required this.chatId,
|
||||
required this.chatUrl,
|
||||
required this.startDate,
|
||||
required this.paymentDeadlineAt,
|
||||
required this.createdAt,
|
||||
});
|
||||
|
||||
factory ClientPlanPaymentRequiredNotification.fromJson(Map<String, dynamic> json, NotificationType type, {bool? isRead, String? createdAt}) {
|
||||
final data = _notificationData(json);
|
||||
return ClientPlanPaymentRequiredNotification(
|
||||
type: type,
|
||||
isRead: isRead ?? false,
|
||||
planName: data['plan_name'] ?? '',
|
||||
planId: data['plan_id'] ?? 0,
|
||||
authorName: data['author_name'] ?? '',
|
||||
authorId: data['author_id'] ?? 0,
|
||||
authorPhotoPath: data['author_photo_path'] ?? '',
|
||||
chatId: data['chat_id'] ?? '',
|
||||
chatUrl: data['chat_url'] ?? '',
|
||||
startDate: parseOptionalDate(data['start_date']),
|
||||
paymentDeadlineAt: parseOptionalDate(data['payment_deadline_at']),
|
||||
createdAt: parseDate(createdAt ?? json['created_at'] ?? data['created_at'] ?? DateTime.now().toIso8601String()),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class ConsultantPlanStartDateSetNotification implements BaseNotificationModel {
|
||||
@override
|
||||
final NotificationType type;
|
||||
@override
|
||||
final bool isRead;
|
||||
final String planName;
|
||||
final int planId;
|
||||
final String clientName;
|
||||
final int userId;
|
||||
final String userPhotoPath;
|
||||
final String chatId;
|
||||
final String chatUrl;
|
||||
final DateTime? startDate;
|
||||
final DateTime? paymentDeadlineAt;
|
||||
@override
|
||||
final DateTime createdAt;
|
||||
|
||||
ConsultantPlanStartDateSetNotification({
|
||||
required this.type,
|
||||
required this.isRead,
|
||||
required this.planName,
|
||||
required this.planId,
|
||||
required this.clientName,
|
||||
required this.userId,
|
||||
required this.userPhotoPath,
|
||||
required this.chatId,
|
||||
required this.chatUrl,
|
||||
required this.startDate,
|
||||
required this.paymentDeadlineAt,
|
||||
required this.createdAt,
|
||||
});
|
||||
|
||||
factory ConsultantPlanStartDateSetNotification.fromJson(Map<String, dynamic> json, NotificationType type, {bool? isRead, String? createdAt}) {
|
||||
final data = _notificationData(json);
|
||||
return ConsultantPlanStartDateSetNotification(
|
||||
type: type,
|
||||
isRead: isRead ?? false,
|
||||
planName: data['plan_name'] ?? '',
|
||||
planId: data['plan_id'] ?? 0,
|
||||
clientName: data['user_name'] ?? '',
|
||||
userId: data['user_id'] ?? 0,
|
||||
userPhotoPath: data['user_photo_path'] ?? '',
|
||||
chatId: data['chat_id'] ?? '',
|
||||
chatUrl: data['chat_url'] ?? '',
|
||||
startDate: parseOptionalDate(data['start_date']),
|
||||
paymentDeadlineAt: parseOptionalDate(data['payment_deadline_at']),
|
||||
createdAt: parseDate(createdAt ?? json['created_at'] ?? data['created_at'] ?? DateTime.now().toIso8601String()),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class UnknownNotification implements BaseNotificationModel {
|
||||
@override
|
||||
final NotificationType type;
|
||||
@@ -2526,6 +2645,8 @@ enum NotificationType {
|
||||
clientStartPlanSubscriptionToAuthor,
|
||||
clientCancelPlanSubscriptionToAuthor,
|
||||
clientCancelPlanSubscriptionToSubscriber,
|
||||
clientPlanPaymentRequired,
|
||||
consultantPlanStartDateSet,
|
||||
userDailyReportCompleted,
|
||||
chosenPlanFinishedToConsultant,
|
||||
stayOnTrackToCustomer,
|
||||
@@ -2648,6 +2769,8 @@ enum NotificationType {
|
||||
'client-start-plan-subscription-to-author' => NotificationType.clientStartPlanSubscriptionToAuthor,
|
||||
'client-cancel-plan-subscription-to-author' => NotificationType.clientCancelPlanSubscriptionToAuthor,
|
||||
'client-cancel-plan-subscription-to-subscriber' => NotificationType.clientCancelPlanSubscriptionToSubscriber,
|
||||
'client-plan-payment-required' => NotificationType.clientPlanPaymentRequired,
|
||||
'consultant-plan-start-date-set' => NotificationType.consultantPlanStartDateSet,
|
||||
'user-daily-report-completed' => NotificationType.userDailyReportCompleted,
|
||||
'chosen-plan-finished-to-consultant' => NotificationType.chosenPlanFinishedToConsultant,
|
||||
'stay-on-track-to-customer' => NotificationType.stayOnTrackToCustomer,
|
||||
|
||||
@@ -355,6 +355,18 @@ class NotificationsCubit extends Cubit<NotificationsState> {
|
||||
isRead: isRead,
|
||||
createdAt: createdAt,
|
||||
),
|
||||
NotificationType.clientPlanPaymentRequired => ClientPlanPaymentRequiredNotification.fromJson(
|
||||
notificationJson,
|
||||
type,
|
||||
isRead: isRead,
|
||||
createdAt: createdAt,
|
||||
),
|
||||
NotificationType.consultantPlanStartDateSet => ConsultantPlanStartDateSetNotification.fromJson(
|
||||
notificationJson,
|
||||
type,
|
||||
isRead: isRead,
|
||||
createdAt: createdAt,
|
||||
),
|
||||
NotificationType.unknown => UnknownNotification(type: type, createdAt: parseDate(createdAt ?? jsonEncode(notificationJson))),
|
||||
};
|
||||
} catch (e, st) {
|
||||
|
||||
@@ -137,11 +137,54 @@ class NotificationWidget extends StatelessWidget {
|
||||
CommentComplaintNotification() => _CommentComplaintWidget(notification: notification as CommentComplaintNotification),
|
||||
CommentDeletedNotification() => _CommentDeletedWidget(notification: notification as CommentDeletedNotification),
|
||||
UserSubscribedNotification() => _UserSubscribedWidget(notification: notification as UserSubscribedNotification),
|
||||
ClientPlanPaymentRequiredNotification() => _ClientPlanPaymentRequiredWidget(
|
||||
notification: notification as ClientPlanPaymentRequiredNotification,
|
||||
),
|
||||
ConsultantPlanStartDateSetNotification() => _ConsultantPlanStartDateSetWidget(
|
||||
notification: notification as ConsultantPlanStartDateSetNotification,
|
||||
),
|
||||
UnknownNotification() => const SizedBox.shrink(),
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
VoidCallback? _chatTap(BuildContext context, String chatUrl) {
|
||||
final uri = Uri.tryParse(chatUrl);
|
||||
final uuid = (uri != null && uri.pathSegments.isNotEmpty) ? uri.pathSegments.last : '';
|
||||
if (uuid.isEmpty) {
|
||||
return null;
|
||||
}
|
||||
return () => context.push('${RouteConstants.chatScreen}?uuid=$uuid');
|
||||
}
|
||||
|
||||
class _ClientPlanPaymentRequiredWidget extends StatelessWidget {
|
||||
const _ClientPlanPaymentRequiredWidget({required this.notification});
|
||||
final ClientPlanPaymentRequiredNotification notification;
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return _BaseNotificationWidget(
|
||||
isRead: notification.isRead,
|
||||
notificationsText: 'Необходимо оплатить консультацию «${notification.planName}» у консультанта ${notification.authorName}',
|
||||
createdAt: notification.createdAt,
|
||||
onTap: _chatTap(context, notification.chatUrl),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class _ConsultantPlanStartDateSetWidget extends StatelessWidget {
|
||||
const _ConsultantPlanStartDateSetWidget({required this.notification});
|
||||
final ConsultantPlanStartDateSetNotification notification;
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return _BaseNotificationWidget(
|
||||
isRead: notification.isRead,
|
||||
notificationsText: 'Дата старта установлена: «${notification.planName}». Клиент ${notification.clientName} ещё не оплатил',
|
||||
createdAt: notification.createdAt,
|
||||
onTap: _chatTap(context, notification.chatUrl),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
void _navigateToBottomNavRoute(BuildContext context, String path, [Object? extra]) {
|
||||
final controller = BottomNavScope.maybeOf(context);
|
||||
if (controller != null) {
|
||||
|
||||
@@ -495,6 +495,18 @@ class NotificationsService {
|
||||
isRead: readDate != null,
|
||||
createdAt: createdAt,
|
||||
),
|
||||
NotificationType.clientPlanPaymentRequired => ClientPlanPaymentRequiredNotification.fromJson(
|
||||
(notificationJson['data'] as Map<String, dynamic>?) ?? notificationJson,
|
||||
type,
|
||||
isRead: readDate != null,
|
||||
createdAt: createdAt,
|
||||
),
|
||||
NotificationType.consultantPlanStartDateSet => ConsultantPlanStartDateSetNotification.fromJson(
|
||||
(notificationJson['data'] as Map<String, dynamic>?) ?? notificationJson,
|
||||
type,
|
||||
isRead: readDate != null,
|
||||
createdAt: createdAt,
|
||||
),
|
||||
NotificationType.unknown => UnknownNotification(type: type, createdAt: parseDate(createdAt)),
|
||||
};
|
||||
} catch (error, stackTrace) {
|
||||
|
||||
@@ -53,9 +53,7 @@ class _CredentialsScreenState extends State<CredentialsScreen> {
|
||||
textInputAction: TextInputAction.next,
|
||||
onChanged: (newValue) {
|
||||
final registrationCubit = context.read<RegistrationCubit>();
|
||||
registrationCubit.updateSheet(
|
||||
registrationCubit.state.sheet.copyWith(email: newValue),
|
||||
);
|
||||
registrationCubit.updateSheet(registrationCubit.state.sheet.copyWith(email: newValue));
|
||||
},
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
@@ -73,24 +71,15 @@ class _CredentialsScreenState extends State<CredentialsScreen> {
|
||||
});
|
||||
},
|
||||
icon: Icon(
|
||||
hidePassword
|
||||
? Icons.visibility_outlined
|
||||
: Icons.visibility_off_outlined,
|
||||
hidePassword ? Icons.visibility_outlined : Icons.visibility_off_outlined,
|
||||
color: Colors.grey,
|
||||
),
|
||||
),
|
||||
onChanged: (newValue) {
|
||||
final registrationCubit = context.read<RegistrationCubit>();
|
||||
registrationCubit.updateSheet(
|
||||
registrationCubit.state.sheet.copyWith(password: newValue),
|
||||
);
|
||||
registrationCubit.updateSheet(registrationCubit.state.sheet.copyWith(password: newValue));
|
||||
},
|
||||
),
|
||||
const SizedBox(height: 4),
|
||||
Text(
|
||||
s.password_hint,
|
||||
style: const TextStyle(fontSize: 12, color: Colors.grey),
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
Text(s.password_confirmation),
|
||||
const SizedBox(height: 4),
|
||||
@@ -106,19 +95,13 @@ class _CredentialsScreenState extends State<CredentialsScreen> {
|
||||
});
|
||||
},
|
||||
icon: Icon(
|
||||
hidePassword
|
||||
? Icons.visibility_outlined
|
||||
: Icons.visibility_off_outlined,
|
||||
hidePassword ? Icons.visibility_outlined : Icons.visibility_off_outlined,
|
||||
color: Colors.grey,
|
||||
),
|
||||
),
|
||||
onChanged: (newValue) {
|
||||
final registrationCubit = context.read<RegistrationCubit>();
|
||||
registrationCubit.updateSheet(
|
||||
registrationCubit.state.sheet.copyWith(
|
||||
passwordConfirmation: newValue,
|
||||
),
|
||||
);
|
||||
registrationCubit.updateSheet(registrationCubit.state.sheet.copyWith(passwordConfirmation: newValue));
|
||||
},
|
||||
),
|
||||
],
|
||||
|
||||
@@ -353,7 +353,7 @@ class _RegistrationScreenState extends State<RegistrationScreen> {
|
||||
errors.add(s.email_empty);
|
||||
}
|
||||
|
||||
if (password.length < 8) {
|
||||
if (password.length < 6) {
|
||||
errors.add(s.password_short);
|
||||
}
|
||||
|
||||
|
||||
@@ -272,12 +272,6 @@ class RegistrationCubitV2 extends Cubit<RegistrationStateV2> {
|
||||
}
|
||||
}
|
||||
}
|
||||
final passwordErrors = errors?['password'] as List<dynamic>?;
|
||||
if (passwordErrors != null && passwordErrors.isNotEmpty) {
|
||||
for (var error in passwordErrors) {
|
||||
allErrors.add(error.toString());
|
||||
}
|
||||
}
|
||||
|
||||
// Сохраняем все ошибки для отображения в диалоге
|
||||
if (allErrors.isNotEmpty) {
|
||||
|
||||
@@ -529,46 +529,16 @@ class S {
|
||||
);
|
||||
}
|
||||
|
||||
/// `В пароле должно быть минимум 8 символов`
|
||||
/// `В пароле должно быть минимум 6 символов`
|
||||
String get password_short {
|
||||
return Intl.message(
|
||||
'В пароле должно быть минимум 8 символов',
|
||||
'В пароле должно быть минимум 6 символов',
|
||||
name: 'password_short',
|
||||
desc: '',
|
||||
args: [],
|
||||
);
|
||||
}
|
||||
|
||||
/// `At least 8 characters, avoid common passwords`
|
||||
String get password_hint {
|
||||
return Intl.message(
|
||||
'At least 8 characters, avoid common passwords',
|
||||
name: 'password_hint',
|
||||
desc: '',
|
||||
args: [],
|
||||
);
|
||||
}
|
||||
|
||||
/// `Too many login attempts. Try again in {seconds} sec.`
|
||||
String too_many_login_attempts(int seconds) {
|
||||
return Intl.message(
|
||||
'Too many login attempts. Try again in $seconds sec.',
|
||||
name: 'too_many_login_attempts',
|
||||
desc: '',
|
||||
args: [seconds],
|
||||
);
|
||||
}
|
||||
|
||||
/// `Too many login attempts. Please try again later.`
|
||||
String get too_many_login_attempts_no_retry {
|
||||
return Intl.message(
|
||||
'Too many login attempts. Please try again later.',
|
||||
name: 'too_many_login_attempts_no_retry',
|
||||
desc: '',
|
||||
args: [],
|
||||
);
|
||||
}
|
||||
|
||||
/// `Имя пользователя обязательно для заполнения`
|
||||
String get name_empty {
|
||||
return Intl.message(
|
||||
|
||||
@@ -55,17 +55,7 @@
|
||||
"email_empty": "Необходимо ввести адрес электронной почты",
|
||||
"email_invalid": "Некорректный адрес электронной почты",
|
||||
"password_empty": "Пароль обязателен для заполнения",
|
||||
"password_short": "В пароле должно быть минимум 8 символов",
|
||||
"password_hint": "At least 8 characters, avoid common passwords",
|
||||
"too_many_login_attempts": "Too many login attempts. Try again in {seconds} sec.",
|
||||
"@too_many_login_attempts": {
|
||||
"placeholders": {
|
||||
"seconds": {
|
||||
"type": "int"
|
||||
}
|
||||
}
|
||||
},
|
||||
"too_many_login_attempts_no_retry": "Too many login attempts. Please try again later.",
|
||||
"password_short": "В пароле должно быть минимум 6 символов",
|
||||
"name_empty": "Имя пользователя обязательно для заполнения",
|
||||
"name_short": "В имени пользователя должно быть минимум 6 символов",
|
||||
"password_confirmation_mismatch": "Пароли не совпадают",
|
||||
|
||||
@@ -55,17 +55,7 @@
|
||||
"email_empty": "Необходимо ввести адрес электронной почты",
|
||||
"email_invalid": "Некорректный адрес электронной почты",
|
||||
"password_empty": "Пароль обязателен для заполнения",
|
||||
"password_short": "В пароле должно быть минимум 8 символов",
|
||||
"password_hint": "Минимум 8 символов, не используйте распространённые пароли",
|
||||
"too_many_login_attempts": "Слишком много попыток входа. Повторите через {seconds} сек.",
|
||||
"@too_many_login_attempts": {
|
||||
"placeholders": {
|
||||
"seconds": {
|
||||
"type": "int"
|
||||
}
|
||||
}
|
||||
},
|
||||
"too_many_login_attempts_no_retry": "Слишком много попыток входа. Попробуйте позже.",
|
||||
"password_short": "В пароле должно быть минимум 6 символов",
|
||||
"name_empty": "Имя пользователя обязательно для заполнения",
|
||||
"name_short": "В имени пользователя должно быть минимум 6 символов",
|
||||
"password_confirmation_mismatch": "Пароли не совпадают",
|
||||
|
||||
@@ -1,88 +0,0 @@
|
||||
import 'dart:ui';
|
||||
|
||||
import 'package:dio/dio.dart';
|
||||
import 'package:eatvio_app/core/firebase_api.dart';
|
||||
import 'package:eatvio_app/core/prefs.dart';
|
||||
import 'package:eatvio_app/core/session/session_lifecycle_service.dart';
|
||||
import 'package:eatvio_app/features/auth/presentation/bloc/auth_cubit/auth_cubit.dart';
|
||||
import 'package:eatvio_app/features/auth/presentation/bloc/auth_cubit/auth_state.dart';
|
||||
import 'package:eatvio_app/features/auth/repositories/auth_repository.dart';
|
||||
import 'package:eatvio_app/features/profile/repositories/profile_repository.dart';
|
||||
import 'package:eatvio_app/generated/l10n.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:mocktail/mocktail.dart';
|
||||
|
||||
class _MockAuthRepository extends Mock implements AuthRepository {}
|
||||
|
||||
class _MockPrefs extends Mock implements Prefs {}
|
||||
|
||||
class _MockProfileRepository extends Mock implements ProfileRepository {}
|
||||
|
||||
class _MockFirebaseApi extends Mock implements FirebaseApi {}
|
||||
|
||||
class _MockSessionLifecycleService extends Mock
|
||||
implements SessionLifecycleService {}
|
||||
|
||||
void main() {
|
||||
TestWidgetsFlutterBinding.ensureInitialized();
|
||||
|
||||
const toastChannel = MethodChannel('PonnamKarthik/fluttertoast');
|
||||
|
||||
setUpAll(() async {
|
||||
await S.delegate.load(const Locale('ru'));
|
||||
TestDefaultBinaryMessengerBinding.instance.defaultBinaryMessenger
|
||||
.setMockMethodCallHandler(toastChannel, (call) async => true);
|
||||
});
|
||||
|
||||
test('AuthCubit maps 429 Retry-After to localized message', () async {
|
||||
final request = RequestOptions(path: '/api/login');
|
||||
final response = Response(
|
||||
requestOptions: request,
|
||||
statusCode: 429,
|
||||
headers: Headers.fromMap({
|
||||
'retry-after': ['55'],
|
||||
}),
|
||||
data: {
|
||||
'message': 'Слишком много неудачных попыток.',
|
||||
'error': {
|
||||
'code': 'too_many_login_attempts',
|
||||
'retry_after': 55,
|
||||
},
|
||||
},
|
||||
);
|
||||
final exception = DioException(
|
||||
requestOptions: request,
|
||||
response: response,
|
||||
type: DioExceptionType.badResponse,
|
||||
);
|
||||
|
||||
final repository = _MockAuthRepository();
|
||||
when(
|
||||
() => repository.getTokenByCredentials(
|
||||
'browser.check@example.com',
|
||||
'wrong-password',
|
||||
),
|
||||
).thenThrow(exception);
|
||||
|
||||
final cubit = AuthCubit(
|
||||
authRepository: repository,
|
||||
prefs: _MockPrefs(),
|
||||
profileRepository: _MockProfileRepository(),
|
||||
firebaseApi: _MockFirebaseApi(),
|
||||
sessionLifecycleService: _MockSessionLifecycleService(),
|
||||
);
|
||||
|
||||
final result = await cubit.getTokenByCredentials(
|
||||
'browser.check@example.com',
|
||||
'wrong-password',
|
||||
);
|
||||
|
||||
expect(result, isFalse);
|
||||
expect(cubit.state, isA<AuthStateError>());
|
||||
expect(
|
||||
(cubit.state as AuthStateError).errorMessage,
|
||||
contains('Повторите через 55 сек.'),
|
||||
);
|
||||
});
|
||||
}
|
||||
@@ -63,6 +63,8 @@ void main() {
|
||||
ScoreAdded.fromJson(scoreLike, NotificationType.scoreAdded);
|
||||
ScoreSubstractedNotification.fromJson(scoreLike, NotificationType.scoreSubstracted);
|
||||
EntityCommented.fromJson(entityCommented, NotificationType.entityCommented);
|
||||
ClientPlanPaymentRequiredNotification.fromJson(base, NotificationType.clientPlanPaymentRequired);
|
||||
ConsultantPlanStartDateSetNotification.fromJson(base, NotificationType.consultantPlanStartDateSet);
|
||||
UnknownNotification.fromJson(base, NotificationType.unknown);
|
||||
|
||||
ConsultantConfirmPlanSubscriptionToSubscriberNotification.fromJson(
|
||||
|
||||
@@ -51,6 +51,8 @@ void main() {
|
||||
'diary-reminder-for-users': NotificationType.diaryReminderForUsers,
|
||||
'personal-diet-is-defined-to-customer': NotificationType.personalDietIsDefinedToCustomer,
|
||||
'personal-diet-is-defined-to-author': NotificationType.personalDietIsDefinedToAuthor,
|
||||
'client-plan-payment-required': NotificationType.clientPlanPaymentRequired,
|
||||
'consultant-plan-start-date-set': NotificationType.consultantPlanStartDateSet,
|
||||
};
|
||||
|
||||
cases.forEach((key, expected) {
|
||||
|
||||
@@ -1654,6 +1654,100 @@ void main() {
|
||||
expect(result!['notifications'], isA<List>());
|
||||
expect(result['notifications'].length, 1);
|
||||
});
|
||||
|
||||
test('getNotifications - распознаёт client-plan-payment-required', () async {
|
||||
const page = 1;
|
||||
final response = Response(
|
||||
data: {
|
||||
'data': [
|
||||
{
|
||||
'type': 'client-plan-payment-required',
|
||||
'data': {
|
||||
'plan_name': 'План 3054',
|
||||
'plan_id': 101,
|
||||
'author_name': 'Консультант',
|
||||
'author_id': 7,
|
||||
'author_photo_path': '/storage/a.jpg',
|
||||
'chat_id': 'uuid-101',
|
||||
'chat_url': 'https://eatvio.ru/ru/chat/uuid-101',
|
||||
'start_date': '2026-11-27T00:00:00+03:00',
|
||||
'payment_deadline_at': '2026-11-26T12:00:00+03:00',
|
||||
},
|
||||
'read_at': null,
|
||||
'created_at': '2026-11-24T10:00:00Z',
|
||||
},
|
||||
],
|
||||
'current_page': 1,
|
||||
'last_page': 1,
|
||||
'per_page': 10,
|
||||
'total': 1,
|
||||
},
|
||||
statusCode: 200,
|
||||
requestOptions: RequestOptions(path: '/api/profile/notifications'),
|
||||
);
|
||||
|
||||
when(mockDio.get(any)).thenAnswer((_) async => response);
|
||||
|
||||
final result = await notificationsService.getNotifications(page: page);
|
||||
final notifications = result!['notifications'] as List<BaseNotificationModel>;
|
||||
final notification = notifications.single;
|
||||
|
||||
expect(notification, isA<ClientPlanPaymentRequiredNotification>());
|
||||
expect(notification.type, NotificationType.clientPlanPaymentRequired);
|
||||
expect(notification.isRead, isFalse);
|
||||
final clientNotification = notification as ClientPlanPaymentRequiredNotification;
|
||||
expect(clientNotification.planName, 'План 3054');
|
||||
expect(clientNotification.authorName, 'Консультант');
|
||||
expect(clientNotification.chatUrl, 'https://eatvio.ru/ru/chat/uuid-101');
|
||||
expect(clientNotification.paymentDeadlineAt, isNotNull);
|
||||
});
|
||||
|
||||
test('getNotifications - распознаёт consultant-plan-start-date-set', () async {
|
||||
const page = 1;
|
||||
final response = Response(
|
||||
data: {
|
||||
'data': [
|
||||
{
|
||||
'type': 'consultant-plan-start-date-set',
|
||||
'data': {
|
||||
'plan_name': 'План 3054',
|
||||
'plan_id': 102,
|
||||
'user_name': 'Клиент',
|
||||
'user_id': 8,
|
||||
'user_photo_path': '/storage/c.jpg',
|
||||
'chat_id': 'uuid-102',
|
||||
'chat_url': 'https://eatvio.ru/ru/chat/uuid-102',
|
||||
'start_date': '2026-11-27T00:00:00+03:00',
|
||||
'payment_deadline_at': null,
|
||||
},
|
||||
'read_at': '2026-11-24T11:00:00Z',
|
||||
'created_at': '2026-11-24T10:00:00Z',
|
||||
},
|
||||
],
|
||||
'current_page': 1,
|
||||
'last_page': 1,
|
||||
'per_page': 10,
|
||||
'total': 1,
|
||||
},
|
||||
statusCode: 200,
|
||||
requestOptions: RequestOptions(path: '/api/profile/notifications'),
|
||||
);
|
||||
|
||||
when(mockDio.get(any)).thenAnswer((_) async => response);
|
||||
|
||||
final result = await notificationsService.getNotifications(page: page);
|
||||
final notifications = result!['notifications'] as List<BaseNotificationModel>;
|
||||
final notification = notifications.single;
|
||||
|
||||
expect(notification, isA<ConsultantPlanStartDateSetNotification>());
|
||||
expect(notification.type, NotificationType.consultantPlanStartDateSet);
|
||||
expect(notification.isRead, isTrue);
|
||||
final consultantNotification = notification as ConsultantPlanStartDateSetNotification;
|
||||
expect(consultantNotification.planName, 'План 3054');
|
||||
expect(consultantNotification.clientName, 'Клиент');
|
||||
expect(consultantNotification.chatUrl, 'https://eatvio.ru/ru/chat/uuid-102');
|
||||
expect(consultantNotification.paymentDeadlineAt, isNull);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user