diff --git a/resources/KYC/KycController.js b/resources/KYC/KycController.js index 5abd4d4..23ccc2e 100644 --- a/resources/KYC/KycController.js +++ b/resources/KYC/KycController.js @@ -337,13 +337,29 @@ export const createretaildistributor = async (req, res) => { await sendEmail({ to: `${email}`, // Change to your recipient from: `${process.env.SEND_EMAIL_FROM}`, // Change to your verified sender - subject: `Cheminova Account Created`, - html: `Your Retail Distributor Account is created successfully. -
name is: ${name} -
-
MobileNumber is: ${mobile_number}
-
Email is: ${email}
-
password is: ${password}

If you have not requested this email, please ignore it.`, + subject: `Welcome to Cheminova - Account Created Successfully`, + html: ` +

Dear ${name},

+

We are pleased to inform you that your retailer account has been successfully created. Please find your account details below:

+

Name: ${name}

+

Mobile Number: ${mobile_number}

+
Email is: ${email}
+

Password: ${password}

+
+

You can log in to your account using the following link:

+

Click here to log in

+
+

For convenience, you can also download our mobile app from the following links:

+ +
+

If you have not requested this email or have any concerns, please contact our support team immediately.

+
+

Best regards,

+

Cheminova Support Team

+ `, }); // Send response res.status(201).json({ @@ -550,12 +566,29 @@ export const updateKycStatus = async (req, res) => { await sendEmail({ to: kyc.email, from: process.env.SEND_EMAIL_FROM, - subject: `Cheminova Account Created`, - html: `Your Retail Distributor Account is created successfully. -
name is: ${kyc.name} -
Mobile Number is: ${kyc.mobile_number}
+ subject: `Welcome to Cheminova - Account Created Successfully`, + html: ` +

Dear ${kyc.name},

+

We are pleased to inform you that your Retailer account has been successfully created. Please find your account details below:

+

Name: ${kyc.name}

+

Mobile Number: ${kyc.mobile_number}


Email is: ${kyc.email}
-
password is: ${password}

If you have not requested this email, please ignore it.`, +

Password: ${password}

+
+

You can log in to your account using the following link:

+

Click here to log in

+
+

For convenience, you can also download our mobile app from the following links:

+ +
+

If you have not requested this email or have any concerns, please contact our support team immediately.

+
+

Best regards,

+

Cheminova Support Team

+ `, }); } diff --git a/resources/RetailDistributor/RetailDistributorController.js b/resources/RetailDistributor/RetailDistributorController.js index 0420045..50d94dd 100644 --- a/resources/RetailDistributor/RetailDistributorController.js +++ b/resources/RetailDistributor/RetailDistributorController.js @@ -304,13 +304,29 @@ export const uploadRetaildistributors = async (req, res) => { await sendEmail({ to: `${item.email}`, // Change to your recipient from: `${process.env.SEND_EMAIL_FROM}`, // Change to your verified sender - subject: `Cheminova Account Created`, - html: `Your Retail Distributor Account is created successfully. -
name is: ${item.name} -
-
MobileNumber is: ${item.mobile_number}
-
Email is: ${item.email}
-
password is: ${password}

If you have not requested this email, please ignore it.`, + subject: `Welcome to Cheminova - Account Created Successfully`, + html: ` +

Dear ${name},

+

We are pleased to inform you that your Retailer account has been successfully created. Please find your account details below:

+

Name: ${item.name}

+

Mobile Number: ${item.mobile_number}

+

Email: ${item.email}

+

Password: ${password}

+
+

You can log in to your account using the following link:

+

Click here to log in

+
+

For convenience, you can also download our mobile app from the following links:

+ +
+

If you have not requested this email or have any concerns, please contact our support team immediately.

+
+

Best regards,

+

Cheminova Support Team

+ `, }); newlyCreated.push({ Kyc }); } @@ -335,7 +351,6 @@ export const uploadRetaildistributors = async (req, res) => { } }; - // Helper function to upload images to Cloudinary const uploadImage = async (image, folder) => { if (!image) return null; @@ -391,24 +406,38 @@ export const updateretaildistributorwithKYC = async (req, res) => { kycUpdates.pan_img = await uploadImage(files.panImg, "KYC/pan"); } if (files.aadharImg) { - kycUpdates.aadhar_img = await uploadImage(files.aadharImg, "KYC/aadhar"); + kycUpdates.aadhar_img = await uploadImage( + files.aadharImg, + "KYC/aadhar" + ); } if (files.gstImg) { kycUpdates.gst_img = await uploadImage(files.gstImg, "KYC/gst"); } if (files.pesticideLicenseImg) { - kycUpdates.pesticide_license_img = await uploadImage(files.pesticideLicenseImg, "KYC/pesticide_license"); + kycUpdates.pesticide_license_img = await uploadImage( + files.pesticideLicenseImg, + "KYC/pesticide_license" + ); } if (files.fertilizerLicenseImg) { - kycUpdates.fertilizer_license_img = await uploadImage(files.fertilizerLicenseImg, "KYC/fertilizer_license"); + kycUpdates.fertilizer_license_img = await uploadImage( + files.fertilizerLicenseImg, + "KYC/fertilizer_license" + ); } if (files.selfieEntranceImg) { - kycUpdates.selfie_entrance_img = await uploadImage(files.selfieEntranceImg, "KYC/selfie_entrance"); + kycUpdates.selfie_entrance_img = await uploadImage( + files.selfieEntranceImg, + "KYC/selfie_entrance" + ); } } // Update the KYC model - const updatedKYC = await KYC.findByIdAndUpdate(kycId, kycUpdates, { new: true }); + const updatedKYC = await KYC.findByIdAndUpdate(kycId, kycUpdates, { + new: true, + }); if (!updatedKYC) { return res.status(404).json({ message: "KYC record not found" }); } @@ -442,7 +471,8 @@ export const updateretaildistributorwithKYC = async (req, res) => { } res.status(200).json({ - message: "Retail Distributor, KYC, and Shipping Address updated successfully", + message: + "Retail Distributor, KYC, and Shipping Address updated successfully", success: true, retailDistributor: updatedRetailDistributor, kyc: updatedKYC, @@ -625,17 +655,25 @@ export const ResetPassword = async (req, res) => { from: `${process.env.SEND_EMAIL_FROM}`, // Sender email subject: "Cheminova Account Credentials", html: ` -

Dear ${Retailers.name},

-

Your account credentials have been updated. Please find your new login details below:

-

Email: ${Retailers.email}

-

Password: ${newPassword}

-

Please use these credentials to log in to your account. For security reasons, it's recommended to change your password after logging in.

-
-

If you did not request this change, please contact our support team immediately.

-
-

Best regards,

-

Cheminova Support Team

- `, +

Dear ${Retailers.name},

+

Your Retailer account credentials have been updated. Please find your new login details below:

+

Email: ${Retailers.email}

+

Password: ${newPassword}

+

Please use these credentials to log in to your account. For security reasons, it's recommended to change your password after logging in.

+
+

To log in via our website, please click here.

+

To download our mobile app, use the following links:

+ +
+

If you did not request this change, please contact our support team immediately.

+
+

Best regards,

+

Cheminova Support Team

+ `, }); // console.log(Retailers); res.status(200).json({ @@ -1911,7 +1949,10 @@ export const generateRetailerReport = async (req, res) => { try { // Fetch retailer data and populate required fields const retailers = await RetailDistributor.find() - .populate("kyc", "trade_name pan_number aadhar_number gst_number state city district address pincode") + .populate( + "kyc", + "trade_name pan_number aadhar_number gst_number state city district address pincode" + ) .populate("principal_distributer", "name") .populate("mappedTM", "name") .populate("mappedSC", "name") @@ -2007,4 +2048,4 @@ export const generateRetailerReport = async (req, res) => { console.error("Error generating retailer report:", error); res.status(500).json({ message: "Failed to generate report" }); } -}; \ No newline at end of file +}; diff --git a/resources/SalesCoOrdinators/SalesCoOrdinatorController.js b/resources/SalesCoOrdinators/SalesCoOrdinatorController.js index 841cc93..796dfe9 100644 --- a/resources/SalesCoOrdinators/SalesCoOrdinatorController.js +++ b/resources/SalesCoOrdinators/SalesCoOrdinatorController.js @@ -231,11 +231,29 @@ export const uploadSalesCoordinators = async (req, res) => { await sendEmail({ to: `${item?.email}`, // Change to your recipient from: `${process.env.SEND_EMAIL_FROM}`, // Change to your verified sender - subject: `Cheminova Account Created`, - html: `Your Sales Coordinator Account is created successfully. -
Name: ${item?.name}
-
Mobile Number: ${item?.mobileNumber}
-
Password: ${password}

If you have not requested this email, please ignore it.`, + subject: `Welcome to Cheminova - Account Created Successfully`, + html: ` +

Dear ${item?.name},

+

We are pleased to inform you that your Sales Coordinator account has been successfully created. Please find your account details below:

+

Name: ${item?.name}

+

Mobile Number: ${item?.mobileNumber}

+

Email: ${item.email}

+

Password: ${password}

+
+

You can log in to your account using the following link:

+ +
+

For convenience, you can also download our mobile app from the following links:

+ +
+

If you have not requested this email or have any concerns, please contact our support team immediately.

+
+

Best regards,

+

Cheminova Support Team

+ `, }); newlyCreated.push({ salesCoordinator }); } @@ -357,11 +375,29 @@ export const verifyOtp = async (req, res) => { await sendEmail({ to: `${salesCoordinator?.email}`, // Change to your recipient from: `${process.env.SEND_EMAIL_FROM}`, // Change to your verified sender - subject: `Cheminova Account Created`, - html: `Your Sales Coordinator Account is created successfully. -
name is: ${name}
-
MobileNumber is: ${mobile}
-
password is: ${newPassword}

If you have not requested this email, please ignore it.`, + subject: `Welcome to Cheminova - Account Created Successfully`, + html: ` +

Dear ${name},

+

We are pleased to inform you that your Sales Coordinator account has been successfully created. Please find your account details below:

+

Name: ${name}

+

Mobile Number: ${mobile}

+

Email: ${salesCoordinator.email}

+

Password: ${newPassword}

+
+

You can log in to your account using the following link:

+ +
+

For convenience, you can also download our mobile app from the following links:

+ +
+

If you have not requested this email or have any concerns, please contact our support team immediately.

+
+

Best regards,

+

Cheminova Support Team

+ `, }); const token = salesCoordinator.getJWTToken(); @@ -751,17 +787,23 @@ export const ResetPassword = async (req, res) => { from: `${process.env.SEND_EMAIL_FROM}`, // Sender email subject: "Cheminova Account Credentials", html: ` -

Dear ${salescoordinator.name},

-

Your account credentials have been updated. Please find your new login details below:

-

Email: ${salescoordinator.email}

-

Password: ${newPassword}

-

Please use these credentials to log in to your account. For security reasons, it's recommended to change your password after logging in.

-
-

If you did not request this change, please contact our support team immediately.

-
-

Best regards,

-

Cheminova Support Team

- `, +

Dear ${salescoordinator.name},

+

Your Sales Coordinator account credentials have been updated. Please find your new login details below:

+

Email: ${salescoordinator.email}

+

Password: ${newPassword}

+

Please use these credentials to log in to your account. For security reasons, it's recommended to change your password after logging in.

+
+

To download our mobile app, use the following links:

+ +
+

If you did not request this change, please contact our support team immediately.

+
+

Best regards,

+

Cheminova Support Team

+ `, }); // console.log(salescoordinator); res.status(200).json({ diff --git a/resources/TerritoryManagers/TerritoryManagerController.js b/resources/TerritoryManagers/TerritoryManagerController.js index 0a96084..460a272 100644 --- a/resources/TerritoryManagers/TerritoryManagerController.js +++ b/resources/TerritoryManagers/TerritoryManagerController.js @@ -229,11 +229,26 @@ export const uploadTerritoryManagers = async (req, res) => { await sendEmail({ to: `${item?.email}`, // Change to your recipient from: `${process.env.SEND_EMAIL_FROM}`, // Change to your verified sender - subject: `Cheminova Account Created`, - html: `Your Territory Manager Account is created successfully. -
name is: ${item?.name}
-
MobileNumber is: ${item?.mobileNumber}
-
password is: ${password}

