forked from eatvio/eatvio_app
fix(plans, recipes): added new end points for plans and recipes creation
This commit is contained in:
@@ -132,6 +132,12 @@ enum Portion {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
String getValue() => switch (this) {
|
||||
Portion.grams => 'gr',
|
||||
Portion.milliliters => 'milliliters',
|
||||
Portion.pcs => 'pcs',
|
||||
};
|
||||
}
|
||||
|
||||
@freezed
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
import 'dart:ffi';
|
||||
|
||||
import 'package:eatvio_app/core/models/pagination_model.dart';
|
||||
import 'package:eatvio_app/features/feed/models/diets_pagination_model.dart';
|
||||
import 'package:eatvio_app/features/my_finance/models/card_model.dart';
|
||||
@@ -63,7 +65,7 @@ PlanType planTypeFromJson(dynamic json) {
|
||||
@freezed
|
||||
class PacketOptions with _$PacketOptions {
|
||||
const factory PacketOptions({
|
||||
@JsonKey(name: "items") required List<String> items,
|
||||
@JsonKey(name: "items", fromJson: _parseItems) required List<String> items,
|
||||
@JsonKey(name: "price") required dynamic price,
|
||||
@JsonKey(name: "short") required String short,
|
||||
@JsonKey(name: "description_md") required String description,
|
||||
@@ -71,7 +73,14 @@ class PacketOptions with _$PacketOptions {
|
||||
|
||||
factory PacketOptions.fromJson(Map<String, dynamic> json) => _$PacketOptionsFromJson(json);
|
||||
|
||||
factory PacketOptions.empty() => const PacketOptions(items: [], price: 1200, short: '', description: '');
|
||||
factory PacketOptions.empty() => PacketOptions(items: [], price: double.parse('1200'), short: '', description: '');
|
||||
}
|
||||
|
||||
List<String> _parseItems(json) {
|
||||
if (json is Map<String, dynamic>) {
|
||||
return json.values.map((e) => e as String).toList();
|
||||
}
|
||||
return (json as List<dynamic>).map((e) => e as String).toList();
|
||||
}
|
||||
|
||||
@freezed
|
||||
|
||||
Reference in New Issue
Block a user