refactor(category-picker): streamline category selection flow in product picker
This commit is contained in:
@@ -64,17 +64,9 @@ class CategoryThenProductPicker {
|
||||
String? initialQuery,
|
||||
Future<ProductOption?> Function(String name, int categoryId)? onCreate,
|
||||
}) async {
|
||||
AdminCategoryNode? selectedCategory;
|
||||
|
||||
if (preselectedCategoryId != null) {
|
||||
// AI-föreslagen kategori — hoppa direkt till produktpickern
|
||||
selectedCategory = _findNode(categoryTree, preselectedCategoryId);
|
||||
}
|
||||
|
||||
if (selectedCategory == null) {
|
||||
// Steg 1 — visa kategoriträd
|
||||
// Steg 1 — visa alltid kategoriträd (med eventuell förmarkering)
|
||||
if (!context.mounted) return null;
|
||||
selectedCategory = await showModalBottomSheet<AdminCategoryNode>(
|
||||
final selectedCategory = await showModalBottomSheet<AdminCategoryNode>(
|
||||
context: context,
|
||||
isScrollControlled: true,
|
||||
useSafeArea: true,
|
||||
@@ -85,7 +77,6 @@ class CategoryThenProductPicker {
|
||||
),
|
||||
);
|
||||
if (selectedCategory == null || !context.mounted) return null;
|
||||
}
|
||||
|
||||
// Samla alla kategori-IDs i den valda grenen (inkl. ättlingar)
|
||||
final categoryIds = _collectIds(selectedCategory);
|
||||
@@ -99,7 +90,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;
|
||||
|
||||
Reference in New Issue
Block a user