If you have not requested this email, please ignore it.`, + subject: `Welcome to Cheminova - Account Created Successfully`, + html: ` +

Dear ${item.name},

+

We are pleased to inform you that your Territory Manager account has been successfully created. Please find your account details below:

+

Name: ${item.name}

+

Mobile Number: ${item.mobileNumber}

+

Email: ${item.email}

+

Password: ${password}

+
+
+

For convenience, you can also download our mobile app from the following links:

+ +
+

If you have not requested this email or have any concerns, please contact our support team immediately.

+
+

Best regards,

+

Cheminova Support Team

+ `, }); newlyCreated.push({ territoryManager }); } @@ -351,11 +366,26 @@ export const verifyOtp = async (req, res) => { await sendEmail({ to: `${territoryManager?.email}`, // Change to your recipient from: `${process.env.SEND_EMAIL_FROM}`, // Change to your verified sender - subject: `Cheminova Account Created`, - html: `Your Territory Manager Account is created successfully. -
name is: ${name}
-
MobileNumber is: ${mobile}
-
password is: ${newPassword}

If you have not requested this email, please ignore it.`, + subject: `Welcome to Cheminova - Account Created Successfully`, + html: ` +

Dear ${name},

+

We are pleased to inform you that your Territory Manager account has been successfully created. Please find your account details below:

