feat: implement two-step category and product picker with private product creation support

This commit is contained in:
Nils-Johan Gynther
2026-05-01 02:44:30 +02:00
parent 4f387fe6eb
commit f983458ff0
3 changed files with 116 additions and 4 deletions
@@ -73,7 +73,7 @@ class CategoryThenProductPicker {
}
// Samla alla kategori-IDs i den valda grenen (inkl. ättlingar)
final categoryIds = _collectIds(selectedCategory);
final categoryIds = _collectIds(selectedCategory!);
// Filtrera produkter på dessa kategorier
final filtered = products
@@ -84,7 +84,7 @@ class CategoryThenProductPicker {
// Bygg eventuell onCreate-callback med categoryId inbunden
final onCreateBound = onCreate == null
? null
: (String name) => onCreate(name, selectedCategory.id);
: (String name) => onCreate(name, selectedCategory!.id);
// Steg 2 — välj produkt
if (!context.mounted) return null;
@@ -92,7 +92,7 @@ class CategoryThenProductPicker {
context,
products: useList,
value: currentProductId,
label: 'Produkt i "${selectedCategory.name}"',
label: 'Produkt i "${selectedCategory!.name}"',
categoryFilter: null, // redan förfiltrerat
onCreate: onCreateBound,
);