forked from eatvio/eatvio_app
fix: glossary modeartion
This commit is contained in:
@@ -87,13 +87,17 @@ class InitializationCubit extends Cubit<InitializationState> {
|
||||
await subscribeNotifications(wsUrl.userId, client);
|
||||
await subscribeChatMessages(wsUrl.userId, client);
|
||||
|
||||
emit(InitializationState.success(
|
||||
client: client,
|
||||
),);
|
||||
emit(
|
||||
InitializationState.success(
|
||||
client: client,
|
||||
),
|
||||
);
|
||||
} catch (e) {
|
||||
emit(InitializationState.error(
|
||||
errorMessage: e.toString(),
|
||||
),);
|
||||
emit(
|
||||
InitializationState.error(
|
||||
errorMessage: e.toString(),
|
||||
),
|
||||
);
|
||||
rethrow;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -155,7 +155,7 @@ class DiaryCubit extends Cubit<DiaryState> {
|
||||
await fetchDiary();
|
||||
}
|
||||
|
||||
Future<GlossaryModerationModel> sendProductToModeration({
|
||||
Future<void> sendProductToModeration({
|
||||
required String name,
|
||||
required double energy,
|
||||
required double proteins,
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import 'package:eatvio_app/features/diary/presentation/bloc/diary_cubit.dart';
|
||||
import 'package:eatvio_app/core/theme/theme_helper.dart';
|
||||
import 'package:eatvio_app/core/widgets/custom_text_form_field.dart';
|
||||
import 'package:eatvio_app/features/glossary/models/glossary_model.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:lottie/lottie.dart';
|
||||
|
||||
@@ -28,7 +27,7 @@ class _GlossaryModerationRequestModalWidgetState extends State<GlossaryModeratio
|
||||
final proteinsController = TextEditingController();
|
||||
final fatsController = TextEditingController();
|
||||
final carbohydratesController = TextEditingController();
|
||||
GlossaryModel? glossary;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
if (glossaryState == GlossaryState.alert) {
|
||||
@@ -161,7 +160,7 @@ class _GlossaryModerationRequestModalWidgetState extends State<GlossaryModeratio
|
||||
const SizedBox(height: 16),
|
||||
InkWell(
|
||||
onTap: () {
|
||||
Navigator.of(context).pop(glossary);
|
||||
Navigator.of(context).pop();
|
||||
},
|
||||
borderRadius: BorderRadius.circular(20),
|
||||
child: Ink(
|
||||
@@ -264,14 +263,13 @@ class _GlossaryModerationRequestModalWidgetState extends State<GlossaryModeratio
|
||||
const SizedBox(height: 12),
|
||||
InkWell(
|
||||
onTap: () async {
|
||||
glossary = (await widget.diaryCubit.sendProductToModeration(
|
||||
await widget.diaryCubit.sendProductToModeration(
|
||||
name: productNameController.text,
|
||||
energy: double.parse(energyController.text),
|
||||
proteins: double.parse(proteinsController.text),
|
||||
fats: double.parse(fatsController.text),
|
||||
carbohydrates: double.parse(carbohydratesController.text),
|
||||
))
|
||||
.glossary;
|
||||
);
|
||||
setState(() {
|
||||
glossaryState = GlossaryState.success;
|
||||
});
|
||||
|
||||
@@ -128,7 +128,7 @@ class DiaryRepository {
|
||||
);
|
||||
}
|
||||
|
||||
Future<GlossaryModerationModel> sendProductToModeration({
|
||||
Future<void> sendProductToModeration({
|
||||
required String name,
|
||||
required double energy,
|
||||
required double proteins,
|
||||
|
||||
@@ -88,7 +88,7 @@ abstract class DiaryService {
|
||||
});
|
||||
|
||||
@POST('/api/diary/product_nutritional_values/sendToModeration')
|
||||
Future<GlossaryModerationModel> sendProductToModeration({
|
||||
Future<void> sendProductToModeration({
|
||||
@Body() required Map<String, dynamic> data,
|
||||
});
|
||||
}
|
||||
|
||||
@@ -387,14 +387,14 @@ class _DiaryService implements DiaryService {
|
||||
}
|
||||
|
||||
@override
|
||||
Future<GlossaryModerationModel> sendProductToModeration(
|
||||
Future<void> sendProductToModeration(
|
||||
{required Map<String, dynamic> data}) async {
|
||||
final _extra = <String, dynamic>{};
|
||||
final queryParameters = <String, dynamic>{};
|
||||
final _headers = <String, dynamic>{};
|
||||
final _data = <String, dynamic>{};
|
||||
_data.addAll(data);
|
||||
final _options = _setStreamType<GlossaryModerationModel>(Options(
|
||||
final _options = _setStreamType<void>(Options(
|
||||
method: 'POST',
|
||||
headers: _headers,
|
||||
extra: _extra,
|
||||
@@ -410,15 +410,7 @@ class _DiaryService implements DiaryService {
|
||||
_dio.options.baseUrl,
|
||||
baseUrl,
|
||||
)));
|
||||
final _result = await _dio.fetch<Map<String, dynamic>>(_options);
|
||||
late GlossaryModerationModel _value;
|
||||
try {
|
||||
_value = GlossaryModerationModel.fromJson(_result.data!);
|
||||
} on Object catch (e, s) {
|
||||
errorLogger?.logError(e, s, _options);
|
||||
rethrow;
|
||||
}
|
||||
return _value;
|
||||
await _dio.fetch<void>(_options);
|
||||
}
|
||||
|
||||
RequestOptions _setStreamType<T>(RequestOptions requestOptions) {
|
||||
|
||||
Reference in New Issue
Block a user