forked from eatvio/eatvio_app
feat(profile): Описание профиля (статус)
This commit is contained in:
@@ -18,11 +18,13 @@ class ProfileCubit extends Cubit<ProfileState> {
|
||||
|
||||
getProfileBySlug(String slug) async {
|
||||
try {
|
||||
emit(ProfileState.loaded(
|
||||
profile: await profileRepository.getProfileBySlug(slug),
|
||||
profileDetails: await profileRepository.getMyProfileDetails(),
|
||||
blogPosts: await profileRepository.getBlogPostsByAuthorSlug(slug: slug),
|
||||
),);
|
||||
emit(
|
||||
ProfileState.loaded(
|
||||
profile: await profileRepository.getProfileBySlug(slug),
|
||||
profileDetails: await profileRepository.getProfileDetailsBySlug(slug),
|
||||
blogPosts: await profileRepository.getBlogPostsByAuthorSlug(slug: slug),
|
||||
),
|
||||
);
|
||||
} catch (e) {
|
||||
emit(ProfileState.error(errorMessage: e.toString()));
|
||||
}
|
||||
@@ -34,13 +36,15 @@ class ProfileCubit extends Cubit<ProfileState> {
|
||||
_currentPeriod = period;
|
||||
try {
|
||||
final profile = await profileRepository.getMyProfile();
|
||||
emit(ProfileState.loaded(
|
||||
profile: profile,
|
||||
profileDetails: await profileRepository.getMyProfileDetails(),
|
||||
blogPosts: await profileRepository.getBlogPostsByAuthorSlug(slug: profile.slug),
|
||||
weightPoints: await profileRepository.getWeight(period: period),
|
||||
circumferencePoints: await profileRepository.getCircumferences(period: period),
|
||||
),);
|
||||
emit(
|
||||
ProfileState.loaded(
|
||||
profile: profile,
|
||||
profileDetails: await profileRepository.getMyProfileDetails(),
|
||||
blogPosts: await profileRepository.getBlogPostsByAuthorSlug(slug: profile.slug),
|
||||
weightPoints: await profileRepository.getWeight(period: period),
|
||||
circumferencePoints: await profileRepository.getCircumferences(period: period),
|
||||
),
|
||||
);
|
||||
} catch (e) {
|
||||
emit(ProfileState.error(errorMessage: e.toString()));
|
||||
}
|
||||
|
||||
@@ -22,6 +22,14 @@ class ProfileRepository {
|
||||
}
|
||||
}
|
||||
|
||||
Future<ProfileDetailsModel> getProfileDetailsBySlug(String slug) async {
|
||||
try {
|
||||
return await profileService.getProfileDetailsBySlug(slug: slug);
|
||||
} catch (e) {
|
||||
rethrow;
|
||||
}
|
||||
}
|
||||
|
||||
Future<ProfileModel> getMyProfile() async {
|
||||
try {
|
||||
return await profileService.getMyProfile();
|
||||
|
||||
@@ -25,6 +25,11 @@ abstract class ProfileService {
|
||||
@GET('/api/profile/detailz')
|
||||
Future<ProfileDetailsModel> getMyProfileDetails();
|
||||
|
||||
@GET('/api/profile/detailz/{slug}')
|
||||
Future<ProfileDetailsModel> getProfileDetailsBySlug({
|
||||
@Path() required String slug,
|
||||
});
|
||||
|
||||
@POST('/api/profile/addCircumference')
|
||||
Future<void> addCircumference({
|
||||
@Part(name: 'chest_circumference') required int chestCircumference,
|
||||
|
||||
@@ -120,6 +120,40 @@ class _ProfileService implements ProfileService {
|
||||
return _value;
|
||||
}
|
||||
|
||||
@override
|
||||
Future<ProfileDetailsModel> getProfileDetailsBySlug(
|
||||
{required String slug}) async {
|
||||
final _extra = <String, dynamic>{};
|
||||
final queryParameters = <String, dynamic>{};
|
||||
final _headers = <String, dynamic>{};
|
||||
const Map<String, dynamic>? _data = null;
|
||||
final _options = _setStreamType<ProfileDetailsModel>(Options(
|
||||
method: 'GET',
|
||||
headers: _headers,
|
||||
extra: _extra,
|
||||
)
|
||||
.compose(
|
||||
_dio.options,
|
||||
'/api/profile/detailz/${slug}',
|
||||
queryParameters: queryParameters,
|
||||
data: _data,
|
||||
)
|
||||
.copyWith(
|
||||
baseUrl: _combineBaseUrls(
|
||||
_dio.options.baseUrl,
|
||||
baseUrl,
|
||||
)));
|
||||
final _result = await _dio.fetch<Map<String, dynamic>>(_options);
|
||||
late ProfileDetailsModel _value;
|
||||
try {
|
||||
_value = ProfileDetailsModel.fromJson(_result.data!);
|
||||
} on Object catch (e, s) {
|
||||
errorLogger?.logError(e, s, _options);
|
||||
rethrow;
|
||||
}
|
||||
return _value;
|
||||
}
|
||||
|
||||
@override
|
||||
Future<void> addCircumference({
|
||||
required int chestCircumference,
|
||||
|
||||
Reference in New Issue
Block a user