Skip to main content

Overview

Tienda ETCA uses two notification systems to provide user feedback:
  • React Toastify: Lightweight toast notifications for cart operations
  • SweetAlert2: Rich modal dialogs for admin actions and confirmations

React Toastify

Toast notifications are used in CartContext for non-intrusive feedback during shopping operations.

Implementation

Import toast from React Toastify in ~/workspace/source/src/context/CartContext.jsx:2:

Adding Products to Cart

When a product is added to the cart, the system shows different messages based on whether the product already exists:
The toast automatically displays the product name in the notification message for better user feedback.

Toast Types

Tienda ETCA uses two toast notification types:

Success Toast

Used when a new product is added to cart

Info Toast

Used when quantity is increased for existing product

Usage Example

SweetAlert2

SweetAlert2 provides rich modal dialogs for critical admin operations that require user confirmation.

Implementation

Imported in AdminContext at ~/workspace/source/src/context/AdminContext.jsx:2:

Success Notifications

Used to confirm successful operations:

Product Added

Product Updated

Confirmation Dialogs

For destructive actions, SweetAlert2 shows a confirmation dialog before proceeding:
The confirmation dialog prevents accidental deletions by requiring explicit user confirmation.

Alert Types

SweetAlert2 is used with multiple icon types:

Notification Comparison

React Toastify

Best for:
  • Non-blocking notifications
  • Cart operations
  • Quick feedback
  • Multiple simultaneous messages
Location: CartContext.jsx

SweetAlert2

Best for:
  • Confirmation dialogs
  • Destructive actions
  • Admin operations
  • Detailed error messages
Location: AdminContext.jsx

Best Practices

1

Choose the Right Notification Type

Use toasts for informational messages and SweetAlert2 for actions requiring user confirmation.
2

Include Contextual Information

Always include the product name or relevant details in notification messages.
3

Handle Errors Gracefully

Show error notifications when operations fail to keep users informed.
Both notification systems are already configured and available through their respective contexts (CartContext and AdminContext).