feat(shopping-list): add shopping list feature with flyer integration
This commit introduces a comprehensive shopping list feature with the following key changes: Backend: - Added ShoppingListItem model with relations to User, Product, and Category - Added new fields to FlyerSession for source file metadata - Added categoryId field to FlyerItem model - Implemented session source file retrieval endpoint - Added endpoint for updating flyer session items with category assignment - Added endpoint for planning flyer selections to shopping list - Implemented backfillCategoriesMine for AI-assisted category assignment - Added ShoppingListModule and integrated with FlyerSelectionModule Frontend: - Added ShoppingListScreen and navigation route - Implemented API paths and client methods for shopping list operations - Added category tree loading for shopping list item creation - Integrated shopping list functionality in flyer import tab - Added category backfill trigger in inventory screen - Updated FlyerImportItem model with categoryId support - Added methods for updating flyer session items and retrieving source files Database: - Added new Prisma migration for flyer source metadata and shopping list items - Updated schema with new relations and indexes The shopping list feature allows users to: 1. Plan flyer selections directly to their shopping list 2. View and manage their shopping list items 3. Update flyer session items with proper categorization 4. Retrieve original flyer source files 5. Automatically backfill categories for uncategorized products
This commit is contained in:
@@ -2,7 +2,8 @@ class FlyerImportItem {
|
||||
final int? flyerItemId;
|
||||
final String rawName;
|
||||
final String normalizedName;
|
||||
final String? category;
|
||||
final String? category;
|
||||
final int? categoryId;
|
||||
final double? price;
|
||||
final String? priceUnit;
|
||||
final String? offerText;
|
||||
@@ -21,7 +22,8 @@ class FlyerImportItem {
|
||||
required this.flyerItemId,
|
||||
required this.rawName,
|
||||
required this.normalizedName,
|
||||
this.category,
|
||||
this.category,
|
||||
this.categoryId,
|
||||
this.price,
|
||||
this.priceUnit,
|
||||
this.offerText,
|
||||
@@ -42,7 +44,8 @@ class FlyerImportItem {
|
||||
flyerItemId: (json['flyerItemId'] as num?)?.toInt(),
|
||||
rawName: json['rawName'] as String? ?? '',
|
||||
normalizedName: json['normalizedName'] as String? ?? '',
|
||||
category: json['category'] as String?,
|
||||
category: json['category'] as String?,
|
||||
categoryId: (json['categoryId'] as num?)?.toInt(),
|
||||
price: (json['price'] as num?)?.toDouble(),
|
||||
priceUnit: json['priceUnit'] as String?,
|
||||
offerText: json['offerText'] as String?,
|
||||
@@ -65,6 +68,7 @@ class FlyerImportItem {
|
||||
'rawName': rawName,
|
||||
'normalizedName': normalizedName,
|
||||
'category': category,
|
||||
'categoryId': categoryId,
|
||||
'price': price,
|
||||
'priceUnit': priceUnit,
|
||||
'offerText': offerText,
|
||||
@@ -80,4 +84,31 @@ class FlyerImportItem {
|
||||
'matchConfidence': matchConfidence,
|
||||
};
|
||||
}
|
||||
|
||||
FlyerImportItem copyWith({
|
||||
String? rawName,
|
||||
String? category,
|
||||
int? categoryId,
|
||||
}) {
|
||||
return FlyerImportItem(
|
||||
flyerItemId: flyerItemId,
|
||||
rawName: rawName ?? this.rawName,
|
||||
normalizedName: normalizedName,
|
||||
category: category ?? this.category,
|
||||
categoryId: categoryId ?? this.categoryId,
|
||||
price: price,
|
||||
priceUnit: priceUnit,
|
||||
offerText: offerText,
|
||||
isOffer: isOffer,
|
||||
offerLimitText: offerLimitText,
|
||||
comparisonPrice: comparisonPrice,
|
||||
comparisonUnit: comparisonUnit,
|
||||
parseConfidence: parseConfidence,
|
||||
parseReasons: parseReasons,
|
||||
matchedProductId: matchedProductId,
|
||||
matchedProductName: matchedProductName,
|
||||
matchedVia: matchedVia,
|
||||
matchConfidence: matchConfidence,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,11 +4,19 @@ class FlyerImportResult {
|
||||
final int? sessionId;
|
||||
final List<FlyerImportItem> items;
|
||||
final List<String> warnings;
|
||||
final bool sourceAvailable;
|
||||
final String? sourceFileName;
|
||||
final String? sourceMimeType;
|
||||
final int? sourceFileSize;
|
||||
|
||||
FlyerImportResult({
|
||||
required this.sessionId,
|
||||
required this.items,
|
||||
required this.warnings,
|
||||
required this.sourceAvailable,
|
||||
this.sourceFileName,
|
||||
this.sourceMimeType,
|
||||
this.sourceFileSize,
|
||||
});
|
||||
|
||||
factory FlyerImportResult.fromJson(Map<String, dynamic> json) {
|
||||
@@ -24,6 +32,10 @@ class FlyerImportResult {
|
||||
.map((item) => FlyerImportItem.fromJson(item as Map<String, dynamic>))
|
||||
.toList(),
|
||||
warnings: warnings,
|
||||
sourceAvailable: json['sourceAvailable'] == true,
|
||||
sourceFileName: json['sourceFileName'] as String?,
|
||||
sourceMimeType: json['sourceMimeType'] as String?,
|
||||
sourceFileSize: (json['sourceFileSize'] as num?)?.toInt(),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -32,6 +44,10 @@ class FlyerImportResult {
|
||||
'sessionId': sessionId,
|
||||
'items': items.map((item) => item.toJson()).toList(),
|
||||
'warnings': warnings,
|
||||
'sourceAvailable': sourceAvailable,
|
||||
'sourceFileName': sourceFileName,
|
||||
'sourceMimeType': sourceMimeType,
|
||||
'sourceFileSize': sourceFileSize,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user