Feature/wishlists notify me restock & price drop alerts#34
Conversation
|
@heet2312 is attempting to deploy a commit to the dav nguyen's projects Team on Vercel. A member of the Team first needs to authorize it. |
✅ Deploy Preview for mern-stack-ecommerce-website ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
There was a problem hiding this comment.
Code Review
This pull request introduces a comprehensive Wishlist and 'Notify Me' alert system, allowing users to save products and receive email notifications for restocks or price drops. Key additions include new Mongoose models, API endpoints for wishlist and alert management, and a SendGrid-powered email service. The frontend is updated with a dedicated wishlist page, a React context for state management, and interactive UI elements on product detail pages. Review feedback highlights opportunities to optimize the email service initialization, improve input validation for product updates, reduce unnecessary network traffic by removing wishlist polling, and ensure data consistency by fetching user emails dynamically during alert evaluation.

Description
Implements the Wishlist + "Notify Me" (Restock & Price-Drop Alerts) feature requested in Issue #21.
Shoppers can now save products to a personal wishlist and subscribe to email alerts when an out-of-stock item is restocked or when a product's price drops below a chosen threshold or percentage. Alert delivery uses a console transport in development and SendGrid in production, and is gated behind
FEATURE_ALERTS=true.Fixes #21
Type of change
How Has This Been Tested?
Unit tests — 29 new Jest tests in
backend/__tests__/wishlist-alerts.spec.jscovering:evaluateSubscriptionsservice: restock fires/no-fire, price_drop targetPrice fires/no-fire, dropPercent threshold fires/no-fire, idempotency (concurrent trigger is a no-op)Manual testing:
PATCH /api/products/:idwith{ "stock": 10 }→ backend console logs restock email ✅PATCH /api/products/:idwith{ "price": 850 }→ backend console logs price-drop email ✅TRIGGERED, idempotent) ✅To reproduce: