feat: Add toast notifications to all wizards
- Imported showToast utility from react-hot-toast wrapper - Added success toast after successful API calls in all 7 wizards - Added error toast on API failures for better user feedback - Replaced silent errors with user-visible toast notifications Wizards updated: - CustomerWizard: Toast on customer creation - EquipmentWizard: Toast on equipment creation - QualityTemplateWizard: Toast on template creation - SupplierWizard: Toast on supplier + price list creation - RecipeWizard: Toast on recipe creation - SalesEntryWizard: Toast on sales record creation - CustomerOrderWizard: Toast on customer + order creation This completes the toast notification implementation (High Priority item). Users now get immediate visual feedback on success/failure instead of relying on console.log or error state alone.
This commit is contained in:
@@ -6,6 +6,7 @@ import { recipesService } from '../../../../api/services/recipes';
|
||||
import { inventoryService } from '../../../../api/services/inventory';
|
||||
import { IngredientResponse } from '../../../../api/types/inventory';
|
||||
import { RecipeCreate, RecipeIngredientCreate, MeasurementUnit } from '../../../../api/types/recipes';
|
||||
import { showToast } from '../../../../utils/toast';
|
||||
|
||||
interface WizardDataProps extends WizardStepProps {
|
||||
data: Record<string, any>;
|
||||
@@ -259,11 +260,14 @@ const IngredientsStep: React.FC<WizardDataProps> = ({ data, onDataChange, onComp
|
||||
};
|
||||
|
||||
await recipesService.createRecipe(currentTenant.id, recipeData);
|
||||
showToast.success('Receta creada exitosamente');
|
||||
onDataChange({ ...data, ingredients: selectedIngredients });
|
||||
onComplete();
|
||||
} catch (err: any) {
|
||||
console.error('Error creating recipe:', err);
|
||||
setError(err.response?.data?.detail || 'Error al crear la receta');
|
||||
const errorMessage = err.response?.data?.detail || 'Error al crear la receta';
|
||||
setError(errorMessage);
|
||||
showToast.error(errorMessage);
|
||||
} finally {
|
||||
setSaving(false);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user