From cacfaff4cfe42f148f105c59f28bb9fd12555406 Mon Sep 17 00:00:00 2001 From: mso7nueh Date: Wed, 4 Jun 2025 15:26:34 +0300 Subject: [PATCH] fix: email verify + consultant registration --- ios/Runner.xcodeproj/project.pbxproj | 6 +- ios/Runner/Info.plist | 2 +- lib/core/app_router.dart | 21 ++--- .../models/consultation_request_model.dart | 2 +- .../register_consultant_cubit.dart | 8 +- .../stepper_become_consultant_screen.dart | 14 ++-- .../profile/models/profile_model.dart | 3 +- .../bloc/profile_cubit/profile_cubit.dart | 1 + .../presentation/pages/profile_screen.dart | 79 ++++++++++--------- .../registration_cubit.dart | 1 - .../pages/verify_email_screen.dart | 9 ++- .../presentation/pages/settings_screen.dart | 6 +- pubspec.yaml | 2 +- 13 files changed, 87 insertions(+), 67 deletions(-) diff --git a/ios/Runner.xcodeproj/project.pbxproj b/ios/Runner.xcodeproj/project.pbxproj index c580f377..2ee97ce4 100644 --- a/ios/Runner.xcodeproj/project.pbxproj +++ b/ios/Runner.xcodeproj/project.pbxproj @@ -388,7 +388,7 @@ CODE_SIGN_ENTITLEMENTS = Runner/Runner.entitlements; CODE_SIGN_IDENTITY = "Apple Distribution: ITVIO, OOO (VL68C36HYS)"; CODE_SIGN_STYLE = Manual; - CURRENT_PROJECT_VERSION = 23; + CURRENT_PROJECT_VERSION = 24; DEVELOPMENT_TEAM = VL68C36HYS; ENABLE_BITCODE = NO; FRAMEWORK_SEARCH_PATHS = ( @@ -538,7 +538,7 @@ CODE_SIGN_ENTITLEMENTS = Runner/Runner.entitlements; CODE_SIGN_IDENTITY = "Apple Distribution: ITVIO, OOO (VL68C36HYS)"; CODE_SIGN_STYLE = Manual; - CURRENT_PROJECT_VERSION = 23; + CURRENT_PROJECT_VERSION = 24; DEVELOPMENT_TEAM = VL68C36HYS; ENABLE_BITCODE = NO; FRAMEWORK_SEARCH_PATHS = ( @@ -576,7 +576,7 @@ CODE_SIGN_ENTITLEMENTS = Runner/Runner.entitlements; CODE_SIGN_IDENTITY = "Apple Distribution: ITVIO, OOO (VL68C36HYS)"; CODE_SIGN_STYLE = Manual; - CURRENT_PROJECT_VERSION = 23; + CURRENT_PROJECT_VERSION = 24; DEVELOPMENT_TEAM = VL68C36HYS; ENABLE_BITCODE = NO; FRAMEWORK_SEARCH_PATHS = ( diff --git a/ios/Runner/Info.plist b/ios/Runner/Info.plist index c661f4f7..a88158e2 100644 --- a/ios/Runner/Info.plist +++ b/ios/Runner/Info.plist @@ -21,7 +21,7 @@ CFBundleSignature ???? CFBundleVersion - 23 + 24 ITSAppUsesNonExemptEncryption LSRequiresIPhoneOS diff --git a/lib/core/app_router.dart b/lib/core/app_router.dart index c1d3b23d..32358505 100644 --- a/lib/core/app_router.dart +++ b/lib/core/app_router.dart @@ -100,9 +100,6 @@ class AppRouter { GoRoute( path: '/my-profile-screen', name: 'myProfileScreen', - redirect: (context, state) async { - return null; - }, pageBuilder: (context, state) { return const NoTransitionPage(child: ProfileScreen()); }, @@ -112,15 +109,21 @@ class AppRouter { name: 'feedScreen', pageBuilder: (context, state) => const NoTransitionPage(child: FeedScreen()), redirect: (context, state) async { - final data = state.extra as Map?; - if (data?['needToInitializeWebSocket'] == false) { - return null; + try { + await sl().initialize(); + } catch (e) { + rethrow; } - await sl().initialize(); - return null; + return '/feed-screen'; }, ), - GoRoute(path: '/diary-screen', name: 'diaryScreen', pageBuilder: (context, state) => const NoTransitionPage(child: DiaryScreen())), + GoRoute( + path: '/diary-screen', + name: 'diaryScreen', + pageBuilder: (context, state) => const NoTransitionPage( + child: DiaryScreen(), + ), + ), GoRoute( path: ConsultationsScreen.path, name: ConsultationsScreen.name, diff --git a/lib/features/consultant/become_consultant/models/consultation_request_model.dart b/lib/features/consultant/become_consultant/models/consultation_request_model.dart index 68549759..13cc0e77 100644 --- a/lib/features/consultant/become_consultant/models/consultation_request_model.dart +++ b/lib/features/consultant/become_consultant/models/consultation_request_model.dart @@ -11,7 +11,7 @@ abstract class ConsultationRequestModel with _$ConsultationRequestModel { @JsonKey(name: 'rating_place') int? ratingPlace, @JsonKey(name: 'education_resource') required EducationModel educationModel, @JsonKey(name: 'cert_photos') required List photos, - @JsonKey(name: 'canceled_moderation') required CanceledModerationModel canceledModeration, + @JsonKey(name: 'canceled_moderation') CanceledModerationModel? canceledModeration, }) = _ConsultationRequestModel; factory ConsultationRequestModel.fromJson(Map json) => _$ConsultationRequestModelFromJson(json); diff --git a/lib/features/consultant/become_consultant/presentation/bloc/register_consultant_cubit/register_consultant_cubit.dart b/lib/features/consultant/become_consultant/presentation/bloc/register_consultant_cubit/register_consultant_cubit.dart index 2eb9f373..05bfd52a 100644 --- a/lib/features/consultant/become_consultant/presentation/bloc/register_consultant_cubit/register_consultant_cubit.dart +++ b/lib/features/consultant/become_consultant/presentation/bloc/register_consultant_cubit/register_consultant_cubit.dart @@ -86,7 +86,13 @@ class RegisterConsultantCubit extends Cubit { } updateConsultantProfileModel(ConsultantProfileModel consultant, [bool acceptOffer = false]) { - emit(RegisterConsultantState(consultant: consultant, acceptOffer: acceptOffer, loading: false)); + emit( + state.copyWith( + consultant: consultant, + acceptOffer: acceptOffer, + loading: false, + ), + ); } registerConsultant() async { diff --git a/lib/features/consultant/become_consultant/presentation/pages/stepper_become_consultant_screen.dart b/lib/features/consultant/become_consultant/presentation/pages/stepper_become_consultant_screen.dart index a365c1fc..494ffc36 100644 --- a/lib/features/consultant/become_consultant/presentation/pages/stepper_become_consultant_screen.dart +++ b/lib/features/consultant/become_consultant/presentation/pages/stepper_become_consultant_screen.dart @@ -81,19 +81,19 @@ class _StepperBecomeConsultantScreenState extends State AlertDialog( - title: Text(state.requestModel!.canceledModeration.title), + title: Text(state.requestModel!.canceledModeration!.title), content: Column( crossAxisAlignment: CrossAxisAlignment.start, mainAxisSize: MainAxisSize.min, children: [ - for (int i = 0; i < state.requestModel!.canceledModeration.additional!.length; i++) ...[ - Text('• ${state.requestModel!.canceledModeration.additional![i]}'), + for (int i = 0; i < state.requestModel!.canceledModeration!.additional!.length; i++) ...[ + Text('• ${state.requestModel!.canceledModeration!.additional![i]}'), ] ], ), @@ -129,7 +129,7 @@ class _StepperBecomeConsultantScreenState extends State json) => _$EducationModelFromJson(json); diff --git a/lib/features/profile/presentation/bloc/profile_cubit/profile_cubit.dart b/lib/features/profile/presentation/bloc/profile_cubit/profile_cubit.dart index cdbab793..28f654f2 100644 --- a/lib/features/profile/presentation/bloc/profile_cubit/profile_cubit.dart +++ b/lib/features/profile/presentation/bloc/profile_cubit/profile_cubit.dart @@ -33,6 +33,7 @@ class ProfileCubit extends Cubit { ); } catch (e) { emit(ProfileState.error(errorMessage: e.toString())); + rethrow; } } diff --git a/lib/features/profile/presentation/pages/profile_screen.dart b/lib/features/profile/presentation/pages/profile_screen.dart index a09ff174..ef9aac1a 100644 --- a/lib/features/profile/presentation/pages/profile_screen.dart +++ b/lib/features/profile/presentation/pages/profile_screen.dart @@ -93,12 +93,15 @@ class _ProfileScreenState extends State { } return widget.author == null || widget.author!.authorIsMe ? _myProfileScreen(state) : _profileScreen(state); } else if (state is ProfileStateError) { - return DataErrorWidget( - onReload: () async { - widget.author == null || widget.author!.authorIsMe - ? await profileCubit.getMyProfile() - : await profileCubit.getProfileBySlug(widget.author!.authorSlug); - }, + return Scaffold( + appBar: AppBar(), + body: DataErrorWidget( + onReload: () async { + widget.author == null || widget.author!.authorIsMe + ? await profileCubit.getMyProfile() + : await profileCubit.getProfileBySlug(widget.author!.authorSlug); + }, + ), ); } else { return Scaffold( @@ -437,12 +440,12 @@ class _ProfileScreenState extends State { padding: const EdgeInsets.only(bottom: 16), child: Column( children: [ - Padding( - padding: const EdgeInsets.symmetric(horizontal: 16), + const Padding( + padding: EdgeInsets.symmetric(horizontal: 16), child: Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ - const Text( + Text( 'Дипломы\nи сертификаты', style: TextStyle( color: Color(0xFF323F4B), @@ -451,19 +454,19 @@ class _ProfileScreenState extends State { fontWeight: FontWeight.w600, ), ), - GestureDetector( - onTap: () { - GoRouter.of(context).pushNamed('stepperBecomeConsultantScreen', extra: state.profile.slug); - }, - child: Text( - widget.author == null || widget.author!.authorIsMe ? 'Редактировать' : '', - style: const TextStyle( - color: Color(0xFF2F80ED), - fontSize: 16, - fontWeight: FontWeight.w500, - ), - ), - ), + // GestureDetector( + // onTap: () { + // GoRouter.of(context).pushNamed('stepperBecomeConsultantScreen', extra: state.profile.slug); + // }, + // child: Text( + // widget.author == null || widget.author!.authorIsMe ? 'Редактировать' : '', + // style: const TextStyle( + // color: Color(0xFF2F80ED), + // fontSize: 16, + // fontWeight: FontWeight.w500, + // ), + // ), + // ), ], ), ), @@ -538,12 +541,12 @@ class _ProfileScreenState extends State { padding: const EdgeInsets.only(bottom: 16), child: Column( children: [ - Padding( - padding: const EdgeInsets.symmetric(horizontal: 16), + const Padding( + padding: EdgeInsets.symmetric(horizontal: 16), child: Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ - const Text( + Text( 'Образование', style: TextStyle( color: Color(0xFF323F4B), @@ -551,19 +554,19 @@ class _ProfileScreenState extends State { fontWeight: FontWeight.w600, ), ), - GestureDetector( - onTap: () { - GoRouter.of(context).pushNamed('stepperBecomeConsultantScreen', extra: state.profile.slug); - }, - child: Text( - widget.author == null || widget.author!.authorIsMe ? 'Редактировать' : '', - style: const TextStyle( - color: Color(0xFF2F80ED), - fontSize: 16, - fontWeight: FontWeight.w500, - ), - ), - ), + // GestureDetector( + // onTap: () { + // GoRouter.of(context).pushNamed('stepperBecomeConsultantScreen', extra: state.profile.slug); + // }, + // child: Text( + // widget.author == null || widget.author!.authorIsMe ? 'Редактировать' : '', + // style: const TextStyle( + // color: Color(0xFF2F80ED), + // fontSize: 16, + // fontWeight: FontWeight.w500, + // ), + // ), + // ), ], ), ), diff --git a/lib/features/registration/presentation/bloc/registration_cubit/registration_cubit.dart b/lib/features/registration/presentation/bloc/registration_cubit/registration_cubit.dart index e3113e78..af748b69 100644 --- a/lib/features/registration/presentation/bloc/registration_cubit/registration_cubit.dart +++ b/lib/features/registration/presentation/bloc/registration_cubit/registration_cubit.dart @@ -58,7 +58,6 @@ class RegistrationCubit extends Cubit { ), ); await TokenStorage.saveTokenInStorage(token); - AppRouter.navigatorKey.currentContext?.go('/feed-screen'); AppRouter.navigatorKey.currentContext?.pushNamed('verifyEmailScreen'); } catch (e) { log(e.toString()); diff --git a/lib/features/registration/presentation/pages/verify_email_screen.dart b/lib/features/registration/presentation/pages/verify_email_screen.dart index 75f38712..ed4ea11f 100644 --- a/lib/features/registration/presentation/pages/verify_email_screen.dart +++ b/lib/features/registration/presentation/pages/verify_email_screen.dart @@ -17,6 +17,13 @@ class _VerifyEmailScreenState extends State { final List _focusNodes = List.generate(4, (_) => FocusNode()); final List _controllers = List.generate(4, (_) => TextEditingController()); String email = ''; + late final GoRouter goRouter; + + @override + void initState() { + super.initState(); + goRouter = GoRouter.of(context); + } @override void dispose() { @@ -48,7 +55,7 @@ class _VerifyEmailScreenState extends State { }); } else if (state is VerifyEmailStateVerifySuccess) { showSuccessToast('Почта успешно подтверждена'); - GoRouter.of(context).pop(); + goRouter.pushNamed('feedScreen'); } else if (state is VerifyEmailStateVerifyError) { showErrorToast("Неверный код. Попробуйте снова."); for (var controller in _controllers) { diff --git a/lib/features/settings/presentation/pages/settings_screen.dart b/lib/features/settings/presentation/pages/settings_screen.dart index 90c516ca..8afe8cd7 100644 --- a/lib/features/settings/presentation/pages/settings_screen.dart +++ b/lib/features/settings/presentation/pages/settings_screen.dart @@ -379,7 +379,7 @@ class _SettingsScreenState extends State { ), ); } else { - if (state.consultationRequestModel!.canceledModeration.status == ModerationStatus.created) { + if (state.consultationRequestModel!.educationModel.requestState == ModerationStatus.created) { return Padding( padding: const EdgeInsets.symmetric(horizontal: 16) + const EdgeInsets.only(bottom: 8), child: Ink( @@ -391,7 +391,7 @@ class _SettingsScreenState extends State { ), child: const Center( child: Text( - 'Данные на проверке...', + 'Данные на проверке', style: TextStyle( color: Colors.black, height: 1, @@ -401,7 +401,7 @@ class _SettingsScreenState extends State { ), ), ); - } else if (state.consultationRequestModel!.canceledModeration.status == ModerationStatus.canceled) { + } else if (state.consultationRequestModel!.educationModel.requestState == ModerationStatus.canceled) { return Padding( padding: const EdgeInsets.symmetric(horizontal: 16) + const EdgeInsets.only(bottom: 8), child: InkWell( diff --git a/pubspec.yaml b/pubspec.yaml index 02918a68..97712189 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,6 +1,6 @@ name: eatvio_app description: A new Flutter project. -version: 1.1.1+30 +version: 1.1.2+32 publish_to: 'none' environment: