Newsletter functionality for a MERN-Stack eCommerce Website

Viewed 234

(first time posting here, don't throw rocks at me just yet )
I'd need some guidance regarding a MERN Stack (MongoDB, Express, React, Node) eCommerce Project I'm trying to implement.
I created an e-commerce website, using MERN and I'd like to add a newsletter functionality but I'm not sure what's the best way to do it
This is a link to the github project : https://github.com/Beny9313/shopIT-eCommerce.git
Link to the deployed website : https://shopit-ecommerce-beny.herokuapp.com/
My problem is as follows: I'd like to send out a link to users, every time a new product is added to the website.
I implemented the consent part (users can opt-in or opt-out of getting an email notification, the choice being saved in the DB; I'll have a question regarding this later on)
What I need to find out how to do is :

  1. How do I send the email (should I try to get "allUsers" method from my "authController.js" code as a basis, filter users by consent, send a mail with nodemailer - already have mail with nodemailer for password reset)
  2. I need some way to pass on the newly created product's ID ( I cannot think of a way of passing on this parameter to my other method, in which I try to send an email to all consented users with a link directly to my new password )
    Regarding my issue with the UI: I'd like to have the checkbox reflect the exact value in my consent variable, for each user. For now, the checkbox remains unchecked on every edit, regardless of the consent variable.
    Most likely this is due to the fact that I initialize my useState with "False". Tried without initialization, the logic goes off. Is there a fix to this, should I use a different hook, if so, which would be more suitable for my needs? I'm here to provide further details if something is not clear
0 Answers
Related