+

Name: ${name}

+

Mobile Number: ${mobile}

+

Email: ${territoryManager.email}

+

Password: ${newPassword}

+
+
+

For convenience, you can also download our mobile app from the following links:

+ +
+

If you have not requested this email or have any concerns, please contact our support team immediately.

+
+

Best regards,

+

Cheminova Support Team

+ `, }); const token = territoryManager.getJWTToken(); @@ -603,17 +633,22 @@ export const ResetPassword = async (req, res) => { from: `${process.env.SEND_EMAIL_FROM}`, // Sender email subject: "Cheminova Account Credentials", html: ` -

Dear ${territorymanager.name},

-

Your account credentials have been updated. Please find your new login details below:

-

Email: ${territorymanager.email}

-

Password: ${newPassword}

-

Please use these credentials to log in to your account. For security reasons, it's recommended to change your password after logging in.

-
-

If you did not request this change, please contact our support team immediately.

-
-

Best regards,

-

Cheminova Support Team

- `, +

Dear ${territorymanager.name},

+

Your Territory Manager account credentials have been updated. Please find your new login details below:

+

Email: ${territorymanager.email}

+

Password: ${newPassword}

+

Please use these credentials to log in to your account. For security reasons, it's recommended to change your password after logging in.

+
+

To download our mobile app, use the following links:

+ +
+

If you did not request this change, please contact our support team immediately.

+
+

Best regards,

+

Cheminova Support Team

+ `, }); // console.log(territorymanager); res.status(200).json({ diff --git a/resources/user/userController.js b/resources/user/userController.js index 9dd0550..af359e2 100644 --- a/resources/user/userController.js +++ b/resources/user/userController.js @@ -333,15 +333,30 @@ export const uploadPrincipaldistributors = async (req, res) => { await sendEmail({ to: distributor.email, from: process.env.SEND_EMAIL_FROM, - subject: `Cheminova Account Created`, + subject: `Welcome to Cheminova - Account Created Successfully`, html: ` - Your Principal Distributor Account is created successfully. -
Name: ${distributor.name}
-
Mobile Number: ${distributor.phone}
-
Password: ${password}

