feat: Implement 'My Recipes' feature, add diary moderation request modal, and introduce diary repository.

This commit is contained in:
mso7nueh
2026-03-17 12:18:17 +03:00
parent 50deaeddd1
commit 2da3b10e63
4 changed files with 27 additions and 9 deletions

View File

@@ -257,12 +257,17 @@ class _GlossaryModerationRequestModalWidgetState extends State<GlossaryModeratio
const SizedBox(height: 12),
InkWell(
onTap: () async {
final energy = double.tryParse(energyController.text.replaceAll(',', '.')) ?? 0;
final proteins = double.tryParse(proteinsController.text.replaceAll(',', '.')) ?? 0;
final fats = double.tryParse(fatsController.text.replaceAll(',', '.')) ?? 0;
final carbohydrates = double.tryParse(carbohydratesController.text.replaceAll(',', '.')) ?? 0;
glossary = (await widget.diaryCubit.sendProductToModeration(
name: productNameController.text,
energy: double.parse(energyController.text.replaceAll(',', '.')),
proteins: double.parse(proteinsController.text.replaceAll(',', '.')),
fats: double.parse(fatsController.text.replaceAll(',', '.')),
carbohydrates: double.parse(carbohydratesController.text.replaceAll(',', '.')),
energy: energy,
proteins: proteins,
fats: fats,
carbohydrates: carbohydrates,
))?.glossary;
setState(() {
glossaryState = GlossaryState.success;

View File

@@ -1,5 +1,6 @@
import 'dart:async';
import 'dart:io';
import 'package:dio/dio.dart';
import 'package:eatvio_app/features/diary/models/consultant_comment_model.dart';
import 'package:eatvio_app/features/diary/models/consultant_review_model.dart';
import 'package:eatvio_app/features/diary/models/create_day_model.dart';
@@ -381,7 +382,10 @@ class DiaryRepository {
await diaryService.createDay(body: CreateDayModel(day: day));
await getDiaryByDate(day);
} catch (e, s) {
await Sentry.captureException(e, stackTrace: s);
if (e is DioException && e.response?.statusCode == 422) {
} else {
await Sentry.captureException(e, stackTrace: s);
}
rethrow;
}
}

View File

@@ -74,8 +74,11 @@ class MyRecipesScreen extends StatelessWidget {
),
const SizedBox(width: 8),
InkWell(
onTap: () {
context.push(RecipeCreateScreen.path);
onTap: () async {
await context.push(RecipeCreateScreen.path);
if (context.mounted) {
context.read<MyRecipesCubit>().getMyRecipes();
}
},
borderRadius: BorderRadius.circular(100),
child: Container(

View File

@@ -155,7 +155,10 @@ class _MyRecipeWidgetState extends State<MyRecipeWidget> {
final fullRecipe = await context.read<MyRecipesCubit>().getRecipeById(widget.recipe.slug);
if (context.mounted) {
Navigator.pop(context); // close dialog
context.push(RecipeCreateScreen.path, extra: fullRecipe);
await context.push(RecipeCreateScreen.path, extra: fullRecipe);
if (context.mounted) {
context.read<MyRecipesCubit>().setDraftedState();
}
}
},
height: 52,
@@ -236,10 +239,13 @@ class _MyRecipeWidgetState extends State<MyRecipeWidget> {
} else {
showErrorToast('Заполните все необходимые поля для публикации рецепта');
if (context.mounted) {
context.push(RecipeCreateScreen.path, extra: {
await context.push(RecipeCreateScreen.path, extra: {
'recipe': fullRecipe,
'autoValidate': true,
});
if (context.mounted) {
context.read<MyRecipesCubit>().setDraftedState();
}
}
}
await createCubit.close();