diff --git a/flutter/lib/features/import/presentation/receipt_import_tab.dart b/flutter/lib/features/import/presentation/receipt_import_tab.dart index 90a7fa9c..7d9cdbf6 100644 --- a/flutter/lib/features/import/presentation/receipt_import_tab.dart +++ b/flutter/lib/features/import/presentation/receipt_import_tab.dart @@ -354,21 +354,39 @@ class _EditDialogState extends State<_EditDialog> { } bool get _canConfirm { - if (_entryMode == _ProductEntryMode.create) { - return !_isCreatingProduct && - _newProductNameCtrl.text.trim().isNotEmpty && - _newCategoryId != null; - } + if (_isCreatingProduct) return false; + if (_entryMode == _ProductEntryMode.create) return true; return _productId != null; } Future _confirm() async { if (_entryMode == _ProductEntryMode.create) { - if (widget.onCreate == null || _newCategoryId == null) return; + final trimmedName = _newProductNameCtrl.text.trim(); + if (trimmedName.isEmpty) { + ScaffoldMessenger.of(context).showSnackBar( + const SnackBar(content: Text('Ange ett produktnamn först.')), + ); + return; + } + + if (_newCategoryId == null) { + ScaffoldMessenger.of(context).showSnackBar( + const SnackBar(content: Text('Välj kategori innan du skapar produkten.')), + ); + return; + } + + if (widget.onCreate == null) { + ScaffoldMessenger.of(context).showSnackBar( + const SnackBar(content: Text('Produktskapande är inte tillgängligt i den här vyn.')), + ); + return; + } + setState(() => _isCreatingProduct = true); try { final newProduct = await widget.onCreate!( - _newProductNameCtrl.text.trim(), + trimmedName, _newCategoryId!, ); if (newProduct == null || !mounted) {