fix(rating_consultant): Issue-513

This commit is contained in:
mso7nueh
2025-10-03 16:57:22 +03:00
parent 086e6cf94e
commit 37cedb2238
13 changed files with 56 additions and 71 deletions

View File

@@ -0,0 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" height="24px" viewBox="0 -960 960 960" width="24px" fill="#2F80ED"><path d="M759.23-353.08q8.92-8.92 21.19-8.92 12.27 0 21.19 8.92l63.39 64q8.92 9.07 8.92 21.15 0 12.08-8.92 21.01-8.92 8.92-21.01 8.92-12.08 0-21.14-8.92l-64-63.39q-8.93-8.92-8.73-21.38.19-12.46 9.11-21.39Zm33.85-472.22q8.92 9 8.92 21.38 0 12.38-8.92 21.3l-63.39 63.39q-8.92 8.92-21.19 8.92-12.27 0-21.19-9-8.92-9.01-8.92-21.39t8.92-21.3l63.61-63.38q9.07-8.93 21.15-8.93 12.08 0 21.01 9.01ZM167-825q9.01-8.92 21.39-8.92t21.3 8.92l63.39 63.62q8.92 9.06 8.92 21.14 0 12.09-9 21.01-9.01 8.92-21.39 8.92t-21.3-8.92l-63.39-63.39q-8.92-8.92-8.92-21.19 0-12.27 9-21.19Zm33.77 472.31q8.92 8.92 8.92 21.19 0 12.27-8.92 21.19l-63.39 63.39q-8.92 8.92-21.19 8.92-12.27 0-21.19-9-8.92-9.01-8.92-21.39t8.92-21.3l63.62-63.39q8.92-8.92 21.07-8.73 12.16.2 21.08 9.12Zm135.54 86.85L480-352.23l144.08 87.77-37.62-163.62 126.39-109.07-166.39-14.93L480-706.54l-66.08 153.46-166.38 14.54 126.38 110.46-37.61 162.24ZM480.38-486ZM480-281.31 306.69-177.08q-8.69 5.08-17.42 4.27-8.73-.81-15.81-5.88-7.07-5.08-10.92-13.27-3.85-8.19-1.23-18.12L307.23-406 154.08-538.39q-7.69-6.83-9.62-15.57-1.92-8.73 1.31-17.04 3.23-8.31 9.28-13.62 6.05-5.32 16.64-6.84l201.7-17.39 78.46-185.3q3.84-9.31 11.65-13.77 7.81-4.46 16.5-4.46 8.69 0 16.5 4.46 7.81 4.46 11.65 13.77L587-608.85l201.69 17.39q10.68 1.51 16.78 6.82 6.1 5.3 9.14 13.64 3.24 8.31 1.31 17.04-1.92 8.74-9.61 15.57L653.15-406l45.93 196.31q2.61 9.92-1.23 17.92-3.85 8-10.93 13.08-7.07 5.07-15.8 5.88-8.73.81-17.43-4.27L480-281.31Z"/></svg>

After

Width:  |  Height:  |  Size: 1.5 KiB

View File

@@ -135,7 +135,7 @@ class CubitRegistrations {
sl.registerFactory<UserPurchasesCubit>(() => UserPurchasesCubit(consultationsRepository: sl()));
sl.registerFactory<BlockedUsersCubit>(() => BlockedUsersCubit(blockedUsersRepository: sl()));
sl.registerFactory<NotificationSettingsCubit>(() => NotificationSettingsCubit(notificationSettingsRepository: sl()));
sl.registerFactory<ConsultantRatingCubit>(() => ConsultantRatingCubit(sl()));
sl.registerFactory<ConsultantRatingCubit>(() => ConsultantRatingCubit(feedRepository: sl(), repository: sl(), profileRepository: sl()));
sl.registerFactory<ViewsCubit>(() => ViewsCubit(viewsRepository: sl()));
sl.registerFactory<UserDetailsCubit>(() => UserDetailsCubit(profileRepository: sl()));
}

View File

@@ -13,6 +13,7 @@ abstract class StatisticsModel with _$StatisticsModel {
@JsonKey(name: 'count_diets') int? dietsCount,
@JsonKey(name: 'count_consultants') int? consultationsCount,
@JsonKey(name: 'count_products_nutritional_values') int? qwe,
@JsonKey(name: 'referral_link') String? refLink,
}) = _StatisticsModel;
factory StatisticsModel.fromJson(Map<String, dynamic> json) => _$StatisticsModelFromJson(json);

View File

