From 26820997fcd79fd5ebbdbb9f09695ad62f854536 Mon Sep 17 00:00:00 2001 From: mso7nueh Date: Fri, 4 Oct 2024 15:07:07 +0300 Subject: [PATCH] feat(consultant): add requests for upload photo, register consultant profile, state manager --- lib/app_router.dart | 4 +- .../pages/blog_post_create_screen.dart | 4 +- .../models/consultant_profile_model.dart | 40 + .../consultant_profile_model.freezed.dart | 717 ++++++++++++++++++ .../models/consultant_profile_model.g.dart | 66 ++ .../register_consultant_cubit.dart | 30 + .../register_consultant_state.dart | 11 + .../register_consultant_state.freezed.dart | 166 ++++ .../pages/additional_settings_screen.dart | 0 .../pages/become_consultant_screen.dart | 0 .../certificates_and_diploms_screen.dart | 0 .../pages/last_step_screen.dart | 0 .../pages/photo_or_scans_screen.dart | 0 .../pages/registration_as_screen.dart | 0 .../pages/social_networks_screen.dart | 0 .../stepper_become_consultant_screen.dart | 12 +- .../repositories/consultant_repository.dart | 51 ++ .../services/consultant_service.dart | 20 + .../services/consultant_service.g.dart | 118 +++ .../registration_cubit.dart | 5 +- lib/locator_service.dart | 6 + .../bloc/blog_post_create_bloc.dart | 2 +- 22 files changed, 1240 insertions(+), 12 deletions(-) create mode 100644 lib/features/consultant/become_consultant/models/consultant_profile_model.dart create mode 100644 lib/features/consultant/become_consultant/models/consultant_profile_model.freezed.dart create mode 100644 lib/features/consultant/become_consultant/models/consultant_profile_model.g.dart create mode 100644 lib/features/consultant/become_consultant/presentation/bloc/register_consultant_cubit/register_consultant_cubit.dart create mode 100644 lib/features/consultant/become_consultant/presentation/bloc/register_consultant_cubit/register_consultant_state.dart create mode 100644 lib/features/consultant/become_consultant/presentation/bloc/register_consultant_cubit/register_consultant_state.freezed.dart rename lib/features/consultant/become_consultant/{ => presentation}/pages/additional_settings_screen.dart (100%) rename lib/features/consultant/become_consultant/{ => presentation}/pages/become_consultant_screen.dart (100%) rename lib/features/consultant/become_consultant/{ => presentation}/pages/certificates_and_diploms_screen.dart (100%) rename lib/features/consultant/become_consultant/{ => presentation}/pages/last_step_screen.dart (100%) rename lib/features/consultant/become_consultant/{ => presentation}/pages/photo_or_scans_screen.dart (100%) rename lib/features/consultant/become_consultant/{ => presentation}/pages/registration_as_screen.dart (100%) rename lib/features/consultant/become_consultant/{ => presentation}/pages/social_networks_screen.dart (100%) rename lib/features/consultant/become_consultant/{ => presentation}/pages/stepper_become_consultant_screen.dart (94%) create mode 100644 lib/features/consultant/become_consultant/repositories/consultant_repository.dart create mode 100644 lib/features/consultant/become_consultant/services/consultant_service.dart create mode 100644 lib/features/consultant/become_consultant/services/consultant_service.g.dart diff --git a/lib/app_router.dart b/lib/app_router.dart index 7b4751e0..6e791055 100644 --- a/lib/app_router.dart +++ b/lib/app_router.dart @@ -7,8 +7,8 @@ import 'package:eatvio_app/features/calendar/presentation/pages/calendar_screen. import 'package:eatvio_app/features/chat/presentation/pages/chat_screen.dart'; import 'package:eatvio_app/features/chat/presentation/pages/chat_select_screen.dart'; import 'package:eatvio_app/features/chat/presentation/pages/photo_view_screen.dart'; -import 'package:eatvio_app/features/consultant/become_consultant/pages/become_consultant_screen.dart'; -import 'package:eatvio_app/features/consultant/become_consultant/pages/stepper_become_consultant_screen.dart'; +import 'package:eatvio_app/features/consultant/become_consultant/presentation/pages/become_consultant_screen.dart'; +import 'package:eatvio_app/features/consultant/become_consultant/presentation/pages/stepper_become_consultant_screen.dart'; import 'package:eatvio_app/features/diary/presentation/pages/diary_screen.dart'; import 'package:eatvio_app/features/diets/presentation/pages/about_diet_screen.dart'; import 'package:eatvio_app/features/feed/models/diets_pagination_model.dart'; diff --git a/lib/features/blog_post_create/presentation/pages/blog_post_create_screen.dart b/lib/features/blog_post_create/presentation/pages/blog_post_create_screen.dart index 4dbf9277..2a03f274 100644 --- a/lib/features/blog_post_create/presentation/pages/blog_post_create_screen.dart +++ b/lib/features/blog_post_create/presentation/pages/blog_post_create_screen.dart @@ -89,7 +89,9 @@ class _BlogPostCreateScreenState extends State { onPressed: () => _submitForm(context, state.title!.text, state.description!.text, state.youtubeURL!.text), label: Text( 'Создать', - style: theme.textTheme.titleSmall, + style: TextStyle( + color: Colors.white, + ), ), ), ), diff --git a/lib/features/consultant/become_consultant/models/consultant_profile_model.dart b/lib/features/consultant/become_consultant/models/consultant_profile_model.dart new file mode 100644 index 00000000..4cbde94f --- /dev/null +++ b/lib/features/consultant/become_consultant/models/consultant_profile_model.dart @@ -0,0 +1,40 @@ +import 'package:freezed_annotation/freezed_annotation.dart'; + +part 'consultant_profile_model.freezed.dart'; + +part 'consultant_profile_model.g.dart'; + +@freezed +class ConsultantProfileModel with _$ConsultantProfileModel { + const factory ConsultantProfileModel({ + @JsonKey(name: 'has_medical_education') bool? hasMedicalEducation, + @JsonKey(name: 'social_links') SocialLinksModel? socialLinks, + @JsonKey(name: 'cert_photos') List? photos, + @JsonKey(name: 'completed_courses') List? certificates, + }) = _ConsultantProfileModel; + + factory ConsultantProfileModel.fromJson(Map json) => _$ConsultantProfileModelFromJson(json); +} + +@freezed +class SocialLinksModel with _$SocialLinksModel { + const factory SocialLinksModel({ + @JsonKey(name: 'vk_link') String? vkLink, + @JsonKey(name: 'tg_link') String? tgLink, + @JsonKey(name: 'fb_link') String? fbLink, + @JsonKey(name: 'insta_link') String? instaLink, + @JsonKey(name: 'personal_site_link') String? personalSiteLink, + }) = _SocialLinksModel; + + factory SocialLinksModel.fromJson(Map json) => _$SocialLinksModelFromJson(json); +} + +@freezed +class CertificatesModel with _$CertificatesModel { + const factory CertificatesModel({ + required String title, + required String date, + }) = _CertificatesModel; + + factory CertificatesModel.fromJson(Map json) => _$CertificatesModelFromJson(json); +} diff --git a/lib/features/consultant/become_consultant/models/consultant_profile_model.freezed.dart b/lib/features/consultant/become_consultant/models/consultant_profile_model.freezed.dart new file mode 100644 index 00000000..3abdd043 --- /dev/null +++ b/lib/features/consultant/become_consultant/models/consultant_profile_model.freezed.dart @@ -0,0 +1,717 @@ +// coverage:ignore-file +// GENERATED CODE - DO NOT MODIFY BY HAND +// ignore_for_file: type=lint +// ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, invalid_annotation_target, unnecessary_question_mark + +part of 'consultant_profile_model.dart'; + +// ************************************************************************** +// FreezedGenerator +// ************************************************************************** + +T _$identity(T value) => value; + +final _privateConstructorUsedError = UnsupportedError( + 'It seems like you constructed your class using `MyClass._()`. This constructor is only meant to be used by freezed and you are not supposed to need it nor use it.\nPlease check the documentation here for more information: https://github.com/rrousselGit/freezed#adding-getters-and-methods-to-our-models'); + +ConsultantProfileModel _$ConsultantProfileModelFromJson( + Map json) { + return _ConsultantProfileModel.fromJson(json); +} + +/// @nodoc +mixin _$ConsultantProfileModel { + @JsonKey(name: 'has_medical_education') + bool? get hasMedicalEducation => throw _privateConstructorUsedError; + @JsonKey(name: 'social_links') + SocialLinksModel? get socialLinks => throw _privateConstructorUsedError; + @JsonKey(name: 'cert_photos') + List? get photos => throw _privateConstructorUsedError; + @JsonKey(name: 'completed_courses') + List? get certificates => + throw _privateConstructorUsedError; + + /// Serializes this ConsultantProfileModel to a JSON map. + Map toJson() => throw _privateConstructorUsedError; + + /// Create a copy of ConsultantProfileModel + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + $ConsultantProfileModelCopyWith get copyWith => + throw _privateConstructorUsedError; +} + +/// @nodoc +abstract class $ConsultantProfileModelCopyWith<$Res> { + factory $ConsultantProfileModelCopyWith(ConsultantProfileModel value, + $Res Function(ConsultantProfileModel) then) = + _$ConsultantProfileModelCopyWithImpl<$Res, ConsultantProfileModel>; + @useResult + $Res call( + {@JsonKey(name: 'has_medical_education') bool? hasMedicalEducation, + @JsonKey(name: 'social_links') SocialLinksModel? socialLinks, + @JsonKey(name: 'cert_photos') List? photos, + @JsonKey(name: 'completed_courses') + List? certificates}); + + $SocialLinksModelCopyWith<$Res>? get socialLinks; +} + +/// @nodoc +class _$ConsultantProfileModelCopyWithImpl<$Res, + $Val extends ConsultantProfileModel> + implements $ConsultantProfileModelCopyWith<$Res> { + _$ConsultantProfileModelCopyWithImpl(this._value, this._then); + + // ignore: unused_field + final $Val _value; + // ignore: unused_field + final $Res Function($Val) _then; + + /// Create a copy of ConsultantProfileModel + /// with the given fields replaced by the non-null parameter values. + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? hasMedicalEducation = freezed, + Object? socialLinks = freezed, + Object? photos = freezed, + Object? certificates = freezed, + }) { + return _then(_value.copyWith( + hasMedicalEducation: freezed == hasMedicalEducation + ? _value.hasMedicalEducation + : hasMedicalEducation // ignore: cast_nullable_to_non_nullable + as bool?, + socialLinks: freezed == socialLinks + ? _value.socialLinks + : socialLinks // ignore: cast_nullable_to_non_nullable + as SocialLinksModel?, + photos: freezed == photos + ? _value.photos + : photos // ignore: cast_nullable_to_non_nullable + as List?, + certificates: freezed == certificates + ? _value.certificates + : certificates // ignore: cast_nullable_to_non_nullable + as List?, + ) as $Val); + } + + /// Create a copy of ConsultantProfileModel + /// with the given fields replaced by the non-null parameter values. + @override + @pragma('vm:prefer-inline') + $SocialLinksModelCopyWith<$Res>? get socialLinks { + if (_value.socialLinks == null) { + return null; + } + + return $SocialLinksModelCopyWith<$Res>(_value.socialLinks!, (value) { + return _then(_value.copyWith(socialLinks: value) as $Val); + }); + } +} + +/// @nodoc +abstract class _$$ConsultantProfileModelImplCopyWith<$Res> + implements $ConsultantProfileModelCopyWith<$Res> { + factory _$$ConsultantProfileModelImplCopyWith( + _$ConsultantProfileModelImpl value, + $Res Function(_$ConsultantProfileModelImpl) then) = + __$$ConsultantProfileModelImplCopyWithImpl<$Res>; + @override + @useResult + $Res call( + {@JsonKey(name: 'has_medical_education') bool? hasMedicalEducation, + @JsonKey(name: 'social_links') SocialLinksModel? socialLinks, + @JsonKey(name: 'cert_photos') List? photos, + @JsonKey(name: 'completed_courses') + List? certificates}); + + @override + $SocialLinksModelCopyWith<$Res>? get socialLinks; +} + +/// @nodoc +class __$$ConsultantProfileModelImplCopyWithImpl<$Res> + extends _$ConsultantProfileModelCopyWithImpl<$Res, + _$ConsultantProfileModelImpl> + implements _$$ConsultantProfileModelImplCopyWith<$Res> { + __$$ConsultantProfileModelImplCopyWithImpl( + _$ConsultantProfileModelImpl _value, + $Res Function(_$ConsultantProfileModelImpl) _then) + : super(_value, _then); + + /// Create a copy of ConsultantProfileModel + /// with the given fields replaced by the non-null parameter values. + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? hasMedicalEducation = freezed, + Object? socialLinks = freezed, + Object? photos = freezed, + Object? certificates = freezed, + }) { + return _then(_$ConsultantProfileModelImpl( + hasMedicalEducation: freezed == hasMedicalEducation + ? _value.hasMedicalEducation + : hasMedicalEducation // ignore: cast_nullable_to_non_nullable + as bool?, + socialLinks: freezed == socialLinks + ? _value.socialLinks + : socialLinks // ignore: cast_nullable_to_non_nullable + as SocialLinksModel?, + photos: freezed == photos + ? _value._photos + : photos // ignore: cast_nullable_to_non_nullable + as List?, + certificates: freezed == certificates + ? _value._certificates + : certificates // ignore: cast_nullable_to_non_nullable + as List?, + )); + } +} + +/// @nodoc +@JsonSerializable() +class _$ConsultantProfileModelImpl implements _ConsultantProfileModel { + const _$ConsultantProfileModelImpl( + {@JsonKey(name: 'has_medical_education') this.hasMedicalEducation, + @JsonKey(name: 'social_links') this.socialLinks, + @JsonKey(name: 'cert_photos') final List? photos, + @JsonKey(name: 'completed_courses') + final List? certificates}) + : _photos = photos, + _certificates = certificates; + + factory _$ConsultantProfileModelImpl.fromJson(Map json) => + _$$ConsultantProfileModelImplFromJson(json); + + @override + @JsonKey(name: 'has_medical_education') + final bool? hasMedicalEducation; + @override + @JsonKey(name: 'social_links') + final SocialLinksModel? socialLinks; + final List? _photos; + @override + @JsonKey(name: 'cert_photos') + List? get photos { + final value = _photos; + if (value == null) return null; + if (_photos is EqualUnmodifiableListView) return _photos; + // ignore: implicit_dynamic_type + return EqualUnmodifiableListView(value); + } + + final List? _certificates; + @override + @JsonKey(name: 'completed_courses') + List? get certificates { + final value = _certificates; + if (value == null) return null; + if (_certificates is EqualUnmodifiableListView) return _certificates; + // ignore: implicit_dynamic_type + return EqualUnmodifiableListView(value); + } + + @override + String toString() { + return 'ConsultantProfileModel(hasMedicalEducation: $hasMedicalEducation, socialLinks: $socialLinks, photos: $photos, certificates: $certificates)'; + } + + @override + bool operator ==(Object other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$ConsultantProfileModelImpl && + (identical(other.hasMedicalEducation, hasMedicalEducation) || + other.hasMedicalEducation == hasMedicalEducation) && + (identical(other.socialLinks, socialLinks) || + other.socialLinks == socialLinks) && + const DeepCollectionEquality().equals(other._photos, _photos) && + const DeepCollectionEquality() + .equals(other._certificates, _certificates)); + } + + @JsonKey(includeFromJson: false, includeToJson: false) + @override + int get hashCode => Object.hash( + runtimeType, + hasMedicalEducation, + socialLinks, + const DeepCollectionEquality().hash(_photos), + const DeepCollectionEquality().hash(_certificates)); + + /// Create a copy of ConsultantProfileModel + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + @override + @pragma('vm:prefer-inline') + _$$ConsultantProfileModelImplCopyWith<_$ConsultantProfileModelImpl> + get copyWith => __$$ConsultantProfileModelImplCopyWithImpl< + _$ConsultantProfileModelImpl>(this, _$identity); + + @override + Map toJson() { + return _$$ConsultantProfileModelImplToJson( + this, + ); + } +} + +abstract class _ConsultantProfileModel implements ConsultantProfileModel { + const factory _ConsultantProfileModel( + {@JsonKey(name: 'has_medical_education') final bool? hasMedicalEducation, + @JsonKey(name: 'social_links') final SocialLinksModel? socialLinks, + @JsonKey(name: 'cert_photos') final List? photos, + @JsonKey(name: 'completed_courses') + final List? + certificates}) = _$ConsultantProfileModelImpl; + + factory _ConsultantProfileModel.fromJson(Map json) = + _$ConsultantProfileModelImpl.fromJson; + + @override + @JsonKey(name: 'has_medical_education') + bool? get hasMedicalEducation; + @override + @JsonKey(name: 'social_links') + SocialLinksModel? get socialLinks; + @override + @JsonKey(name: 'cert_photos') + List? get photos; + @override + @JsonKey(name: 'completed_courses') + List? get certificates; + + /// Create a copy of ConsultantProfileModel + /// with the given fields replaced by the non-null parameter values. + @override + @JsonKey(includeFromJson: false, includeToJson: false) + _$$ConsultantProfileModelImplCopyWith<_$ConsultantProfileModelImpl> + get copyWith => throw _privateConstructorUsedError; +} + +SocialLinksModel _$SocialLinksModelFromJson(Map json) { + return _SocialLinksModel.fromJson(json); +} + +/// @nodoc +mixin _$SocialLinksModel { + @JsonKey(name: 'vk_link') + String? get vkLink => throw _privateConstructorUsedError; + @JsonKey(name: 'tg_link') + String? get tgLink => throw _privateConstructorUsedError; + @JsonKey(name: 'fb_link') + String? get fbLink => throw _privateConstructorUsedError; + @JsonKey(name: 'insta_link') + String? get instaLink => throw _privateConstructorUsedError; + @JsonKey(name: 'personal_site_link') + String? get personalSiteLink => throw _privateConstructorUsedError; + + /// Serializes this SocialLinksModel to a JSON map. + Map toJson() => throw _privateConstructorUsedError; + + /// Create a copy of SocialLinksModel + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + $SocialLinksModelCopyWith get copyWith => + throw _privateConstructorUsedError; +} + +/// @nodoc +abstract class $SocialLinksModelCopyWith<$Res> { + factory $SocialLinksModelCopyWith( + SocialLinksModel value, $Res Function(SocialLinksModel) then) = + _$SocialLinksModelCopyWithImpl<$Res, SocialLinksModel>; + @useResult + $Res call( + {@JsonKey(name: 'vk_link') String? vkLink, + @JsonKey(name: 'tg_link') String? tgLink, + @JsonKey(name: 'fb_link') String? fbLink, + @JsonKey(name: 'insta_link') String? instaLink, + @JsonKey(name: 'personal_site_link') String? personalSiteLink}); +} + +/// @nodoc +class _$SocialLinksModelCopyWithImpl<$Res, $Val extends SocialLinksModel> + implements $SocialLinksModelCopyWith<$Res> { + _$SocialLinksModelCopyWithImpl(this._value, this._then); + + // ignore: unused_field + final $Val _value; + // ignore: unused_field + final $Res Function($Val) _then; + + /// Create a copy of SocialLinksModel + /// with the given fields replaced by the non-null parameter values. + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? vkLink = freezed, + Object? tgLink = freezed, + Object? fbLink = freezed, + Object? instaLink = freezed, + Object? personalSiteLink = freezed, + }) { + return _then(_value.copyWith( + vkLink: freezed == vkLink + ? _value.vkLink + : vkLink // ignore: cast_nullable_to_non_nullable + as String?, + tgLink: freezed == tgLink + ? _value.tgLink + : tgLink // ignore: cast_nullable_to_non_nullable + as String?, + fbLink: freezed == fbLink + ? _value.fbLink + : fbLink // ignore: cast_nullable_to_non_nullable + as String?, + instaLink: freezed == instaLink + ? _value.instaLink + : instaLink // ignore: cast_nullable_to_non_nullable + as String?, + personalSiteLink: freezed == personalSiteLink + ? _value.personalSiteLink + : personalSiteLink // ignore: cast_nullable_to_non_nullable + as String?, + ) as $Val); + } +} + +/// @nodoc +abstract class _$$SocialLinksModelImplCopyWith<$Res> + implements $SocialLinksModelCopyWith<$Res> { + factory _$$SocialLinksModelImplCopyWith(_$SocialLinksModelImpl value, + $Res Function(_$SocialLinksModelImpl) then) = + __$$SocialLinksModelImplCopyWithImpl<$Res>; + @override + @useResult + $Res call( + {@JsonKey(name: 'vk_link') String? vkLink, + @JsonKey(name: 'tg_link') String? tgLink, + @JsonKey(name: 'fb_link') String? fbLink, + @JsonKey(name: 'insta_link') String? instaLink, + @JsonKey(name: 'personal_site_link') String? personalSiteLink}); +} + +/// @nodoc +class __$$SocialLinksModelImplCopyWithImpl<$Res> + extends _$SocialLinksModelCopyWithImpl<$Res, _$SocialLinksModelImpl> + implements _$$SocialLinksModelImplCopyWith<$Res> { + __$$SocialLinksModelImplCopyWithImpl(_$SocialLinksModelImpl _value, + $Res Function(_$SocialLinksModelImpl) _then) + : super(_value, _then); + + /// Create a copy of SocialLinksModel + /// with the given fields replaced by the non-null parameter values. + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? vkLink = freezed, + Object? tgLink = freezed, + Object? fbLink = freezed, + Object? instaLink = freezed, + Object? personalSiteLink = freezed, + }) { + return _then(_$SocialLinksModelImpl( + vkLink: freezed == vkLink + ? _value.vkLink + : vkLink // ignore: cast_nullable_to_non_nullable + as String?, + tgLink: freezed == tgLink + ? _value.tgLink + : tgLink // ignore: cast_nullable_to_non_nullable + as String?, + fbLink: freezed == fbLink + ? _value.fbLink + : fbLink // ignore: cast_nullable_to_non_nullable + as String?, + instaLink: freezed == instaLink + ? _value.instaLink + : instaLink // ignore: cast_nullable_to_non_nullable + as String?, + personalSiteLink: freezed == personalSiteLink + ? _value.personalSiteLink + : personalSiteLink // ignore: cast_nullable_to_non_nullable + as String?, + )); + } +} + +/// @nodoc +@JsonSerializable() +class _$SocialLinksModelImpl implements _SocialLinksModel { + const _$SocialLinksModelImpl( + {@JsonKey(name: 'vk_link') this.vkLink, + @JsonKey(name: 'tg_link') this.tgLink, + @JsonKey(name: 'fb_link') this.fbLink, + @JsonKey(name: 'insta_link') this.instaLink, + @JsonKey(name: 'personal_site_link') this.personalSiteLink}); + + factory _$SocialLinksModelImpl.fromJson(Map json) => + _$$SocialLinksModelImplFromJson(json); + + @override + @JsonKey(name: 'vk_link') + final String? vkLink; + @override + @JsonKey(name: 'tg_link') + final String? tgLink; + @override + @JsonKey(name: 'fb_link') + final String? fbLink; + @override + @JsonKey(name: 'insta_link') + final String? instaLink; + @override + @JsonKey(name: 'personal_site_link') + final String? personalSiteLink; + + @override + String toString() { + return 'SocialLinksModel(vkLink: $vkLink, tgLink: $tgLink, fbLink: $fbLink, instaLink: $instaLink, personalSiteLink: $personalSiteLink)'; + } + + @override + bool operator ==(Object other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$SocialLinksModelImpl && + (identical(other.vkLink, vkLink) || other.vkLink == vkLink) && + (identical(other.tgLink, tgLink) || other.tgLink == tgLink) && + (identical(other.fbLink, fbLink) || other.fbLink == fbLink) && + (identical(other.instaLink, instaLink) || + other.instaLink == instaLink) && + (identical(other.personalSiteLink, personalSiteLink) || + other.personalSiteLink == personalSiteLink)); + } + + @JsonKey(includeFromJson: false, includeToJson: false) + @override + int get hashCode => Object.hash( + runtimeType, vkLink, tgLink, fbLink, instaLink, personalSiteLink); + + /// Create a copy of SocialLinksModel + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + @override + @pragma('vm:prefer-inline') + _$$SocialLinksModelImplCopyWith<_$SocialLinksModelImpl> get copyWith => + __$$SocialLinksModelImplCopyWithImpl<_$SocialLinksModelImpl>( + this, _$identity); + + @override + Map toJson() { + return _$$SocialLinksModelImplToJson( + this, + ); + } +} + +abstract class _SocialLinksModel implements SocialLinksModel { + const factory _SocialLinksModel( + {@JsonKey(name: 'vk_link') final String? vkLink, + @JsonKey(name: 'tg_link') final String? tgLink, + @JsonKey(name: 'fb_link') final String? fbLink, + @JsonKey(name: 'insta_link') final String? instaLink, + @JsonKey(name: 'personal_site_link') + final String? personalSiteLink}) = _$SocialLinksModelImpl; + + factory _SocialLinksModel.fromJson(Map json) = + _$SocialLinksModelImpl.fromJson; + + @override + @JsonKey(name: 'vk_link') + String? get vkLink; + @override + @JsonKey(name: 'tg_link') + String? get tgLink; + @override + @JsonKey(name: 'fb_link') + String? get fbLink; + @override + @JsonKey(name: 'insta_link') + String? get instaLink; + @override + @JsonKey(name: 'personal_site_link') + String? get personalSiteLink; + + /// Create a copy of SocialLinksModel + /// with the given fields replaced by the non-null parameter values. + @override + @JsonKey(includeFromJson: false, includeToJson: false) + _$$SocialLinksModelImplCopyWith<_$SocialLinksModelImpl> get copyWith => + throw _privateConstructorUsedError; +} + +CertificatesModel _$CertificatesModelFromJson(Map json) { + return _CertificatesModel.fromJson(json); +} + +/// @nodoc +mixin _$CertificatesModel { + String get title => throw _privateConstructorUsedError; + String get date => throw _privateConstructorUsedError; + + /// Serializes this CertificatesModel to a JSON map. + Map toJson() => throw _privateConstructorUsedError; + + /// Create a copy of CertificatesModel + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + $CertificatesModelCopyWith get copyWith => + throw _privateConstructorUsedError; +} + +/// @nodoc +abstract class $CertificatesModelCopyWith<$Res> { + factory $CertificatesModelCopyWith( + CertificatesModel value, $Res Function(CertificatesModel) then) = + _$CertificatesModelCopyWithImpl<$Res, CertificatesModel>; + @useResult + $Res call({String title, String date}); +} + +/// @nodoc +class _$CertificatesModelCopyWithImpl<$Res, $Val extends CertificatesModel> + implements $CertificatesModelCopyWith<$Res> { + _$CertificatesModelCopyWithImpl(this._value, this._then); + + // ignore: unused_field + final $Val _value; + // ignore: unused_field + final $Res Function($Val) _then; + + /// Create a copy of CertificatesModel + /// with the given fields replaced by the non-null parameter values. + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? title = null, + Object? date = null, + }) { + return _then(_value.copyWith( + title: null == title + ? _value.title + : title // ignore: cast_nullable_to_non_nullable + as String, + date: null == date + ? _value.date + : date // ignore: cast_nullable_to_non_nullable + as String, + ) as $Val); + } +} + +/// @nodoc +abstract class _$$CertificatesModelImplCopyWith<$Res> + implements $CertificatesModelCopyWith<$Res> { + factory _$$CertificatesModelImplCopyWith(_$CertificatesModelImpl value, + $Res Function(_$CertificatesModelImpl) then) = + __$$CertificatesModelImplCopyWithImpl<$Res>; + @override + @useResult + $Res call({String title, String date}); +} + +/// @nodoc +class __$$CertificatesModelImplCopyWithImpl<$Res> + extends _$CertificatesModelCopyWithImpl<$Res, _$CertificatesModelImpl> + implements _$$CertificatesModelImplCopyWith<$Res> { + __$$CertificatesModelImplCopyWithImpl(_$CertificatesModelImpl _value, + $Res Function(_$CertificatesModelImpl) _then) + : super(_value, _then); + + /// Create a copy of CertificatesModel + /// with the given fields replaced by the non-null parameter values. + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? title = null, + Object? date = null, + }) { + return _then(_$CertificatesModelImpl( + title: null == title + ? _value.title + : title // ignore: cast_nullable_to_non_nullable + as String, + date: null == date + ? _value.date + : date // ignore: cast_nullable_to_non_nullable + as String, + )); + } +} + +/// @nodoc +@JsonSerializable() +class _$CertificatesModelImpl implements _CertificatesModel { + const _$CertificatesModelImpl({required this.title, required this.date}); + + factory _$CertificatesModelImpl.fromJson(Map json) => + _$$CertificatesModelImplFromJson(json); + + @override + final String title; + @override + final String date; + + @override + String toString() { + return 'CertificatesModel(title: $title, date: $date)'; + } + + @override + bool operator ==(Object other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$CertificatesModelImpl && + (identical(other.title, title) || other.title == title) && + (identical(other.date, date) || other.date == date)); + } + + @JsonKey(includeFromJson: false, includeToJson: false) + @override + int get hashCode => Object.hash(runtimeType, title, date); + + /// Create a copy of CertificatesModel + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + @override + @pragma('vm:prefer-inline') + _$$CertificatesModelImplCopyWith<_$CertificatesModelImpl> get copyWith => + __$$CertificatesModelImplCopyWithImpl<_$CertificatesModelImpl>( + this, _$identity); + + @override + Map toJson() { + return _$$CertificatesModelImplToJson( + this, + ); + } +} + +abstract class _CertificatesModel implements CertificatesModel { + const factory _CertificatesModel( + {required final String title, + required final String date}) = _$CertificatesModelImpl; + + factory _CertificatesModel.fromJson(Map json) = + _$CertificatesModelImpl.fromJson; + + @override + String get title; + @override + String get date; + + /// Create a copy of CertificatesModel + /// with the given fields replaced by the non-null parameter values. + @override + @JsonKey(includeFromJson: false, includeToJson: false) + _$$CertificatesModelImplCopyWith<_$CertificatesModelImpl> get copyWith => + throw _privateConstructorUsedError; +} diff --git a/lib/features/consultant/become_consultant/models/consultant_profile_model.g.dart b/lib/features/consultant/become_consultant/models/consultant_profile_model.g.dart new file mode 100644 index 00000000..ab86917a --- /dev/null +++ b/lib/features/consultant/become_consultant/models/consultant_profile_model.g.dart @@ -0,0 +1,66 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'consultant_profile_model.dart'; + +// ************************************************************************** +// JsonSerializableGenerator +// ************************************************************************** + +_$ConsultantProfileModelImpl _$$ConsultantProfileModelImplFromJson( + Map json) => + _$ConsultantProfileModelImpl( + hasMedicalEducation: json['has_medical_education'] as bool?, + socialLinks: json['social_links'] == null + ? null + : SocialLinksModel.fromJson( + json['social_links'] as Map), + photos: (json['cert_photos'] as List?) + ?.map((e) => e as String) + .toList(), + certificates: (json['completed_courses'] as List?) + ?.map((e) => CertificatesModel.fromJson(e as Map)) + .toList(), + ); + +Map _$$ConsultantProfileModelImplToJson( + _$ConsultantProfileModelImpl instance) => + { + 'has_medical_education': instance.hasMedicalEducation, + 'social_links': instance.socialLinks, + 'cert_photos': instance.photos, + 'completed_courses': instance.certificates, + }; + +_$SocialLinksModelImpl _$$SocialLinksModelImplFromJson( + Map json) => + _$SocialLinksModelImpl( + vkLink: json['vk_link'] as String?, + tgLink: json['tg_link'] as String?, + fbLink: json['fb_link'] as String?, + instaLink: json['insta_link'] as String?, + personalSiteLink: json['personal_site_link'] as String?, + ); + +Map _$$SocialLinksModelImplToJson( + _$SocialLinksModelImpl instance) => + { + 'vk_link': instance.vkLink, + 'tg_link': instance.tgLink, + 'fb_link': instance.fbLink, + 'insta_link': instance.instaLink, + 'personal_site_link': instance.personalSiteLink, + }; + +_$CertificatesModelImpl _$$CertificatesModelImplFromJson( + Map json) => + _$CertificatesModelImpl( + title: json['title'] as String, + date: json['date'] as String, + ); + +Map _$$CertificatesModelImplToJson( + _$CertificatesModelImpl instance) => + { + 'title': instance.title, + 'date': instance.date, + }; 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 new file mode 100644 index 00000000..b60cab68 --- /dev/null +++ b/lib/features/consultant/become_consultant/presentation/bloc/register_consultant_cubit/register_consultant_cubit.dart @@ -0,0 +1,30 @@ +import 'dart:io'; + +import 'package:eatvio_app/features/consultant/become_consultant/models/consultant_profile_model.dart'; +import 'package:eatvio_app/features/consultant/become_consultant/presentation/bloc/register_consultant_cubit/register_consultant_state.dart'; +import 'package:eatvio_app/features/consultant/become_consultant/repositories/consultant_repository.dart'; +import 'package:flutter_bloc/flutter_bloc.dart'; + +class RegisterConsultantCubit extends Cubit { + final ConsultantRepository consultantRepository; + + RegisterConsultantCubit({ + required this.consultantRepository, + }) : super( + RegisterConsultantState( + consultant: ConsultantProfileModel(), + ), + ); + + updateConsultantProfileModel(ConsultantProfileModel consultant) { + emit(RegisterConsultantState(consultant: consultant)); + } + + registerConsultant() async { + await consultantRepository.registerConsultant(consultant: state.consultant); + } + + uploadPhotos(List files) async { + await consultantRepository.uploadPhotos(files: files); + } +} diff --git a/lib/features/consultant/become_consultant/presentation/bloc/register_consultant_cubit/register_consultant_state.dart b/lib/features/consultant/become_consultant/presentation/bloc/register_consultant_cubit/register_consultant_state.dart new file mode 100644 index 00000000..cb8cafe6 --- /dev/null +++ b/lib/features/consultant/become_consultant/presentation/bloc/register_consultant_cubit/register_consultant_state.dart @@ -0,0 +1,11 @@ +import 'package:eatvio_app/features/consultant/become_consultant/models/consultant_profile_model.dart'; +import 'package:freezed_annotation/freezed_annotation.dart'; + +part 'register_consultant_state.freezed.dart'; + +@freezed +abstract class RegisterConsultantState with _$RegisterConsultantState { + const factory RegisterConsultantState({ + required ConsultantProfileModel consultant, + }) = _RegisterConsultantState; +} diff --git a/lib/features/consultant/become_consultant/presentation/bloc/register_consultant_cubit/register_consultant_state.freezed.dart b/lib/features/consultant/become_consultant/presentation/bloc/register_consultant_cubit/register_consultant_state.freezed.dart new file mode 100644 index 00000000..f516e7bf --- /dev/null +++ b/lib/features/consultant/become_consultant/presentation/bloc/register_consultant_cubit/register_consultant_state.freezed.dart @@ -0,0 +1,166 @@ +// coverage:ignore-file +// GENERATED CODE - DO NOT MODIFY BY HAND +// ignore_for_file: type=lint +// ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, invalid_annotation_target, unnecessary_question_mark + +part of 'register_consultant_state.dart'; + +// ************************************************************************** +// FreezedGenerator +// ************************************************************************** + +T _$identity(T value) => value; + +final _privateConstructorUsedError = UnsupportedError( + 'It seems like you constructed your class using `MyClass._()`. This constructor is only meant to be used by freezed and you are not supposed to need it nor use it.\nPlease check the documentation here for more information: https://github.com/rrousselGit/freezed#adding-getters-and-methods-to-our-models'); + +/// @nodoc +mixin _$RegisterConsultantState { + ConsultantProfileModel get consultant => throw _privateConstructorUsedError; + + /// Create a copy of RegisterConsultantState + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + $RegisterConsultantStateCopyWith get copyWith => + throw _privateConstructorUsedError; +} + +/// @nodoc +abstract class $RegisterConsultantStateCopyWith<$Res> { + factory $RegisterConsultantStateCopyWith(RegisterConsultantState value, + $Res Function(RegisterConsultantState) then) = + _$RegisterConsultantStateCopyWithImpl<$Res, RegisterConsultantState>; + @useResult + $Res call({ConsultantProfileModel consultant}); + + $ConsultantProfileModelCopyWith<$Res> get consultant; +} + +/// @nodoc +class _$RegisterConsultantStateCopyWithImpl<$Res, + $Val extends RegisterConsultantState> + implements $RegisterConsultantStateCopyWith<$Res> { + _$RegisterConsultantStateCopyWithImpl(this._value, this._then); + + // ignore: unused_field + final $Val _value; + // ignore: unused_field + final $Res Function($Val) _then; + + /// Create a copy of RegisterConsultantState + /// with the given fields replaced by the non-null parameter values. + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? consultant = null, + }) { + return _then(_value.copyWith( + consultant: null == consultant + ? _value.consultant + : consultant // ignore: cast_nullable_to_non_nullable + as ConsultantProfileModel, + ) as $Val); + } + + /// Create a copy of RegisterConsultantState + /// with the given fields replaced by the non-null parameter values. + @override + @pragma('vm:prefer-inline') + $ConsultantProfileModelCopyWith<$Res> get consultant { + return $ConsultantProfileModelCopyWith<$Res>(_value.consultant, (value) { + return _then(_value.copyWith(consultant: value) as $Val); + }); + } +} + +/// @nodoc +abstract class _$$RegisterConsultantStateImplCopyWith<$Res> + implements $RegisterConsultantStateCopyWith<$Res> { + factory _$$RegisterConsultantStateImplCopyWith( + _$RegisterConsultantStateImpl value, + $Res Function(_$RegisterConsultantStateImpl) then) = + __$$RegisterConsultantStateImplCopyWithImpl<$Res>; + @override + @useResult + $Res call({ConsultantProfileModel consultant}); + + @override + $ConsultantProfileModelCopyWith<$Res> get consultant; +} + +/// @nodoc +class __$$RegisterConsultantStateImplCopyWithImpl<$Res> + extends _$RegisterConsultantStateCopyWithImpl<$Res, + _$RegisterConsultantStateImpl> + implements _$$RegisterConsultantStateImplCopyWith<$Res> { + __$$RegisterConsultantStateImplCopyWithImpl( + _$RegisterConsultantStateImpl _value, + $Res Function(_$RegisterConsultantStateImpl) _then) + : super(_value, _then); + + /// Create a copy of RegisterConsultantState + /// with the given fields replaced by the non-null parameter values. + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? consultant = null, + }) { + return _then(_$RegisterConsultantStateImpl( + consultant: null == consultant + ? _value.consultant + : consultant // ignore: cast_nullable_to_non_nullable + as ConsultantProfileModel, + )); + } +} + +/// @nodoc + +class _$RegisterConsultantStateImpl implements _RegisterConsultantState { + const _$RegisterConsultantStateImpl({required this.consultant}); + + @override + final ConsultantProfileModel consultant; + + @override + String toString() { + return 'RegisterConsultantState(consultant: $consultant)'; + } + + @override + bool operator ==(Object other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$RegisterConsultantStateImpl && + (identical(other.consultant, consultant) || + other.consultant == consultant)); + } + + @override + int get hashCode => Object.hash(runtimeType, consultant); + + /// Create a copy of RegisterConsultantState + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + @override + @pragma('vm:prefer-inline') + _$$RegisterConsultantStateImplCopyWith<_$RegisterConsultantStateImpl> + get copyWith => __$$RegisterConsultantStateImplCopyWithImpl< + _$RegisterConsultantStateImpl>(this, _$identity); +} + +abstract class _RegisterConsultantState implements RegisterConsultantState { + const factory _RegisterConsultantState( + {required final ConsultantProfileModel consultant}) = + _$RegisterConsultantStateImpl; + + @override + ConsultantProfileModel get consultant; + + /// Create a copy of RegisterConsultantState + /// with the given fields replaced by the non-null parameter values. + @override + @JsonKey(includeFromJson: false, includeToJson: false) + _$$RegisterConsultantStateImplCopyWith<_$RegisterConsultantStateImpl> + get copyWith => throw _privateConstructorUsedError; +} diff --git a/lib/features/consultant/become_consultant/pages/additional_settings_screen.dart b/lib/features/consultant/become_consultant/presentation/pages/additional_settings_screen.dart similarity index 100% rename from lib/features/consultant/become_consultant/pages/additional_settings_screen.dart rename to lib/features/consultant/become_consultant/presentation/pages/additional_settings_screen.dart diff --git a/lib/features/consultant/become_consultant/pages/become_consultant_screen.dart b/lib/features/consultant/become_consultant/presentation/pages/become_consultant_screen.dart similarity index 100% rename from lib/features/consultant/become_consultant/pages/become_consultant_screen.dart rename to lib/features/consultant/become_consultant/presentation/pages/become_consultant_screen.dart diff --git a/lib/features/consultant/become_consultant/pages/certificates_and_diploms_screen.dart b/lib/features/consultant/become_consultant/presentation/pages/certificates_and_diploms_screen.dart similarity index 100% rename from lib/features/consultant/become_consultant/pages/certificates_and_diploms_screen.dart rename to lib/features/consultant/become_consultant/presentation/pages/certificates_and_diploms_screen.dart diff --git a/lib/features/consultant/become_consultant/pages/last_step_screen.dart b/lib/features/consultant/become_consultant/presentation/pages/last_step_screen.dart similarity index 100% rename from lib/features/consultant/become_consultant/pages/last_step_screen.dart rename to lib/features/consultant/become_consultant/presentation/pages/last_step_screen.dart diff --git a/lib/features/consultant/become_consultant/pages/photo_or_scans_screen.dart b/lib/features/consultant/become_consultant/presentation/pages/photo_or_scans_screen.dart similarity index 100% rename from lib/features/consultant/become_consultant/pages/photo_or_scans_screen.dart rename to lib/features/consultant/become_consultant/presentation/pages/photo_or_scans_screen.dart diff --git a/lib/features/consultant/become_consultant/pages/registration_as_screen.dart b/lib/features/consultant/become_consultant/presentation/pages/registration_as_screen.dart similarity index 100% rename from lib/features/consultant/become_consultant/pages/registration_as_screen.dart rename to lib/features/consultant/become_consultant/presentation/pages/registration_as_screen.dart diff --git a/lib/features/consultant/become_consultant/pages/social_networks_screen.dart b/lib/features/consultant/become_consultant/presentation/pages/social_networks_screen.dart similarity index 100% rename from lib/features/consultant/become_consultant/pages/social_networks_screen.dart rename to lib/features/consultant/become_consultant/presentation/pages/social_networks_screen.dart diff --git a/lib/features/consultant/become_consultant/pages/stepper_become_consultant_screen.dart b/lib/features/consultant/become_consultant/presentation/pages/stepper_become_consultant_screen.dart similarity index 94% rename from lib/features/consultant/become_consultant/pages/stepper_become_consultant_screen.dart rename to lib/features/consultant/become_consultant/presentation/pages/stepper_become_consultant_screen.dart index 2f3a3c83..0617b759 100644 --- a/lib/features/consultant/become_consultant/pages/stepper_become_consultant_screen.dart +++ b/lib/features/consultant/become_consultant/presentation/pages/stepper_become_consultant_screen.dart @@ -1,10 +1,10 @@ import 'package:eatvio_app/core/utils/image_constant.dart'; -import 'package:eatvio_app/features/consultant/become_consultant/pages/additional_settings_screen.dart'; -import 'package:eatvio_app/features/consultant/become_consultant/pages/certificates_and_diploms_screen.dart'; -import 'package:eatvio_app/features/consultant/become_consultant/pages/last_step_screen.dart'; -import 'package:eatvio_app/features/consultant/become_consultant/pages/photo_or_scans_screen.dart'; -import 'package:eatvio_app/features/consultant/become_consultant/pages/registration_as_screen.dart'; -import 'package:eatvio_app/features/consultant/become_consultant/pages/social_networks_screen.dart'; +import 'package:eatvio_app/features/consultant/become_consultant/presentation/pages/additional_settings_screen.dart'; +import 'package:eatvio_app/features/consultant/become_consultant/presentation/pages/certificates_and_diploms_screen.dart'; +import 'package:eatvio_app/features/consultant/become_consultant/presentation/pages/last_step_screen.dart'; +import 'package:eatvio_app/features/consultant/become_consultant/presentation/pages/photo_or_scans_screen.dart'; +import 'package:eatvio_app/features/consultant/become_consultant/presentation/pages/registration_as_screen.dart'; +import 'package:eatvio_app/features/consultant/become_consultant/presentation/pages/social_networks_screen.dart'; import 'package:eatvio_app/theme/theme_helper.dart'; import 'package:eatvio_app/widgets/app_bar/appbar_title_image.dart'; import 'package:flutter/material.dart'; diff --git a/lib/features/consultant/become_consultant/repositories/consultant_repository.dart b/lib/features/consultant/become_consultant/repositories/consultant_repository.dart new file mode 100644 index 00000000..35594b96 --- /dev/null +++ b/lib/features/consultant/become_consultant/repositories/consultant_repository.dart @@ -0,0 +1,51 @@ +import 'dart:io'; +import 'package:eatvio_app/features/consultant/become_consultant/models/consultant_profile_model.dart'; +import 'package:eatvio_app/features/consultant/become_consultant/services/consultant_service.dart'; +import 'package:http_parser/http_parser.dart'; +import 'package:dio/dio.dart'; + +class ConsultantRepository { + final ConsultantService consultantService; + + const ConsultantRepository({ + required this.consultantService, + }); + + Future registerConsultant({ + required ConsultantProfileModel consultant, + }) async { + try { + return await consultantService.consultantRegistration( + consultantModel: consultant.toJson(), + ); + } catch (e) { + print(e); + rethrow; + } + } + + Future> uploadPhotos({ + required List files, + }) async { + try { + final multipartFiles = []; + + for (final file in files) { + final fileBytes = await file.readAsBytes(); + final multipartFile = MultipartFile.fromBytes( + fileBytes, + filename: file.path.split('/').last, + contentType: MediaType('application', 'octet-stream'), + ); + multipartFiles.add(multipartFile); + } + + return await consultantService.uploadPhotos( + photos: multipartFiles.isEmpty ? null : multipartFiles, + ); + } catch (e) { + print(e); + rethrow; + } + } +} diff --git a/lib/features/consultant/become_consultant/services/consultant_service.dart b/lib/features/consultant/become_consultant/services/consultant_service.dart new file mode 100644 index 00000000..ecfe5e14 --- /dev/null +++ b/lib/features/consultant/become_consultant/services/consultant_service.dart @@ -0,0 +1,20 @@ +import 'package:dio/dio.dart'; +import 'package:retrofit/retrofit.dart'; + +part 'consultant_service.g.dart'; + +@RestApi() +abstract class ConsultantService { + factory ConsultantService(Dio dio, {String baseUrl}) = _ConsultantService; + + @POST('/api/consultant_request/registration') + Future consultantRegistration({ + @Body() required Map consultantModel, + }); + + @POST('/api/consultant_request/photos/upload') + @MultiPart() + Future> uploadPhotos({ + @Part(name: 'photos[]', contentType: 'multipart/form-data') List? photos, + }); +} diff --git a/lib/features/consultant/become_consultant/services/consultant_service.g.dart b/lib/features/consultant/become_consultant/services/consultant_service.g.dart new file mode 100644 index 00000000..41bc384c --- /dev/null +++ b/lib/features/consultant/become_consultant/services/consultant_service.g.dart @@ -0,0 +1,118 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'consultant_service.dart'; + +// ************************************************************************** +// RetrofitGenerator +// ************************************************************************** + +// ignore_for_file: unnecessary_brace_in_string_interps,no_leading_underscores_for_local_identifiers,unused_element + +class _ConsultantService implements ConsultantService { + _ConsultantService( + this._dio, { + this.baseUrl, + this.errorLogger, + }); + + final Dio _dio; + + String? baseUrl; + + final ParseErrorLogger? errorLogger; + + @override + Future consultantRegistration( + {required Map consultantModel}) async { + final _extra = {}; + final queryParameters = {}; + final _headers = {}; + final _data = {}; + _data.addAll(consultantModel); + final _options = _setStreamType(Options( + method: 'POST', + headers: _headers, + extra: _extra, + ) + .compose( + _dio.options, + '/api/consultant_request/registration', + queryParameters: queryParameters, + data: _data, + ) + .copyWith( + baseUrl: _combineBaseUrls( + _dio.options.baseUrl, + baseUrl, + ))); + await _dio.fetch(_options); + } + + @override + Future> uploadPhotos({List? photos}) async { + final _extra = {}; + final queryParameters = {}; + queryParameters.removeWhere((k, v) => v == null); + final _headers = {}; + final _data = FormData(); + if (photos != null) { + _data.files.addAll(photos.map((i) => MapEntry('photos[]', i))); + } + final _options = _setStreamType>(Options( + method: 'POST', + headers: _headers, + extra: _extra, + contentType: 'multipart/form-data', + ) + .compose( + _dio.options, + '/api/consultant_request/photos/upload', + queryParameters: queryParameters, + data: _data, + ) + .copyWith( + baseUrl: _combineBaseUrls( + _dio.options.baseUrl, + baseUrl, + ))); + final _result = await _dio.fetch>(_options); + late List _value; + try { + _value = _result.data!.cast(); + } on Object catch (e, s) { + errorLogger?.logError(e, s, _options); + rethrow; + } + return _value; + } + + RequestOptions _setStreamType(RequestOptions requestOptions) { + if (T != dynamic && + !(requestOptions.responseType == ResponseType.bytes || + requestOptions.responseType == ResponseType.stream)) { + if (T == String) { + requestOptions.responseType = ResponseType.plain; + } else { + requestOptions.responseType = ResponseType.json; + } + } + return requestOptions; + } + + String _combineBaseUrls( + String dioBaseUrl, + String? baseUrl, + ) { + if (baseUrl == null || baseUrl.trim().isEmpty) { + return dioBaseUrl; + } + + final url = Uri.parse(baseUrl); + + if (url.isAbsolute) { + return url.toString(); + } + + return Uri.parse(dioBaseUrl).resolveUri(url).toString(); + } +} 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 89406741..52c1c039 100644 --- a/lib/features/registration/presentation/bloc/registration_cubit/registration_cubit.dart +++ b/lib/features/registration/presentation/bloc/registration_cubit/registration_cubit.dart @@ -10,8 +10,9 @@ import 'package:go_router/go_router.dart'; class RegistrationCubit extends Cubit { final RegistrationRepository registrationRepository; - RegistrationCubit({required this.registrationRepository}) - : super( + RegistrationCubit({ + required this.registrationRepository, + }) : super( RegistrationState( sheet: UserRegistrationSheet( firstName: '', diff --git a/lib/locator_service.dart b/lib/locator_service.dart index e51ccc7c..e64ee309 100644 --- a/lib/locator_service.dart +++ b/lib/locator_service.dart @@ -11,6 +11,9 @@ import 'package:eatvio_app/features/chat/presentation/bloc/chat_room_cubit/chat_ import 'package:eatvio_app/features/chat/presentation/bloc/chat_select_cubit/chat_select_cubit.dart'; import 'package:eatvio_app/features/chat/repositories/chat_repository.dart'; import 'package:eatvio_app/features/chat/services/chat_service.dart'; +import 'package:eatvio_app/features/consultant/become_consultant/presentation/bloc/register_consultant_cubit/register_consultant_cubit.dart'; +import 'package:eatvio_app/features/consultant/become_consultant/repositories/consultant_repository.dart'; +import 'package:eatvio_app/features/consultant/become_consultant/services/consultant_service.dart'; import 'package:eatvio_app/features/diary/presentation/bloc/diary_bloc.dart'; import 'package:eatvio_app/features/diary/repositories/diary_repository.dart'; import 'package:eatvio_app/features/diary/services/diary_service.dart'; @@ -60,6 +63,7 @@ Future init() async { sl.registerFactory(() => ChatSelectCubit(chatRepository: sl())); sl.registerFactory(() => PlansCubit(plansRepository: sl())); sl.registerFactory(() => SettingsCubit(profileRepository: sl(), settingsRepository: sl())); + sl.registerFactory(() => RegisterConsultantCubit(consultantRepository: sl())); // Repository sl.registerLazySingleton(() => ChatRepository(chatService: sl())); @@ -71,6 +75,7 @@ Future init() async { sl.registerLazySingleton(() => RecipeRepository(recipeService: sl())); sl.registerLazySingleton(() => PlansRepository(plansService: sl())); sl.registerLazySingleton(() => SettingsRepository(settingsService: sl())); + sl.registerLazySingleton(() => ConsultantRepository(consultantService: sl())); // Services sl.registerLazySingleton(() => ChatService(sl())); @@ -82,6 +87,7 @@ Future init() async { sl.registerLazySingleton(() => RecipeService(sl())); sl.registerLazySingleton(() => PlansService(sl())); sl.registerLazySingleton(() => SettingsService(sl())); + sl.registerLazySingleton(() => ConsultantService(sl())); // External sl.registerLazySingleton( diff --git a/lib/old/feed/blog_post_create_screen/bloc/blog_post_create_bloc.dart b/lib/old/feed/blog_post_create_screen/bloc/blog_post_create_bloc.dart index 15e80977..836b8dc9 100644 --- a/lib/old/feed/blog_post_create_screen/bloc/blog_post_create_bloc.dart +++ b/lib/old/feed/blog_post_create_screen/bloc/blog_post_create_bloc.dart @@ -81,8 +81,8 @@ class BlogPostCreateBloc extends Bloc FormData formData = FormData.fromMap({ 'title': title, 'description': description, - 'youtube_url': youtubeURL, 'state': 'active', + 'youtube_url': youtubeURL, 'image': await MultipartFile.fromFile(image!.path, filename: image.name), });