forked from eatvio/eatvio_app
feat(diary): add diary, calendar, meals, products, add product button, modal add product
This commit is contained in:
@@ -18,4 +18,13 @@ abstract class DiaryService {
|
||||
Future<DiaryDayWrapperModel> getDiaryDay({
|
||||
@Path('diary_id') required int index,
|
||||
});
|
||||
|
||||
@POST('/api/diary/{diary_id}/meal/{meal_id}/portions/create')
|
||||
Future<void> addProductToMeal({
|
||||
@Path('diary_id') required int diaryId,
|
||||
@Path('meal_id') required int mealId,
|
||||
@Part(name: 'product_name') required String productName,
|
||||
@Part(name: 'portion') required String portion,
|
||||
@Part(name: 'quantity') required int quantity,
|
||||
});
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@ part of 'diary_service.dart';
|
||||
// RetrofitGenerator
|
||||
// **************************************************************************
|
||||
|
||||
// ignore_for_file: unnecessary_brace_in_string_interps,no_leading_underscores_for_local_identifiers,unused_element
|
||||
// ignore_for_file: unnecessary_brace_in_string_interps,no_leading_underscores_for_local_identifiers,unused_element,unnecessary_string_interpolations
|
||||
|
||||
class _DiaryService implements DiaryService {
|
||||
_DiaryService(
|
||||
@@ -87,6 +87,49 @@ class _DiaryService implements DiaryService {
|
||||
return _value;
|
||||
}
|
||||
|
||||
@override
|
||||
Future<void> addProductToMeal({
|
||||
required int diaryId,
|
||||
required int mealId,
|
||||
required String productName,
|
||||
required String portion,
|
||||
required int quantity,
|
||||
}) async {
|
||||
final _extra = <String, dynamic>{};
|
||||
final queryParameters = <String, dynamic>{};
|
||||
final _headers = <String, dynamic>{};
|
||||
final _data = FormData();
|
||||
_data.fields.add(MapEntry(
|
||||
'product_name',
|
||||
productName,
|
||||
));
|
||||
_data.fields.add(MapEntry(
|
||||
'portion',
|
||||
portion,
|
||||
));
|
||||
_data.fields.add(MapEntry(
|
||||
'quantity',
|
||||
quantity.toString(),
|
||||
));
|
||||
final _options = _setStreamType<void>(Options(
|
||||
method: 'POST',
|
||||
headers: _headers,
|
||||
extra: _extra,
|
||||
)
|
||||
.compose(
|
||||
_dio.options,
|
||||
'/api/diary/${diaryId}/meal/${mealId}/portions/create',
|
||||
queryParameters: queryParameters,
|
||||
data: _data,
|
||||
)
|
||||
.copyWith(
|
||||
baseUrl: _combineBaseUrls(
|
||||
_dio.options.baseUrl,
|
||||
baseUrl,
|
||||
)));
|
||||
await _dio.fetch<void>(_options);
|
||||
}
|
||||
|
||||
RequestOptions _setStreamType<T>(RequestOptions requestOptions) {
|
||||
if (T != dynamic &&
|
||||
!(requestOptions.responseType == ResponseType.bytes ||
|
||||
|
||||
Reference in New Issue
Block a user