@@ -1,6 +1,7 @@
import 'package:eatvio_app/core/locator_service.dart';
import 'package:eatvio_app/core/theme/custom_text_style.dart';
import 'package:eatvio_app/core/theme/theme_helper.dart';
import 'package:eatvio_app/core/utils/toasts.dart';
import 'package:eatvio_app/core/widgets/custom_outlined_button.dart';
import 'package:eatvio_app/core/widgets/data_error_widget.dart';
import 'package:eatvio_app/features/consultant_rating/presentation/cubit/consultant_rating_cubit.dart';
@@ -10,6 +11,7 @@ import 'package:eatvio_app/features/consultant_rating/presentation/widgets/ratin
import 'package:eatvio_app/features/consultant_rating/presentation/widgets/statistic_widget.dart';
import 'package:eatvio_app/generated/l10n.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
class ConsultantRatingScreen extends StatelessWidget {
@@ -53,8 +55,8 @@ class ConsultantRatingPageContent extends StatelessWidget {
child: Column(
children: [
const SizedBox(height: 16),
const RatingWidget(
rating: 1058,
RatingWidget(
rating: state.absoluteRating!,
),
const SizedBox(height: 16),
Padding(
@@ -67,7 +69,10 @@ class ConsultantRatingPageContent extends StatelessWidget {
side: const WidgetStatePropertyAll(BorderSide.none),
backgroundColor: WidgetStatePropertyAll(appTheme.blueA400),
),
onPressed: () {},
onPressed: () {
Clipboard.setData(ClipboardData(text: state.statistics?.refLink ?? ''));
showInfoToast(s.link_was_copied);
},
),
),
const SizedBox(height: 16),

View File

@@ -2,17 +2,23 @@ import 'dart:developer';
import 'package:eatvio_app/features/consultant_rating/presentation/cubit/consultant_rating_state.dart';
import 'package:eatvio_app/features/consultant_rating/repositories/consultant_rating_repository.dart';
import 'package:eatvio_app/features/feed/repositories/feed_repository.dart';
import 'package:eatvio_app/features/profile/repositories/profile_repository.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
class ConsultantRatingCubit extends Cubit<ConsultantRatingState> {
final ConsultantRatingRepository repository;
ConsultantRatingCubit(this.repository) : super(ConsultantRatingState());
final FeedRepository feedRepository;
final ProfileRepository profileRepository;
ConsultantRatingCubit({required this.repository, required this.feedRepository, required this.profileRepository}) : super(ConsultantRatingState());
Future<void> getConsultantStatistics({String? date}) async {
try {
emit(state.copyWith(isStatisticsLoading: true));
final statistics = await repository.getConsultantStatistics(date: date);
emit(state.copyWith(isStatisticsLoading: false, statistics: statistics, error: null));
final absoluteRating = await feedRepository.getConsultants((await profileRepository.getMyProfile()).name);
emit(state.copyWith(isStatisticsLoading: false, statistics: statistics, error: null, absoluteRating: absoluteRating.first.totalScores));
} catch (e, st) {
emit(state.copyWith(isStatisticsLoading: true, error: e.toString()));
log(e.toString(), stackTrace: st);

View File

@@ -12,5 +12,6 @@ abstract class ConsultantRatingState with _$ConsultantRatingState {
@Default(null) StatisticsModel? statistics,
@Default(null) String? error,
@Default(<RatingModel>[]) List<RatingModel> ratings,
@Default(0) int? absoluteRating,
}) = _ConsultantRatingState;
}

View File

@@ -71,7 +71,7 @@ class StatisticWidget extends StatelessWidget {
children: [
Expanded(child: StatisticBouble(number: statistics?.consultationsCount ?? 0, title: s.consultations_count)),
const SizedBox(width: 8),
Expanded(child: StatisticBouble(number: statistics?.qwe ?? 0, title: s.active_consultations_count)),
Expanded(child: StatisticBouble(number: statistics?.qwe ?? 0, title: s.added_products_in_glossary)),
],
),
const SizedBox(

View File

@@ -133,9 +133,9 @@ class FeedRepository {
}
}
Future<List<FeedConsultantModel>> getConsultants() async {
Future<List<FeedConsultantModel>> getConsultants([String? name]) async {
try {
return (await feedService.getConsultants()).data;
return (await feedService.getConsultants(name: name)).data;
} catch (e) {
rethrow;
}

View File

@@ -16,15 +16,10 @@ abstract class FeedService {
factory FeedService(Dio dio, {String baseUrl}) = _FeedService;
@GET('/api/blogPosts/index')
Future<FeedBlogPostSettingsModel> getBlogPostList({
@Query('page') required int page,
@Query('query_search') String? query,
});
Future<FeedBlogPostSettingsModel> getBlogPostList({@Query('page') required int page, @Query('query_search') String? query});
@GET('/api/blogPosts/show/{postId}')
Future<FeedBlogPostModel> getBlogPost({
@Path('postId') required int postId,
});
Future<FeedBlogPostModel> getBlogPost({@Path('postId') required int postId});
@GET('/api/recipes/index')
Future<RecipesPagination> getRecipes({
@@ -53,88 +48,50 @@ abstract class FeedService {
});
@GET('/api/blogPosts/{id}/comments/show')
Future<CommentModel> getBlogPostComments({
@Path() required String id,
});
Future<CommentModel> getBlogPostComments({@Path() required String id});
@POST('/api/blogPosts/{id}/comment/create')
Future<void> sendBlogPostComment({
@Path() required String id,
@Part() required String body,
@Part() int? parentCommentId,
});
Future<void> sendBlogPostComment({@Path() required String id, @Part() required String body, @Part() int? parentCommentId});
@GET('/api/diets/{id}/comments/show')
Future<CommentModel> getDietsComments({
@Path() required String id,
});
Future<CommentModel> getDietsComments({@Path() required String id});
@POST('/api/diets/{id}/comment/create')
Future<void> sendDietsComment({
@Path() required String id,
@Part() required String body,
@Part() int? parentCommentId,
});
Future<void> sendDietsComment({@Path() required String id, @Part() required String body, @Part() int? parentCommentId});
@GET('/api/plans/{slug}/comments/show')
Future<CommentModel> getPlansComments({
@Path() required String slug,
});
Future<CommentModel> getPlansComments({@Path() required String slug});
@POST('/api/plans/{slug}/comment/create')
Future<void> sendPlansComment({
@Path() required String slug,
@Part() required String body,
@Part() int? parentCommentId,
});
Future<void> sendPlansComment({@Path() required String slug, @Part() required String body, @Part() int? parentCommentId});
@GET('/api/recipes/{id}/comments/show')
Future<CommentModel> getRecipesComments({
@Path() required String id,
});
Future<CommentModel> getRecipesComments({@Path() required String id});
@POST('/api/recipes/{id}/comment/create')
Future<void> sendRecipesComment({
@Path() required String id,
@Part() required String body,
@Part() int? parentCommentId,
});
Future<void> sendRecipesComment({@Path() required String id, @Part() required String body, @Part() int? parentCommentId});
@POST('/api/blogPosts/{id}/like')
Future<void> likeBlogPost({
@Path() required int id,
});
Future<void> likeBlogPost({@Path() required int id});
@POST('/api/blogPosts/{id}/unliked')
Future<void> unlikedBlogPost({
@Path() required int id,
});
Future<void> unlikedBlogPost({@Path() required int id});
@GET('/api/consultants/index')
Future<FeedConsultantPaginationModel> getConsultants();
Future<FeedConsultantPaginationModel> getConsultants({@Query('filters[name][\$startsWith]') String? name});
@POST('/api/blogPosts/{id}/view')
Future<void> viewPost({
@Path() required int id,
});
Future<void> viewPost({@Path() required int id});
@POST('/api/recipes/{slug}/view')
Future<void> viewRecipe({
@Path() required String slug,
});
Future<void> viewRecipe({@Path() required String slug});
@POST('/api/diets/{id}/view')
Future<void> viewDiet({
@Path() required int id,
});
Future<void> viewDiet({@Path() required int id});
@POST('/api/plans/{slug}/view')
Future<void> viewPlan({
@Path() required String slug,
});
Future<void> viewPlan({@Path() required String slug});
@POST('/api/views')
Future<void> viewContent({
@Body() required ViewModel viewModel,
});
Future<void> viewContent({@Body() required ViewModel viewModel});
}

View File

@@ -58,7 +58,7 @@ class MenuScreen extends StatelessWidget {
if (profileModel.roles.contains('consultant')) _divider(context),
if (profileModel.roles.contains('consultant'))
_tile(
leading: 'assets/icons/finance.svg',
leading: 'assets/icons/consultant_rating_icon.svg',
title: 'Мой рейтинг',
onTap: () {
GoRouter.of(context).push(ConsultantRatingScreen.path);

View File

@@ -66,6 +66,9 @@ class MessageLookup extends MessageLookupByLibrary {
"add_card": MessageLookupByLibrary.simpleMessage("Привязать карту"),
"add_cover": MessageLookupByLibrary.simpleMessage("Добавьте обложку"),
"add_measure": MessageLookupByLibrary.simpleMessage("Добавить замер"),
"added_products_in_glossary": MessageLookupByLibrary.simpleMessage(
"Кол-во продуктов добавленных в глоссарий",
),
"adding_plan": MessageLookupByLibrary.simpleMessage("Добавление плана"),
"additional_information": MessageLookupByLibrary.simpleMessage(
"Дополнительная информация",

View File

@@ -2399,6 +2399,16 @@ class S {
);
}
/// `Кол-во продуктов добавленных в глоссарий`
String get added_products_in_glossary {
return Intl.message(
'Кол-во продуктов добавленных в глоссарий',
name: 'added_products_in_glossary',
desc: '',
args: [],
);
}
/// `Кол-во активных консультаций`
String get active_consultations_count {
return Intl.message(

View File

@@ -300,6 +300,7 @@
"published_recipes_count": "Кол-во опубликованных рецептов",
"published_diets_count": "Кол-во опубликованных диет",
"consultations_count": "Кол-во проведенных консулдьтаций",
"added_products_in_glossary": "Кол-во продуктов добавленных в глоссарий",
"active_consultations_count": "Кол-во активных консультаций",
"rating_history": "Начисление рейтинга",
"something_went_wrong": "Упс! Что-то пошло не так",