feature: consultant registration

This commit is contained in:
mso7nueh
2024-10-14 15:07:07 +03:00
parent 1462334155
commit 78be72372c
12 changed files with 244 additions and 143 deletions

View File

@@ -19,6 +19,7 @@ class SettingsCubit extends Cubit<SettingsState> {
emit(SettingsState.loaded(
profileSettings: await settingsRepository.getProfileSettings(),
profileDetails: await profileRepository.getMyProfileDetails(),
profile: await profileRepository.getMyProfile(),
));
} catch (e) {
emit(SettingsState.error(errorMessage: e.toString()));

View File

@@ -13,6 +13,7 @@ abstract class SettingsState with _$SettingsState {
const factory SettingsState.loaded({
required ProfileSettingsModel profileSettings,
required ProfileDetailsModel profileDetails,
required ProfileModel profile,
}) = SettingsStateLoaded;
const factory SettingsState.error({

View File

@@ -21,7 +21,7 @@ mixin _$SettingsState {
TResult Function() $default, {
required TResult Function() loading,
required TResult Function(ProfileSettingsModel profileSettings,
ProfileDetailsModel profileDetails)
ProfileDetailsModel profileDetails, ProfileModel profile)
loaded,
required TResult Function(String errorMessage) error,
}) =>
@@ -31,7 +31,7 @@ mixin _$SettingsState {
TResult? Function()? $default, {
TResult? Function()? loading,
TResult? Function(ProfileSettingsModel profileSettings,
ProfileDetailsModel profileDetails)?
ProfileDetailsModel profileDetails, ProfileModel profile)?
loaded,
TResult? Function(String errorMessage)? error,
}) =>
@@ -41,7 +41,7 @@ mixin _$SettingsState {
TResult Function()? $default, {
TResult Function()? loading,
TResult Function(ProfileSettingsModel profileSettings,
ProfileDetailsModel profileDetails)?
ProfileDetailsModel profileDetails, ProfileModel profile)?
loaded,
TResult Function(String errorMessage)? error,
required TResult orElse(),
@@ -139,7 +139,7 @@ class _$SettingsStateImpl implements _SettingsState {
TResult Function() $default, {
required TResult Function() loading,
required TResult Function(ProfileSettingsModel profileSettings,
ProfileDetailsModel profileDetails)
ProfileDetailsModel profileDetails, ProfileModel profile)
loaded,
required TResult Function(String errorMessage) error,
}) {
@@ -152,7 +152,7 @@ class _$SettingsStateImpl implements _SettingsState {
TResult? Function()? $default, {
TResult? Function()? loading,
TResult? Function(ProfileSettingsModel profileSettings,
ProfileDetailsModel profileDetails)?
ProfileDetailsModel profileDetails, ProfileModel profile)?
loaded,
TResult? Function(String errorMessage)? error,
}) {
@@ -165,7 +165,7 @@ class _$SettingsStateImpl implements _SettingsState {
TResult Function()? $default, {
TResult Function()? loading,
TResult Function(ProfileSettingsModel profileSettings,
ProfileDetailsModel profileDetails)?
ProfileDetailsModel profileDetails, ProfileModel profile)?
loaded,
TResult Function(String errorMessage)? error,
required TResult orElse(),
@@ -263,7 +263,7 @@ class _$SettingsStateLoadingImpl implements SettingsStateLoading {
TResult Function() $default, {
required TResult Function() loading,
required TResult Function(ProfileSettingsModel profileSettings,
ProfileDetailsModel profileDetails)
ProfileDetailsModel profileDetails, ProfileModel profile)
loaded,
required TResult Function(String errorMessage) error,
}) {
@@ -276,7 +276,7 @@ class _$SettingsStateLoadingImpl implements SettingsStateLoading {
TResult? Function()? $default, {
TResult? Function()? loading,
TResult? Function(ProfileSettingsModel profileSettings,
ProfileDetailsModel profileDetails)?
ProfileDetailsModel profileDetails, ProfileModel profile)?
loaded,
TResult? Function(String errorMessage)? error,
}) {
@@ -289,7 +289,7 @@ class _$SettingsStateLoadingImpl implements SettingsStateLoading {
TResult Function()? $default, {
TResult Function()? loading,
TResult Function(ProfileSettingsModel profileSettings,
ProfileDetailsModel profileDetails)?
ProfileDetailsModel profileDetails, ProfileModel profile)?
loaded,
TResult Function(String errorMessage)? error,
required TResult orElse(),
@@ -350,10 +350,12 @@ abstract class _$$SettingsStateLoadedImplCopyWith<$Res> {
@useResult
$Res call(
{ProfileSettingsModel profileSettings,
ProfileDetailsModel profileDetails});
ProfileDetailsModel profileDetails,
ProfileModel profile});
$ProfileSettingsModelCopyWith<$Res> get profileSettings;
$ProfileDetailsModelCopyWith<$Res> get profileDetails;
$ProfileModelCopyWith<$Res> get profile;
}
/// @nodoc
@@ -371,6 +373,7 @@ class __$$SettingsStateLoadedImplCopyWithImpl<$Res>
$Res call({
Object? profileSettings = null,
Object? profileDetails = null,
Object? profile = null,
}) {
return _then(_$SettingsStateLoadedImpl(
profileSettings: null == profileSettings
@@ -381,6 +384,10 @@ class __$$SettingsStateLoadedImplCopyWithImpl<$Res>
? _value.profileDetails
: profileDetails // ignore: cast_nullable_to_non_nullable
as ProfileDetailsModel,
profile: null == profile
? _value.profile
: profile // ignore: cast_nullable_to_non_nullable
as ProfileModel,
));
}
@@ -403,22 +410,36 @@ class __$$SettingsStateLoadedImplCopyWithImpl<$Res>
return _then(_value.copyWith(profileDetails: value));
});
}
/// Create a copy of SettingsState
/// with the given fields replaced by the non-null parameter values.
@override
@pragma('vm:prefer-inline')
$ProfileModelCopyWith<$Res> get profile {
return $ProfileModelCopyWith<$Res>(_value.profile, (value) {
return _then(_value.copyWith(profile: value));
});
}
}
/// @nodoc
class _$SettingsStateLoadedImpl implements SettingsStateLoaded {
const _$SettingsStateLoadedImpl(
{required this.profileSettings, required this.profileDetails});
{required this.profileSettings,
required this.profileDetails,
required this.profile});
@override
final ProfileSettingsModel profileSettings;
@override
final ProfileDetailsModel profileDetails;
@override
final ProfileModel profile;
@override
String toString() {
return 'SettingsState.loaded(profileSettings: $profileSettings, profileDetails: $profileDetails)';
return 'SettingsState.loaded(profileSettings: $profileSettings, profileDetails: $profileDetails, profile: $profile)';
}
@override
@@ -429,11 +450,13 @@ class _$SettingsStateLoadedImpl implements SettingsStateLoaded {
(identical(other.profileSettings, profileSettings) ||
other.profileSettings == profileSettings) &&
(identical(other.profileDetails, profileDetails) ||
other.profileDetails == profileDetails));
other.profileDetails == profileDetails) &&
(identical(other.profile, profile) || other.profile == profile));
}
@override
int get hashCode => Object.hash(runtimeType, profileSettings, profileDetails);
int get hashCode =>
Object.hash(runtimeType, profileSettings, profileDetails, profile);
/// Create a copy of SettingsState
/// with the given fields replaced by the non-null parameter values.
@@ -450,11 +473,11 @@ class _$SettingsStateLoadedImpl implements SettingsStateLoaded {
TResult Function() $default, {
required TResult Function() loading,
required TResult Function(ProfileSettingsModel profileSettings,
ProfileDetailsModel profileDetails)
ProfileDetailsModel profileDetails, ProfileModel profile)
loaded,
required TResult Function(String errorMessage) error,
}) {
return loaded(profileSettings, profileDetails);
return loaded(profileSettings, profileDetails, profile);
}
@override
@@ -463,11 +486,11 @@ class _$SettingsStateLoadedImpl implements SettingsStateLoaded {
TResult? Function()? $default, {
TResult? Function()? loading,
TResult? Function(ProfileSettingsModel profileSettings,
ProfileDetailsModel profileDetails)?
ProfileDetailsModel profileDetails, ProfileModel profile)?
loaded,
TResult? Function(String errorMessage)? error,
}) {
return loaded?.call(profileSettings, profileDetails);
return loaded?.call(profileSettings, profileDetails, profile);
}
@override
@@ -476,13 +499,13 @@ class _$SettingsStateLoadedImpl implements SettingsStateLoaded {
TResult Function()? $default, {
TResult Function()? loading,
TResult Function(ProfileSettingsModel profileSettings,
ProfileDetailsModel profileDetails)?
ProfileDetailsModel profileDetails, ProfileModel profile)?
loaded,
TResult Function(String errorMessage)? error,
required TResult orElse(),
}) {
if (loaded != null) {
return loaded(profileSettings, profileDetails);
return loaded(profileSettings, profileDetails, profile);
}
return orElse();
}
@@ -527,12 +550,13 @@ class _$SettingsStateLoadedImpl implements SettingsStateLoaded {
abstract class SettingsStateLoaded implements SettingsState {
const factory SettingsStateLoaded(
{required final ProfileSettingsModel profileSettings,
required final ProfileDetailsModel profileDetails}) =
_$SettingsStateLoadedImpl;
{required final ProfileSettingsModel profileSettings,
required final ProfileDetailsModel profileDetails,
required final ProfileModel profile}) = _$SettingsStateLoadedImpl;
ProfileSettingsModel get profileSettings;
ProfileDetailsModel get profileDetails;
ProfileModel get profile;
/// Create a copy of SettingsState
/// with the given fields replaced by the non-null parameter values.
@@ -614,7 +638,7 @@ class _$SettingsStateErrorImpl implements SettingsStateError {
TResult Function() $default, {
required TResult Function() loading,
required TResult Function(ProfileSettingsModel profileSettings,
ProfileDetailsModel profileDetails)
ProfileDetailsModel profileDetails, ProfileModel profile)
loaded,
required TResult Function(String errorMessage) error,
}) {
@@ -627,7 +651,7 @@ class _$SettingsStateErrorImpl implements SettingsStateError {
TResult? Function()? $default, {
TResult? Function()? loading,
TResult? Function(ProfileSettingsModel profileSettings,
ProfileDetailsModel profileDetails)?
ProfileDetailsModel profileDetails, ProfileModel profile)?
loaded,
TResult? Function(String errorMessage)? error,
}) {
@@ -640,7 +664,7 @@ class _$SettingsStateErrorImpl implements SettingsStateError {
TResult Function()? $default, {
TResult Function()? loading,
TResult Function(ProfileSettingsModel profileSettings,
ProfileDetailsModel profileDetails)?
ProfileDetailsModel profileDetails, ProfileModel profile)?
loaded,
TResult Function(String errorMessage)? error,
required TResult orElse(),

View File

@@ -56,8 +56,11 @@ class _SettingsScreenState extends State<SettingsScreen> {
const SizedBox(height: 12),
_aboutEatvio(state),
const SizedBox(height: 12),
_becomeConsultantButton(state),
const SizedBox(height: 8),
if (state.profile.role != 'consultant')
Padding(
padding: const EdgeInsets.only(bottom: 8),
child: _becomeConsultantButton(state),
),
_deleteAccountButton(state),
],
),
@@ -213,10 +216,10 @@ class _SettingsScreenState extends State<SettingsScreen> {
updatesNotificationsSwitchState = !updatesNotificationsSwitchState;
});
settingsCubit.updateProfileSettings(
profileSettingsModel: state.profileSettings.copyWith(
newUpdatesNotifications: updatesNotificationsSwitchState,
),
);
profileSettingsModel: state.profileSettings.copyWith(
newUpdatesNotifications: updatesNotificationsSwitchState,
),
);
},
title: 'Уведомление о новых обновлениях',
trailing: CupertinoSwitch(
@@ -227,10 +230,10 @@ class _SettingsScreenState extends State<SettingsScreen> {
updatesNotificationsSwitchState = newValue;
});
settingsCubit.updateProfileSettings(
profileSettingsModel: state.profileSettings.copyWith(
newUpdatesNotifications: updatesNotificationsSwitchState,
),
);
profileSettingsModel: state.profileSettings.copyWith(
newUpdatesNotifications: updatesNotificationsSwitchState,
),
);
},
),
),
@@ -242,10 +245,10 @@ class _SettingsScreenState extends State<SettingsScreen> {
fillDiaryNotificationsSwitchState = !fillDiaryNotificationsSwitchState;
});
settingsCubit.updateProfileSettings(
profileSettingsModel: state.profileSettings.copyWith(
diaryReminderNotifications: fillDiaryNotificationsSwitchState,
),
);
profileSettingsModel: state.profileSettings.copyWith(
diaryReminderNotifications: fillDiaryNotificationsSwitchState,
),
);
},
title: 'Напоминание о заполнении дневника',
trailing: CupertinoSwitch(
@@ -256,10 +259,10 @@ class _SettingsScreenState extends State<SettingsScreen> {
fillDiaryNotificationsSwitchState = newValue;
});
settingsCubit.updateProfileSettings(
profileSettingsModel: state.profileSettings.copyWith(
diaryReminderNotifications: fillDiaryNotificationsSwitchState,
),
);
profileSettingsModel: state.profileSettings.copyWith(
diaryReminderNotifications: fillDiaryNotificationsSwitchState,
),
);
},
),
),
@@ -271,10 +274,10 @@ class _SettingsScreenState extends State<SettingsScreen> {
moodSwitchState = !moodSwitchState;
});
settingsCubit.updateProfileSettings(
profileSettingsModel: state.profileSettings.copyWith(
isMoodFillable: moodSwitchState,
),
);
profileSettingsModel: state.profileSettings.copyWith(
isMoodFillable: moodSwitchState,
),
);
},
title: 'Указывать “настроение” в заполнение дневника',
trailing: CupertinoSwitch(
@@ -285,10 +288,10 @@ class _SettingsScreenState extends State<SettingsScreen> {
moodSwitchState = newValue;
});
settingsCubit.updateProfileSettings(
profileSettingsModel: state.profileSettings.copyWith(
isMoodFillable: moodSwitchState,
),
);
profileSettingsModel: state.profileSettings.copyWith(
isMoodFillable: moodSwitchState,
),
);
},
),
),
@@ -300,10 +303,10 @@ class _SettingsScreenState extends State<SettingsScreen> {
bedTimeSwitchState = !bedTimeSwitchState;
});
settingsCubit.updateProfileSettings(
profileSettingsModel: state.profileSettings.copyWith(
isBedtimeFillable: bedTimeSwitchState,
),
);
profileSettingsModel: state.profileSettings.copyWith(
isBedtimeFillable: bedTimeSwitchState,
),
);
},
title: 'Указывать “отход ко сну” в заполнение дневника',
trailing: CupertinoSwitch(
@@ -314,10 +317,10 @@ class _SettingsScreenState extends State<SettingsScreen> {
bedTimeSwitchState = newValue;
});
settingsCubit.updateProfileSettings(
profileSettingsModel: state.profileSettings.copyWith(
isBedtimeFillable: bedTimeSwitchState,
),
);
profileSettingsModel: state.profileSettings.copyWith(
isBedtimeFillable: bedTimeSwitchState,
),
);
},
),
),