feat: implement Iteration 2 — product management
Backend: - migrations/005: add pg_trgm extension + search indexes on ingredient_mappings - migrations/006: products table with computed expires_at column - ingredient: add Search method (aliases + ILIKE + trgm) + HTTP handler - product: full package — model, repository (CRUD + BatchCreate + ListForPrompt), handler - gemini: add AvailableProducts field to RecipeRequest, include in prompt - recommendation: add ProductLister interface, load user products for personalised prompts - server/main: wire ingredient and product handlers with new routes Flutter: - models: Product, IngredientMapping with json_serializable - ProductService: getProducts, createProduct, updateProduct, deleteProduct, searchIngredients - ProductsNotifier: create/update/delete with optimistic delete - ProductsScreen: expiring-soon section, normal section, swipe-to-delete, edit bottom sheet - AddProductScreen: name field with 300ms debounce autocomplete, qty/unit/days fields - app_router: /products/add route + Badge on Products nav tab showing expiring count - MainShell converted to ConsumerWidget for badge reactivity Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
34
client/lib/shared/models/ingredient_mapping.dart
Normal file
34
client/lib/shared/models/ingredient_mapping.dart
Normal file
@@ -0,0 +1,34 @@
|
||||
import 'package:json_annotation/json_annotation.dart';
|
||||
|
||||
part 'ingredient_mapping.g.dart';
|
||||
|
||||
@JsonSerializable()
|
||||
class IngredientMapping {
|
||||
final String id;
|
||||
@JsonKey(name: 'canonical_name')
|
||||
final String canonicalName;
|
||||
@JsonKey(name: 'canonical_name_ru')
|
||||
final String? canonicalNameRu;
|
||||
final String? category;
|
||||
@JsonKey(name: 'default_unit')
|
||||
final String? defaultUnit;
|
||||
@JsonKey(name: 'storage_days')
|
||||
final int? storageDays;
|
||||
|
||||
const IngredientMapping({
|
||||
required this.id,
|
||||
required this.canonicalName,
|
||||
this.canonicalNameRu,
|
||||
this.category,
|
||||
this.defaultUnit,
|
||||
this.storageDays,
|
||||
});
|
||||
|
||||
/// Display name prefers Russian, falls back to canonical English name.
|
||||
String get displayName => canonicalNameRu ?? canonicalName;
|
||||
|
||||
factory IngredientMapping.fromJson(Map<String, dynamic> json) =>
|
||||
_$IngredientMappingFromJson(json);
|
||||
|
||||
Map<String, dynamic> toJson() => _$IngredientMappingToJson(this);
|
||||
}
|
||||
Reference in New Issue
Block a user