feat: Enhance apple categorization logic and improve bulk category update feedback
Test Suite / test (24.15.0) (push) Has been cancelled
Test Suite / test (24.15.0) (push) Has been cancelled
This commit is contained in:
@@ -116,10 +116,15 @@ class _AdminProductsPanelState extends ConsumerState<AdminProductsPanel> {
|
||||
|
||||
setState(() => _isApplying = true);
|
||||
try {
|
||||
await ref.read(adminRepositoryProvider).bulkSetCategory(
|
||||
final updated = await ref.read(adminRepositoryProvider).bulkSetCategory(
|
||||
_selectedIds.toList(),
|
||||
categoryId: categoryId,
|
||||
);
|
||||
if (updated == 0) {
|
||||
if (!mounted) return;
|
||||
_showError('Inga produkter uppdaterades. Kontrollera att valda produkter fortfarande finns och försök igen.');
|
||||
return;
|
||||
}
|
||||
if (!mounted) return;
|
||||
setState(() {
|
||||
_selectedIds.clear();
|
||||
@@ -164,11 +169,18 @@ class _AdminProductsPanelState extends ConsumerState<AdminProductsPanel> {
|
||||
if (!selectedProductIds.contains(row.productId)) continue;
|
||||
grouped.putIfAbsent(row.categoryId, () => <int>[]).add(row.productId);
|
||||
}
|
||||
var totalUpdated = 0;
|
||||
for (final entry in grouped.entries) {
|
||||
await ref.read(adminRepositoryProvider).bulkSetCategory(
|
||||
final updated = await ref.read(adminRepositoryProvider).bulkSetCategory(
|
||||
entry.value,
|
||||
categoryId: entry.key,
|
||||
);
|
||||
totalUpdated += updated;
|
||||
}
|
||||
if (totalUpdated == 0) {
|
||||
if (!mounted) return;
|
||||
_showError('AI-förslag kunde inte sparas. Prova att uppdatera listan och kör igen.');
|
||||
return;
|
||||
}
|
||||
if (!mounted) return;
|
||||
setState(() => _selectedIds.clear());
|
||||
|
||||
Reference in New Issue
Block a user