- Click here to login

- If you have not requested this email, please ignore it. - `, +

Dear ${distributor.name},

+

We are pleased to inform you that your Principal Distributor account has been successfully created. Please find your account details below:

+

Name: ${distributor.name}

+

Mobile Number: ${distributor.phone}

+

Email: ${distributor.email}

+

Password: ${distributor.password}

+
+

You can log in to your account using the following link:

+

Click here to log in

+
+

For convenience, you can also download our mobile app from the following links:

+ +
+

If you have not requested this email or have any concerns, please contact our support team immediately.

+
+

Best regards,

+

Cheminova Support Team

+ `, }); // Now create the address for the new user const addressData = { @@ -441,14 +456,29 @@ export const registerUser = async (req, res) => { await sendEmail({ to: email, from: process.env.SEND_EMAIL_FROM, - subject: `Cheminova Account Created`, + subject: `Welcome to Cheminova - Account Created Successfully`, html: ` - Your Principal Distributor Account is created successfully. -
Name: ${name}
-
Mobile Number: ${phone}
-
Password: ${password}

- Click here to login

- If you have not requested this email, please ignore it. +

Dear ${name},

+

We are pleased to inform you that your Principal Distributor account has been successfully created. Please find your account details below:

+

Name: ${name}

+

Mobile Number: ${phone}

+

Email: ${email}

+

Password: ${password}

+
+

You can log in to your account using the following link:

+

Click here to log in

+
+

For convenience, you can also download our mobile app from the following links:

+ +
+

If you have not requested this email or have any concerns, please contact our support team immediately.

+
+

Best regards,

+

Cheminova Support Team

`, }); } @@ -573,7 +603,9 @@ export const ResetPasswordAdmin = async (req, res) => { const user = await User.findById(id); if (!user) { - return res.status(404).json({ message: "Principal Distributor not found" }); + return res + .status(404) + .json({ message: "Principal Distributor not found" }); } // Generate a new random password @@ -591,24 +623,34 @@ export const ResetPasswordAdmin = async (req, res) => { user.password = newPassword; await user.save(); + // Send email with the new credentials // Send email with the new credentials await sendEmail({ to: `${user.email}`, // Recipient email from: `${process.env.SEND_EMAIL_FROM}`, // Sender email subject: "Cheminova Account Credentials", html: ` -

Dear ${user.name},

-

Your account credentials have been updated. Please find your new login details below:

-

Email: ${user.email}

-

Password: ${newPassword}

-

Please use these credentials to log in to your account. For security reasons, it's recommended to change your password after logging in.

-
-

If you did not request this change, please contact our support team immediately.

-
-

Best regards,

-

Cheminova Support Team

- `, +

Dear ${user.name},

+

Your Principal Distributor account credentials have been updated. Please find your new login details below:

+

Email: ${user.email}

+

Password: ${newPassword}

+

Please use these credentials to log in to your account. For security reasons, it's recommended to change your password after logging in.

+
+

To log in via our website, please click here.

+

To download our mobile app, use the following links:

+ +
+

If you did not request this change, please contact our support team immediately.

+
+

Best regards,

+

Cheminova Support Team

+ `, }); + // console.log(user); res.status(200).json({ success: true,