refactor(edit-dialog): improve category selection handling in AI suggestion
Co-authored-by: Copilot <copilot@github.com>
This commit is contained in:
@@ -349,6 +349,7 @@ class _EditDialogState extends State<_EditDialog> {
|
|||||||
|
|
||||||
void _applyAiSuggestionForExistingSelection() {
|
void _applyAiSuggestionForExistingSelection() {
|
||||||
final suggestedId = widget.item.suggestedProductId;
|
final suggestedId = widget.item.suggestedProductId;
|
||||||
|
int? preselectedCategoryId = widget.item.categorySuggestionId;
|
||||||
if (suggestedId != null) {
|
if (suggestedId != null) {
|
||||||
setState(() {
|
setState(() {
|
||||||
_productId = suggestedId;
|
_productId = suggestedId;
|
||||||
@@ -360,11 +361,11 @@ class _EditDialogState extends State<_EditDialog> {
|
|||||||
_categoryPathForCategoryId(_productCategoryId) ?? widget.item.categorySuggestionPath;
|
_categoryPathForCategoryId(_productCategoryId) ?? widget.item.categorySuggestionPath;
|
||||||
_productCategorySource = CategorySelectionSource.ai;
|
_productCategorySource = CategorySelectionSource.ai;
|
||||||
});
|
});
|
||||||
return;
|
preselectedCategoryId = _productCategoryId;
|
||||||
}
|
}
|
||||||
|
|
||||||
_openExistingCategoryPicker(
|
_openExistingCategoryPicker(
|
||||||
preselectedCategoryId: widget.item.categorySuggestionId,
|
preselectedCategoryId: preselectedCategoryId,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -634,7 +635,9 @@ class _EditDialogState extends State<_EditDialog> {
|
|||||||
backgroundColor: Colors.green.shade50,
|
backgroundColor: Colors.green.shade50,
|
||||||
side: BorderSide(color: Colors.green.shade300),
|
side: BorderSide(color: Colors.green.shade300),
|
||||||
visualDensity: VisualDensity.compact,
|
visualDensity: VisualDensity.compact,
|
||||||
onPressed: _applyAiSuggestionForExistingSelection,
|
onPressed: () => _openExistingCategoryPicker(
|
||||||
|
preselectedCategoryId: item.categorySuggestionId,
|
||||||
|
),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
],
|
],
|
||||||
|
|||||||
Reference in New Issue
Block a user