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:
@@ -3,6 +3,7 @@ import { WizardStep, WizardStepProps } from '../../../ui/WizardModal/WizardModal
|
||||
import { Wrench, CheckCircle2, Loader2 } from 'lucide-react';
|
||||
import { useTenant } from '../../../../stores/tenant.store';
|
||||
import { equipmentService } from '../../../../api/services/equipment';
|
||||
import { showToast } from '../../../../utils/toast';
|
||||
|
||||
interface WizardDataProps extends WizardStepProps {
|
||||
data: Record<string, any>;
|
||||
@@ -48,11 +49,14 @@ const EquipmentDetailsStep: React.FC<WizardDataProps> = ({ data, onDataChange, o
|
||||
|
||||
await equipmentService.createEquipment(currentTenant.id, equipmentCreateData);
|
||||
|
||||
showToast.success('Equipo creado exitosamente');
|
||||
onDataChange({ ...data, ...equipmentData });
|
||||
onComplete();
|
||||
} catch (err: any) {
|
||||
console.error('Error creating equipment:', err);
|
||||
setError(err.response?.data?.detail || 'Error al crear el equipo');
|
||||
const errorMessage = err.response?.data?.detail || 'Error al crear el equipo';
|
||||
setError(errorMessage);
|
||||
showToast.error(errorMessage);
|
||||
} finally {
|
||||
setLoading(false);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user