forked from eatvio/eatvio_app
Merge remote-tracking branch 'upstream_main' into HEAD
# Conflicts: # lib/generated/intl/messages_en.dart # lib/generated/intl/messages_ru.dart
This commit is contained in:
@@ -12,7 +12,11 @@ part 'auth_service.g.dart';
|
||||
|
||||
@RestApi()
|
||||
abstract class AuthService {
|
||||
factory AuthService(Dio dio, {String? baseUrl}) = _AuthService;
|
||||
factory AuthService(
|
||||
Dio dio, {
|
||||
String? baseUrl,
|
||||
ParseErrorLogger? errorLogger,
|
||||
}) = _AuthService;
|
||||
|
||||
@POST('/api/login')
|
||||
Future<TokenModel> getTokenByCredentials({@Body() required CredentialsModel credentials});
|
||||
|
||||
@@ -5,7 +5,11 @@ part 'reset_password_service.g.dart';
|
||||
|
||||
@RestApi()
|
||||
abstract class ResetPasswordService {
|
||||
factory ResetPasswordService(Dio dio, {String baseUrl}) = _ResetPasswordService;
|
||||
factory ResetPasswordService(
|
||||
Dio dio, {
|
||||
String baseUrl,
|
||||
ParseErrorLogger? errorLogger,
|
||||
}) = _ResetPasswordService;
|
||||
|
||||
@POST('/api/send_password_reset_code')
|
||||
Future<HttpResponse> sendEmailCodeForPasswordChange({
|
||||
|
||||
@@ -1,24 +1,28 @@
|
||||
import 'package:dio/dio.dart';
|
||||
import 'package:eatvio_app/features/barcode/models/barcode_product_model.dart';
|
||||
import 'package:retrofit/retrofit.dart';
|
||||
|
||||
part 'barcode_service.g.dart';
|
||||
|
||||
@RestApi()
|
||||
abstract class BarcodeService {
|
||||
factory BarcodeService(Dio dio, {String baseUrl}) = _BarcodeService;
|
||||
|
||||
@GET('/api/gsone/barcode/{barcode}')
|
||||
Future<BarcodeProductModel> getProductByBarcode({@Path('barcode') required String barcode});
|
||||
|
||||
@GET('/api/gsone/barcode/status/{task_id}')
|
||||
Future<BarcodeTaskStatusModel> getTaskStatus({@Path('task_id') required String taskId});
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
import 'package:dio/dio.dart';
|
||||
import 'package:eatvio_app/features/barcode/models/barcode_product_model.dart';
|
||||
import 'package:retrofit/retrofit.dart';
|
||||
|
||||
part 'barcode_service.g.dart';
|
||||
|
||||
@RestApi()
|
||||
abstract class BarcodeService {
|
||||
factory BarcodeService(
|
||||
Dio dio, {
|
||||
String baseUrl,
|
||||
ParseErrorLogger? errorLogger,
|
||||
}) = _BarcodeService;
|
||||
|
||||
@GET('/api/gsone/barcode/{barcode}')
|
||||
Future<BarcodeProductModel> getProductByBarcode({@Path('barcode') required String barcode});
|
||||
|
||||
@GET('/api/gsone/barcode/status/{task_id}')
|
||||
Future<BarcodeTaskStatusModel> getTaskStatus({@Path('task_id') required String taskId});
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -5,7 +5,11 @@ part 'blog_post_service.g.dart';
|
||||
|
||||
@RestApi()
|
||||
abstract class BlogPostService {
|
||||
factory BlogPostService(Dio dio, {String baseUrl}) = _BlogPostService;
|
||||
factory BlogPostService(
|
||||
Dio dio, {
|
||||
String baseUrl,
|
||||
ParseErrorLogger? errorLogger,
|
||||
}) = _BlogPostService;
|
||||
|
||||
@POST('/api/v2/blogPosts/create/published')
|
||||
@MultiPart()
|
||||
|
||||
@@ -6,7 +6,11 @@ part 'calendar_service.g.dart';
|
||||
|
||||
@RestApi()
|
||||
abstract class CalendarService {
|
||||
factory CalendarService(Dio dio, {String baseUrl}) = _CalendarService;
|
||||
factory CalendarService(
|
||||
Dio dio, {
|
||||
String baseUrl,
|
||||
ParseErrorLogger? errorLogger,
|
||||
}) = _CalendarService;
|
||||
|
||||
@GET('/api/calendar/index')
|
||||
Future<List<CalendarModel>> getCalendar();
|
||||
|
||||
@@ -6,7 +6,11 @@ part 'cancel_plan_service.g.dart';
|
||||
|
||||
@RestApi()
|
||||
abstract class CancelPlanService {
|
||||
factory CancelPlanService(Dio dio, {String baseUrl}) = _CancelPlanService;
|
||||
factory CancelPlanService(
|
||||
Dio dio, {
|
||||
String baseUrl,
|
||||
ParseErrorLogger? errorLogger,
|
||||
}) = _CancelPlanService;
|
||||
|
||||
@POST('/api/chosen_plans/{id}/cancel')
|
||||
Future<void> cancelChosenPlan({
|
||||
|
||||
@@ -17,7 +17,11 @@ part 'chat_service.g.dart';
|
||||
|
||||
@RestApi()
|
||||
abstract class ChatService {
|
||||
factory ChatService(Dio dio, {String baseUrl}) = _ChatService;
|
||||
factory ChatService(
|
||||
Dio dio, {
|
||||
String baseUrl,
|
||||
ParseErrorLogger? errorLogger,
|
||||
}) = _ChatService;
|
||||
|
||||
@GET('/api/v2/chat/index')
|
||||
Future<ChatRoomPaginationModel> getChatRooms({
|
||||
|
||||
@@ -6,7 +6,11 @@ part 'complaining_service.g.dart';
|
||||
|
||||
@RestApi()
|
||||
abstract class ComplainingService {
|
||||
factory ComplainingService(Dio dio, {String baseUrl}) = _ComplainingService;
|
||||
factory ComplainingService(
|
||||
Dio dio, {
|
||||
String baseUrl,
|
||||
ParseErrorLogger? errorLogger,
|
||||
}) = _ComplainingService;
|
||||
|
||||
@POST('/api/plans/{slug}/complain/{category}')
|
||||
Future<void> sendPlanComplain({
|
||||
|
||||
@@ -9,7 +9,11 @@ part 'consultant_service.g.dart';
|
||||
|
||||
@RestApi()
|
||||
abstract class ConsultantService {
|
||||
factory ConsultantService(Dio dio, {String baseUrl}) = _ConsultantService;
|
||||
factory ConsultantService(
|
||||
Dio dio, {
|
||||
String baseUrl,
|
||||
ParseErrorLogger? errorLogger,
|
||||
}) = _ConsultantService;
|
||||
|
||||
@POST('/api/v2/consultant_request/registration')
|
||||
Future<void> consultantRegistration({
|
||||
|
||||
@@ -8,7 +8,11 @@ part 'consultant_rating_service.g.dart';
|
||||
|
||||
@RestApi()
|
||||
abstract class ConsultantRatingService {
|
||||
factory ConsultantRatingService(Dio dio, {String baseUrl}) = _ConsultantRatingService;
|
||||
factory ConsultantRatingService(
|
||||
Dio dio, {
|
||||
String baseUrl,
|
||||
ParseErrorLogger? errorLogger,
|
||||
}) = _ConsultantRatingService;
|
||||
|
||||
@GET('/api/consultants/rating/statistics')
|
||||
Future<StatisticsModel> getConsultantStatistics({@Query('filters[duration][\$gte]') String? date});
|
||||
|
||||
@@ -6,7 +6,11 @@ part 'create_diet_service.g.dart';
|
||||
|
||||
@RestApi()
|
||||
abstract class CreateDietService {
|
||||
factory CreateDietService(Dio dio, {String baseUrl}) = _CreateDietService;
|
||||
factory CreateDietService(
|
||||
Dio dio, {
|
||||
String baseUrl,
|
||||
ParseErrorLogger? errorLogger,
|
||||
}) = _CreateDietService;
|
||||
|
||||
@POST('/api/diets/create/published')
|
||||
@MultiPart()
|
||||
|
||||
@@ -5,7 +5,11 @@ part 'create_plan_service.g.dart';
|
||||
|
||||
@RestApi()
|
||||
abstract class CreatePlanService {
|
||||
factory CreatePlanService(Dio dio, {String baseUrl}) = _CreatePlanService;
|
||||
factory CreatePlanService(
|
||||
Dio dio, {
|
||||
String baseUrl,
|
||||
ParseErrorLogger? errorLogger,
|
||||
}) = _CreatePlanService;
|
||||
|
||||
@POST('/api/plans/create/published')
|
||||
@MultiPart()
|
||||
|
||||
@@ -8,7 +8,11 @@ part 'recipe_service.g.dart';
|
||||
|
||||
@RestApi()
|
||||
abstract class CreateRecipeService {
|
||||
factory CreateRecipeService(Dio dio, {String baseUrl}) = _CreateRecipeService;
|
||||
factory CreateRecipeService(
|
||||
Dio dio, {
|
||||
String baseUrl,
|
||||
ParseErrorLogger? errorLogger,
|
||||
}) = _CreateRecipeService;
|
||||
|
||||
@POST('/api/recipes/{slug}/like')
|
||||
Future<void> likeRecipe({
|
||||
|
||||
@@ -13,7 +13,11 @@ part 'diary_service.g.dart';
|
||||
|
||||
@RestApi()
|
||||
abstract class DiaryService {
|
||||
factory DiaryService(Dio dio, {String baseUrl}) = _DiaryService;
|
||||
factory DiaryService(
|
||||
Dio dio, {
|
||||
String baseUrl,
|
||||
ParseErrorLogger? errorLogger,
|
||||
}) = _DiaryService;
|
||||
|
||||
@GET('/api/diary/index/{date}')
|
||||
Future<List<DiaryDayModel>> getDiaryIndexByDate({@Path('date') required String date});
|
||||
|
||||
@@ -7,7 +7,11 @@ part 'diet_service.g.dart';
|
||||
|
||||
@RestApi()
|
||||
abstract class DietService {
|
||||
factory DietService(Dio dio, {String baseUrl}) = _DietService;
|
||||
factory DietService(
|
||||
Dio dio, {
|
||||
String baseUrl,
|
||||
ParseErrorLogger? errorLogger,
|
||||
}) = _DietService;
|
||||
|
||||
@POST('/api/diets/{id}/like')
|
||||
Future<DietLikesModel> likeDiet({
|
||||
|
||||
@@ -14,7 +14,11 @@ part 'feed_service.g.dart';
|
||||
|
||||
@RestApi()
|
||||
abstract class FeedService {
|
||||
factory FeedService(Dio dio, {String baseUrl}) = _FeedService;
|
||||
factory FeedService(
|
||||
Dio dio, {
|
||||
String baseUrl,
|
||||
ParseErrorLogger? errorLogger,
|
||||
}) = _FeedService;
|
||||
|
||||
@GET('/api/blogPosts/index')
|
||||
Future<FeedBlogPostSettingsModel> getBlogPostList({@Query('page') required int page, @Query('query_search') String? query});
|
||||
|
||||
@@ -6,7 +6,11 @@ part 'glossary_service.g.dart';
|
||||
|
||||
@RestApi()
|
||||
abstract class GlossaryService {
|
||||
factory GlossaryService(Dio dio, {String baseUrl}) = _GlossaryService;
|
||||
factory GlossaryService(
|
||||
Dio dio, {
|
||||
String baseUrl,
|
||||
ParseErrorLogger? errorLogger,
|
||||
}) = _GlossaryService;
|
||||
|
||||
@GET('/api/glossaries/search')
|
||||
Future<GlossaryPaginationModel> getGlossaryByQuery({
|
||||
|
||||
@@ -9,7 +9,11 @@ part 'insights_service.g.dart';
|
||||
/// недоступный профиль — 403.
|
||||
@RestApi()
|
||||
abstract class InsightsService {
|
||||
factory InsightsService(Dio dio, {String baseUrl}) = _InsightsService;
|
||||
factory InsightsService(
|
||||
Dio dio, {
|
||||
String baseUrl,
|
||||
ParseErrorLogger? errorLogger,
|
||||
}) = _InsightsService;
|
||||
|
||||
/// Свои графики целиком.
|
||||
@GET('/api/profile/insights')
|
||||
|
||||
@@ -6,7 +6,11 @@ part 'blocked_users_service.g.dart';
|
||||
|
||||
@RestApi()
|
||||
abstract class BlockedUserService {
|
||||
factory BlockedUserService(Dio dio, {String baseUrl}) = _BlockedUserService;
|
||||
factory BlockedUserService(
|
||||
Dio dio, {
|
||||
String baseUrl,
|
||||
ParseErrorLogger? errorLogger,
|
||||
}) = _BlockedUserService;
|
||||
|
||||
@GET('/api/blocked_users')
|
||||
Future<BlockedUsersModel> getBlockedUsers();
|
||||
|
||||
@@ -6,7 +6,11 @@ part 'notification_settings_service.g.dart';
|
||||
|
||||
@RestApi()
|
||||
abstract class NotificationSettingsService {
|
||||
factory NotificationSettingsService(Dio dio, {String baseUrl}) = _NotificationSettingsService;
|
||||
factory NotificationSettingsService(
|
||||
Dio dio, {
|
||||
String baseUrl,
|
||||
ParseErrorLogger? errorLogger,
|
||||
}) = _NotificationSettingsService;
|
||||
|
||||
@GET('/api/profile/notification_settings')
|
||||
Future<NotificationSettingsModel> getNotificationSettings();
|
||||
|
||||
@@ -7,7 +7,11 @@ part 'my_diets_service.g.dart';
|
||||
@RestApi()
|
||||
abstract class MyDietsService {
|
||||
|
||||
factory MyDietsService(Dio dio, {String baseUrl}) = _MyDietsService;
|
||||
factory MyDietsService(
|
||||
Dio dio, {
|
||||
String baseUrl,
|
||||
ParseErrorLogger? errorLogger,
|
||||
}) = _MyDietsService;
|
||||
|
||||
@GET('/api/profile/my_diets')
|
||||
Future<DietsPagination> getDiets({
|
||||
|
||||
@@ -7,7 +7,11 @@ part 'cards_service.g.dart';
|
||||
|
||||
@RestApi()
|
||||
abstract class CardsService {
|
||||
factory CardsService(Dio dio, {String baseUrl}) = _CardsService;
|
||||
factory CardsService(
|
||||
Dio dio, {
|
||||
String baseUrl,
|
||||
ParseErrorLogger? errorLogger,
|
||||
}) = _CardsService;
|
||||
|
||||
@GET('/api/finances/cards')
|
||||
Future<List<CardModel>> getCards();
|
||||
|
||||
@@ -6,7 +6,11 @@ part 'my_plans_service.g.dart';
|
||||
|
||||
@RestApi()
|
||||
abstract class MyPlansService {
|
||||
factory MyPlansService(Dio dio, {String baseUrl}) = _MyPlansService;
|
||||
factory MyPlansService(
|
||||
Dio dio, {
|
||||
String baseUrl,
|
||||
ParseErrorLogger? errorLogger,
|
||||
}) = _MyPlansService;
|
||||
|
||||
@GET('/api/profile/my_plans')
|
||||
Future<PlanPaginationModel> getPlans({
|
||||
|
||||
@@ -1,13 +1,17 @@
|
||||
import 'package:dio/dio.dart';
|
||||
import 'package:eatvio_app/core/error_reporting/api_response_error_reporter.dart';
|
||||
import 'package:eatvio_app/features/notifications/models/notification_model.dart';
|
||||
|
||||
class NotificationsService {
|
||||
final Dio dio;
|
||||
NotificationsService(this.dio);
|
||||
final ApiResponseErrorReporter? responseErrors;
|
||||
static const _endpoint = '/api/profile/notifications';
|
||||
|
||||
NotificationsService(this.dio, {this.responseErrors});
|
||||
|
||||
Future<Map<String, dynamic>?> getNotifications({required int page}) async {
|
||||
final response = await dio.get('$_endpoint?page=$page');
|
||||
try {
|
||||
final response = await dio.get('/api/profile/notifications?page=$page');
|
||||
if (response.statusCode == 200) {
|
||||
final data = response.data['data'] as List<dynamic>;
|
||||
|
||||
@@ -493,7 +497,14 @@ class NotificationsService {
|
||||
),
|
||||
NotificationType.unknown => UnknownNotification(type: type, createdAt: parseDate(createdAt)),
|
||||
};
|
||||
} catch (e) {
|
||||
} catch (error, stackTrace) {
|
||||
responseErrors?.report(
|
||||
error,
|
||||
stackTrace,
|
||||
method: response.requestOptions.method,
|
||||
statusCode: response.statusCode,
|
||||
endpoint: _endpoint,
|
||||
);
|
||||
return UnknownNotification(type: NotificationType.unknown, createdAt: DateTime.now());
|
||||
}
|
||||
}).toList();
|
||||
@@ -510,7 +521,14 @@ class NotificationsService {
|
||||
};
|
||||
}
|
||||
return null;
|
||||
} catch (e) {
|
||||
} catch (error, stackTrace) {
|
||||
responseErrors?.report(
|
||||
error,
|
||||
stackTrace,
|
||||
method: response.requestOptions.method,
|
||||
statusCode: response.statusCode,
|
||||
endpoint: _endpoint,
|
||||
);
|
||||
rethrow;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import 'package:dio/dio.dart';
|
||||
import 'package:eatvio_app/core/error_reporting/api_response_error_reporter.dart';
|
||||
import 'package:eatvio_app/features/chat/models/payment_model.dart';
|
||||
import 'package:eatvio_app/features/chat/services/chat_service.dart';
|
||||
import 'package:eatvio_app/features/payment/models/promo_applied_list_response.dart';
|
||||
@@ -10,8 +11,9 @@ import 'package:eatvio_app/features/payment/models/promo_validate_response.dart'
|
||||
/// Репозиторий оплаты консультаций (chosen_plan) через Alfa Bank / СБП.
|
||||
class PaymentRepository {
|
||||
final ChatService chatService;
|
||||
final ApiResponseErrorReporter? responseErrors;
|
||||
|
||||
PaymentRepository({required this.chatService});
|
||||
PaymentRepository({required this.chatService, this.responseErrors});
|
||||
|
||||
/// Запускает процесс оплаты: POST `/api/chosen_plans/{id}/start_payment_process`
|
||||
/// с `payment_provider: alfa-bank`.
|
||||
@@ -64,9 +66,15 @@ class PaymentRepository {
|
||||
body: {'promo_code': promoCode},
|
||||
);
|
||||
} on DioException catch (e) {
|
||||
final data = e.response?.data;
|
||||
if (data is Map<String, dynamic>) {
|
||||
return PromoApplyResponse.fromJson(data);
|
||||
final response = e.response;
|
||||
final data = response?.data;
|
||||
if (response != null && data is Map<String, dynamic>) {
|
||||
return ApiResponseErrorReporter.decode(
|
||||
responseErrors,
|
||||
response,
|
||||
'/api/chosen_plans/{id}/apply_promo',
|
||||
() => PromoApplyResponse.fromJson(data),
|
||||
);
|
||||
}
|
||||
rethrow;
|
||||
}
|
||||
@@ -77,9 +85,15 @@ class PaymentRepository {
|
||||
try {
|
||||
return await chatService.removePromoCode(id: planId);
|
||||
} on DioException catch (e) {
|
||||
final data = e.response?.data;
|
||||
if (data is Map<String, dynamic>) {
|
||||
return PromoRemoveResponse.fromJson(data);
|
||||
final response = e.response;
|
||||
final data = response?.data;
|
||||
if (response != null && data is Map<String, dynamic>) {
|
||||
return ApiResponseErrorReporter.decode(
|
||||
responseErrors,
|
||||
response,
|
||||
'/api/chosen_plans/{id}/remove_promo_code',
|
||||
() => PromoRemoveResponse.fromJson(data),
|
||||
);
|
||||
}
|
||||
rethrow;
|
||||
}
|
||||
|
||||
@@ -6,8 +6,11 @@ part 'personal_diet_suggestion_service.g.dart';
|
||||
|
||||
@RestApi()
|
||||
abstract class PersonalDietSuggestionService {
|
||||
factory PersonalDietSuggestionService(Dio dio, {String? baseUrl}) =
|
||||
_PersonalDietSuggestionService;
|
||||
factory PersonalDietSuggestionService(
|
||||
Dio dio, {
|
||||
String? baseUrl,
|
||||
ParseErrorLogger? errorLogger,
|
||||
}) = _PersonalDietSuggestionService;
|
||||
|
||||
@GET('/api/consultations')
|
||||
Future<ConsultationPaginationModel> getConsultationWithPersonalDiets({
|
||||
|
||||
@@ -7,7 +7,11 @@ part 'plan_service.g.dart';
|
||||
|
||||
@RestApi()
|
||||
abstract class PlanService {
|
||||
factory PlanService(Dio dio, {String baseUrl}) = _PlanService;
|
||||
factory PlanService(
|
||||
Dio dio, {
|
||||
String baseUrl,
|
||||
ParseErrorLogger? errorLogger,
|
||||
}) = _PlanService;
|
||||
|
||||
@GET('/api/plans/show/{slug}')
|
||||
Future<PlanModel> getPlan(@Path('slug') String slug);
|
||||
|
||||
@@ -6,7 +6,11 @@ part 'plans_service.g.dart';
|
||||
|
||||
@RestApi()
|
||||
abstract class PlansService {
|
||||
factory PlansService(Dio dio, {String baseUrl}) = _PlansService;
|
||||
factory PlansService(
|
||||
Dio dio, {
|
||||
String baseUrl,
|
||||
ParseErrorLogger? errorLogger,
|
||||
}) = _PlansService;
|
||||
|
||||
@GET('/api/plans/get_by_author/{author}')
|
||||
Future<PlanPaginationModel> getPlansBySlug({
|
||||
|
||||
@@ -14,7 +14,11 @@ part 'profile_service.g.dart';
|
||||
|
||||
@RestApi()
|
||||
abstract class ProfileService {
|
||||
factory ProfileService(Dio dio, {String baseUrl}) = _ProfileService;
|
||||
factory ProfileService(
|
||||
Dio dio, {
|
||||
String baseUrl,
|
||||
ParseErrorLogger? errorLogger,
|
||||
}) = _ProfileService;
|
||||
|
||||
@GET('/api/profile/show/{slug}')
|
||||
Future<ProfileModel> getProfileBySlug({@Path() required String slug});
|
||||
|
||||
@@ -6,7 +6,11 @@ part 'about_recipe_service.g.dart';
|
||||
|
||||
@RestApi()
|
||||
abstract class AboutRecipeService {
|
||||
factory AboutRecipeService(Dio dio, {String baseUrl}) = _AboutRecipeService;
|
||||
factory AboutRecipeService(
|
||||
Dio dio, {
|
||||
String baseUrl,
|
||||
ParseErrorLogger? errorLogger,
|
||||
}) = _AboutRecipeService;
|
||||
|
||||
@POST('/api/recipes/{slug}/like')
|
||||
Future<void> likeRecipe({
|
||||
|
||||
@@ -6,7 +6,11 @@ part 'my_recipes_service.g.dart';
|
||||
|
||||
@RestApi()
|
||||
abstract class MyRecipesService {
|
||||
factory MyRecipesService(Dio dio, {String baseUrl}) = _MyRecipesService;
|
||||
factory MyRecipesService(
|
||||
Dio dio, {
|
||||
String baseUrl,
|
||||
ParseErrorLogger? errorLogger,
|
||||
}) = _MyRecipesService;
|
||||
|
||||
@GET('/api/recipes/my')
|
||||
Future<MyRecipePaginationModel> getMyRecipes();
|
||||
|
||||
@@ -6,7 +6,11 @@ part 'registration_service.g.dart';
|
||||
|
||||
@RestApi()
|
||||
abstract class RegistrationService {
|
||||
factory RegistrationService(Dio dio, {String baseUrl}) = _RegistrationService;
|
||||
factory RegistrationService(
|
||||
Dio dio, {
|
||||
String baseUrl,
|
||||
ParseErrorLogger? errorLogger,
|
||||
}) = _RegistrationService;
|
||||
|
||||
@POST('/api/register')
|
||||
Future<Map<String, String>> register({
|
||||
|
||||
@@ -5,7 +5,11 @@ part 'registration_service_v2.g.dart';
|
||||
|
||||
@RestApi()
|
||||
abstract class RegistrationServiceV2 {
|
||||
factory RegistrationServiceV2(Dio dio, {String baseUrl}) = _RegistrationServiceV2;
|
||||
factory RegistrationServiceV2(
|
||||
Dio dio, {
|
||||
String baseUrl,
|
||||
ParseErrorLogger? errorLogger,
|
||||
}) = _RegistrationServiceV2;
|
||||
|
||||
@POST('/api/register')
|
||||
Future<Map<String, String>> register({
|
||||
|
||||
@@ -80,29 +80,33 @@ class SettingsCubit extends Cubit<SettingsState> {
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> updateProfileDetails({
|
||||
Future<bool> updateProfileDetails({
|
||||
required ProfileDetailsModel profileDetailsModel,
|
||||
}) async {
|
||||
try {
|
||||
await settingsRepository.updateProfileDetails(
|
||||
profileDetailsModel: profileDetailsModel,
|
||||
);
|
||||
return true;
|
||||
} catch (e, st) {
|
||||
await reportFrom(e, st, this);
|
||||
return false;
|
||||
} finally {
|
||||
await init();
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> updateProfileSettings({
|
||||
Future<bool> updateProfileSettings({
|
||||
required ProfileSettingsModel profileSettingsModel,
|
||||
}) async {
|
||||
try {
|
||||
await settingsRepository.updateProfileSettings(
|
||||
profileSettingsModel: profileSettingsModel,
|
||||
);
|
||||
return true;
|
||||
} catch (e, st) {
|
||||
await reportFrom(e, st, this);
|
||||
return false;
|
||||
} finally {
|
||||
await init();
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import 'package:eatvio_app/core/data/selectionPopupModel/selection_popup_model.dart';
|
||||
import 'package:eatvio_app/core/utils/date_time_utils.dart';
|
||||
import 'package:eatvio_app/core/utils/toasts.dart';
|
||||
import 'package:eatvio_app/core/widgets/custom_drop_down.dart';
|
||||
import 'package:eatvio_app/core/widgets/loader.dart';
|
||||
import 'package:eatvio_app/features/create_diet/presentation/widgets/error_widget.dart';
|
||||
@@ -10,6 +11,7 @@ import 'package:eatvio_app/core/theme/theme_helper.dart';
|
||||
import 'package:eatvio_app/core/widgets/custom_text_form_field.dart';
|
||||
import 'package:material_ui/material_ui.dart';
|
||||
import 'package:cupertino_ui/cupertino_ui.dart';
|
||||
import 'package:go_router/go_router.dart';
|
||||
|
||||
class GeneralInfoScreen extends StatefulWidget {
|
||||
final SettingsEntity settingsEntity;
|
||||
@@ -233,7 +235,7 @@ class _GeneralInfoScreenState extends State<GeneralInfoScreen> {
|
||||
setState(() {
|
||||
isLoading = true;
|
||||
});
|
||||
await widget.settingsEntity.settingsCubit.updateProfileDetails(
|
||||
final detailsSaved = await widget.settingsEntity.settingsCubit.updateProfileDetails(
|
||||
profileDetailsModel: (widget.settingsEntity.settingsCubit.state as SettingsStateLoaded).profileDetails.copyWith(
|
||||
firstName: firstNameController.text,
|
||||
lastName: lastNameController.text,
|
||||
@@ -244,7 +246,7 @@ class _GeneralInfoScreenState extends State<GeneralInfoScreen> {
|
||||
lang: languageController.text,
|
||||
),
|
||||
);
|
||||
await widget.settingsEntity.settingsCubit.updateProfileSettings(
|
||||
final settingsSaved = await widget.settingsEntity.settingsCubit.updateProfileSettings(
|
||||
profileSettingsModel: (widget.settingsEntity.settingsCubit.state as SettingsStateLoaded).profileSettings.copyWith(
|
||||
isPublicProfile: isPublicProfile.value,
|
||||
),
|
||||
@@ -253,6 +255,10 @@ class _GeneralInfoScreenState extends State<GeneralInfoScreen> {
|
||||
setState(() {
|
||||
isLoading = false;
|
||||
});
|
||||
if (detailsSaved && settingsSaved) {
|
||||
showSuccessToast(S.of(context).data_saved_successfully);
|
||||
context.pop();
|
||||
}
|
||||
},
|
||||
borderRadius: BorderRadius.circular(20),
|
||||
child: Ink(
|
||||
|
||||
@@ -2,6 +2,7 @@ import 'package:eatvio_app/features/settings/entities/settings_entity.dart';
|
||||
import 'package:eatvio_app/features/settings/presentation/bloc/settings_cubit/settings_state.dart';
|
||||
import 'package:eatvio_app/generated/l10n.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_text_form_field.dart';
|
||||
import 'package:material_ui/material_ui.dart';
|
||||
import 'package:go_router/go_router.dart';
|
||||
@@ -137,8 +138,8 @@ class _OtherInfoScreenState extends State<OtherInfoScreen> {
|
||||
|
||||
InkWell _saveButton() {
|
||||
return InkWell(
|
||||
onTap: () {
|
||||
widget.settingsEntity.settingsCubit.updateProfileDetails(
|
||||
onTap: () async {
|
||||
final saved = await widget.settingsEntity.settingsCubit.updateProfileDetails(
|
||||
profileDetailsModel: (widget.settingsEntity.settingsCubit.state as SettingsStateLoaded).profileDetails.copyWith(
|
||||
aboutAlergy: aboutAllergyController.text,
|
||||
aboutTakingPils: aboutTakingPillsController.text,
|
||||
@@ -148,7 +149,11 @@ class _OtherInfoScreenState extends State<OtherInfoScreen> {
|
||||
additionalInfo: additionalInfoController.text,
|
||||
),
|
||||
);
|
||||
GoRouter.of(context).pop();
|
||||
if (!mounted) return;
|
||||
if (saved) {
|
||||
showSuccessToast(S.of(context).data_saved_successfully);
|
||||
GoRouter.of(context).pop();
|
||||
}
|
||||
},
|
||||
borderRadius: BorderRadius.circular(20),
|
||||
child: Ink(
|
||||
|
||||
@@ -2,6 +2,8 @@ import 'package:eatvio_app/features/settings/entities/settings_entity.dart';
|
||||
import 'package:eatvio_app/features/settings/presentation/bloc/settings_cubit/settings_cubit.dart';
|
||||
import 'package:eatvio_app/features/settings/presentation/bloc/settings_cubit/settings_state.dart';
|
||||
import 'package:eatvio_app/core/theme/theme_helper.dart';
|
||||
import 'package:eatvio_app/core/utils/toasts.dart';
|
||||
import 'package:eatvio_app/generated/l10n.dart';
|
||||
import 'package:material_ui/material_ui.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:go_router/go_router.dart';
|
||||
@@ -200,7 +202,7 @@ class _PhysicalActivityScreenState extends State<PhysicalActivityScreen> {
|
||||
|
||||
InkWell _saveButton() {
|
||||
return InkWell(
|
||||
onTap: () {
|
||||
onTap: () async {
|
||||
late final double activityCoefficient;
|
||||
switch (_physicalActivity) {
|
||||
case PhysicalActivity.minimum:
|
||||
@@ -221,12 +223,16 @@ class _PhysicalActivityScreenState extends State<PhysicalActivityScreen> {
|
||||
default:
|
||||
break;
|
||||
}
|
||||
widget.settingsEntity.settingsCubit.updateProfileDetails(
|
||||
final saved = await widget.settingsEntity.settingsCubit.updateProfileDetails(
|
||||
profileDetailsModel: (widget.settingsEntity.settingsCubit.state as SettingsStateLoaded).profileDetails.copyWith(
|
||||
activityCoefficient: activityCoefficient,
|
||||
),
|
||||
);
|
||||
GoRouter.of(context).pop();
|
||||
if (!mounted) return;
|
||||
if (saved) {
|
||||
showSuccessToast(S.of(context).data_saved_successfully);
|
||||
GoRouter.of(context).pop();
|
||||
}
|
||||
},
|
||||
borderRadius: BorderRadius.circular(20),
|
||||
child: Ink(
|
||||
|
||||
@@ -2,6 +2,7 @@ import 'package:eatvio_app/features/settings/entities/settings_entity.dart';
|
||||
import 'package:eatvio_app/features/settings/presentation/bloc/settings_cubit/settings_state.dart';
|
||||
import 'package:eatvio_app/generated/l10n.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_text_form_field.dart';
|
||||
import 'package:material_ui/material_ui.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
@@ -108,8 +109,8 @@ class _PhysicalFormScreenState extends State<PhysicalFormScreen> {
|
||||
|
||||
InkWell _saveButton() {
|
||||
return InkWell(
|
||||
onTap: () {
|
||||
widget.settingsEntity.settingsCubit.updateProfileDetails(
|
||||
onTap: () async {
|
||||
final saved = await widget.settingsEntity.settingsCubit.updateProfileDetails(
|
||||
profileDetailsModel: (widget.settingsEntity.settingsCubit.state as SettingsStateLoaded).profileDetails.copyWith(
|
||||
chestCircumference: int.parse(chestCircumferenceController.text),
|
||||
waistCircumference: int.parse(waistCircumferenceController.text),
|
||||
@@ -118,7 +119,11 @@ class _PhysicalFormScreenState extends State<PhysicalFormScreen> {
|
||||
weight: double.parse(weightController.text),
|
||||
),
|
||||
);
|
||||
GoRouter.of(context).pop();
|
||||
if (!mounted) return;
|
||||
if (saved) {
|
||||
showSuccessToast(S.of(context).data_saved_successfully);
|
||||
GoRouter.of(context).pop();
|
||||
}
|
||||
},
|
||||
borderRadius: BorderRadius.circular(20),
|
||||
child: Ink(
|
||||
|
||||
@@ -4,6 +4,7 @@ import 'package:eatvio_app/features/settings/entities/settings_entity.dart';
|
||||
import 'package:eatvio_app/features/settings/presentation/bloc/settings_cubit/settings_state.dart';
|
||||
import 'package:eatvio_app/generated/l10n.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_text_form_field.dart';
|
||||
import 'package:material_ui/material_ui.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
@@ -114,8 +115,8 @@ class _PressureScreenState extends State<PressureScreen> {
|
||||
|
||||
InkWell _saveButton() {
|
||||
return InkWell(
|
||||
onTap: () {
|
||||
widget.settingsEntity.settingsCubit.updateProfileDetails(
|
||||
onTap: () async {
|
||||
final saved = await widget.settingsEntity.settingsCubit.updateProfileDetails(
|
||||
profileDetailsModel: (widget.settingsEntity.settingsCubit.state as SettingsStateLoaded).profileDetails.copyWith(
|
||||
bloodPressureUp: int.parse(bloodPressureUpController.text),
|
||||
bloodPressureDown: int.parse(bloodPressureDownController.text),
|
||||
@@ -123,7 +124,11 @@ class _PressureScreenState extends State<PressureScreen> {
|
||||
hasHypo: hypo.value,
|
||||
),
|
||||
);
|
||||
GoRouter.of(context).pop();
|
||||
if (!mounted) return;
|
||||
if (saved) {
|
||||
showSuccessToast(S.of(context).data_saved_successfully);
|
||||
GoRouter.of(context).pop();
|
||||
}
|
||||
},
|
||||
borderRadius: BorderRadius.circular(20),
|
||||
child: Ink(
|
||||
|
||||
@@ -9,7 +9,11 @@ part 'settings_service.g.dart';
|
||||
|
||||
@RestApi()
|
||||
abstract class SettingsService {
|
||||
factory SettingsService(Dio dio, {String baseUrl}) = _SettingsService;
|
||||
factory SettingsService(
|
||||
Dio dio, {
|
||||
String baseUrl,
|
||||
ParseErrorLogger? errorLogger,
|
||||
}) = _SettingsService;
|
||||
|
||||
@GET('/api/profile/settings')
|
||||
Future<ProfileSettingsModel> getProfileSettings();
|
||||
|
||||
@@ -7,7 +7,11 @@ part 'video_call_service.g.dart';
|
||||
|
||||
@RestApi()
|
||||
abstract class VideoCallService {
|
||||
factory VideoCallService(Dio dio, {String baseUrl}) = _VideoCallService;
|
||||
factory VideoCallService(
|
||||
Dio dio, {
|
||||
String baseUrl,
|
||||
ParseErrorLogger? errorLogger,
|
||||
}) = _VideoCallService;
|
||||
|
||||
@GET('/api/v2/chat/{conversation}/video-call/token')
|
||||
Future<VideoCallTokenResponse> getParticipantToken({
|
||||
|
||||
Reference in New Issue
Block a user