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:
Claude
2025-11-09 21:22:41 +00:00
parent c3a580905f
commit 9adc9725fd
8 changed files with 418 additions and 8 deletions

View File

@@ -15,6 +15,7 @@ import {
import { useTenant } from '../../../../stores/tenant.store';
import OrdersService from '../../../../api/services/orders';
import { inventoryService } from '../../../../api/services/inventory';
import { showToast } from '../../../../utils/toast';
import {
CustomerCreate,
CustomerType,
@@ -116,11 +117,14 @@ const CustomerSelectionStep: React.FC<WizardDataProps> = ({ data, onDataChange,
};
const createdCustomer = await OrdersService.createCustomer(customerData);
showToast.success('Cliente creado exitosamente');
onDataChange({ ...data, customer: createdCustomer, isNewCustomer: true });
onNext();
} catch (err: any) {
console.error('Error creating customer:', err);
setError(err.response?.data?.detail || 'Error al crear el cliente');
const errorMessage = err.response?.data?.detail || 'Error al crear el cliente';
setError(errorMessage);
showToast.error(errorMessage);
} finally {
setCreatingCustomer(false);
}
@@ -633,11 +637,14 @@ const DeliveryPaymentStep: React.FC<WizardDataProps> = ({ data, onDataChange, on
await OrdersService.createOrder(orderData);
showToast.success('Pedido creado exitosamente');
onDataChange({ ...data, ...deliveryData });
onComplete();
} catch (err: any) {
console.error('Error creating order:', err);
setError(err.response?.data?.detail || 'Error al crear el pedido');
const errorMessage = err.response?.data?.detail || 'Error al crear el pedido';
setError(errorMessage);
showToast.error(errorMessage);
} finally {
setLoading(false);
}