diff --git a/.env b/.env
index e8a5d77..b3dc341 100644
--- a/.env
+++ b/.env
@@ -1,15 +1,17 @@
# mongodb
-# DB_URL="mongodb+srv://Get-Sygnal:Doo1KHDIWWlSsTFW@cluster0.zom9mlq.mongodb.net/?retryWrites=true&w=majority"
-DB_URL="mongodb+srv://Get-Sygnal:Doo1KHDIWWlSsTFW@cluster.zom9mlq.mongodb.net/test?ssl=true&sslValidate=true"
-PORT = 8000
+# DB_URL="mongodb+srv://smellica:Anjefef23dnsfjne@cluster0.c5gfqzm.mongodb.net/?retryWrites=true&w=majority"
+# DB_URL="mongodb+srv://Get-Sygnal:Doo1KHDIWWlSsTFW@cluster.zom9mlq.mongodb.net/test?ssl=true&sslValidate=true"
+DB_URL="mongodb+srv://smellica:Anjefef23dnsfjne@cluster0.c5gfqzm.mongodb.net/"
+# //Anjefef23dnsfjne
+PORT = 5000
JWT_SECRET = jdvnvjwrniwj4562jn6@1xsbfeh@wre4Njdf;
-# // Get-Sygnal cloudinary credential
-CLOUDINARY_NAME = "dne5rkqkt"
-CLOUDINARY_API_KEY = "335493365729323"
-CLOUDINARY_API_SECRET = "uBPv-qUGSGBwVyUKya6tGZjrBSc"
+# // smellica cloudinary credential
+CLOUDINARY_NAME = "dnmgivd1x"
+CLOUDINARY_API_KEY = "877544192441588"
+CLOUDINARY_API_SECRET = "9paejuSC-fY5b0WoaUuSFURSnvM"
# SEND_EMAIL_FROM="project.boloai@gmail.com"
@@ -20,15 +22,15 @@ CLOUDINARY_API_SECRET = "uBPv-qUGSGBwVyUKya6tGZjrBSc"
# SMPT_PORT="587"
# SMPT_MAIL="beameri.team@gmail.com"
# SMPT_PASSWORD="xsmtpsib-a88c224860249a3f1e0765e0e3d119c1bf07ad21f2859318fbf50975deee1711-JrdPpfsvF6LwEn4A"
-SEND_EMAIL_FROM="admin@getsygnal.com"
+SEND_EMAIL_FROM="hello@smellika.com"
# Bolo Ai
SENDGRID_API_KEY="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"
SMPT_HOST="smtp-relay.brevo.com"
SMPT_PORT="587"
-SMPT_MAIL=" admin@getsygnal.com"
-SMPT_PASSWORD="j15Jb8UzhmMx07pN"
+SMPT_MAIL="neonflake.enterprises@gmail.com"
+SMPT_PASSWORD="ND5sgVnWtrpUFfTb"
# SMPT_PASSWORD="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"
PAYPAL_CLIENT_ID="AemCjVuWswklp1sWUo4peCFg9eS4bofMsMR0RCrVRB2DifYR1IUSrWqtHpVmQlrVMKTI2cWZXLJAdYwn"
diff --git a/Utils/sendEmail.js b/Utils/sendEmail.js
index 321a290..cdc2f5a 100644
--- a/Utils/sendEmail.js
+++ b/Utils/sendEmail.js
@@ -19,13 +19,14 @@ const transporter = createTransport({
// };
const sendEmail = async (options) => {
- console.log(options);
+ // console.log(options);
await transporter.sendMail(options, function (error, info) {
if (error) {
console.log(error);
- } else {
- console.log("Email sent: " + info.response);
}
+ // else {
+ // console.log("Email sent: " + info?.response);
+ // }
});
};
export default sendEmail;
diff --git a/resources/Content/ContentController.js b/resources/Content/ContentController.js
index 14a7f8c..f7500ff 100644
--- a/resources/Content/ContentController.js
+++ b/resources/Content/ContentController.js
@@ -1,4 +1,5 @@
import { PrivacyAndPolicy } from "./PrivacyPolicyModel.js";
+import { Refundpolicy } from "./RefundModel.js";
import { Shipping } from "./ShippingModel.js";
import { TermsAndCondition } from "./TermsandConditonModel.js";
@@ -73,6 +74,61 @@ export const updateTermsAndConditions = async (req, res) => {
});
}
};
+//refund Policy
+export const RefundPolicy = async (req, res) => {
+ try {
+ if (!req?.user) return res.status(400).json({ message: "please login !" });
+ // console.log(req?.user)
+ const { content } = req.body;
+ const findv = await Refundpolicy.findOne();
+ let refundPolicy;
+ if (findv) {
+ refundPolicy = await Refundpolicy.findOneAndUpdate(
+ {
+ addedBy: req.user._id,
+ },
+ {
+ Refundpolicy: content,
+ }
+ );
+ } else {
+ refundPolicy = await Refundpolicy.create({
+ addedBy: req.user._id,
+ Refundpolicy: content,
+ });
+ }
+
+ res.status(200).json({
+ success: true,
+ refundPolicy,
+ message: "updated successfully ",
+ });
+ } catch (error) {
+ res.status(500).json({
+ success: false,
+ message: error.message ? error.message : "Something went Wrong",
+ });
+ }
+};
+
+//
+
+export const getRefundPolicy = async (req, res) => {
+ try {
+ const Refundpolicys = await Refundpolicy.find();
+
+ res.status(200).json({
+ success: true,
+ Refundpolicys,
+ message: "Found successfully ",
+ });
+ } catch (error) {
+ res.status(500).json({
+ success: false,
+ message: error.message ? error.message : "Something went Wrong",
+ });
+ }
+};
// Privacy policy controller functions
diff --git a/resources/Content/ContentRoutes.js b/resources/Content/ContentRoutes.js
index dbefc41..907dafe 100644
--- a/resources/Content/ContentRoutes.js
+++ b/resources/Content/ContentRoutes.js
@@ -3,7 +3,9 @@ import {
AddPrivacyAndPolicy,
AddShipping,
AddTermsAndConditions,
+ RefundPolicy,
getPrivacyPolicy,
+ getRefundPolicy,
getShipping,
getTermsAndCondition,
updatePrivacyPolicy,
@@ -17,9 +19,7 @@ const router = express.Router();
router
.route("/terms-and-conditions")
.post(isAuthenticatedUser, authorizeRoles("admin"), AddTermsAndConditions);
-router
- .route("/terms-and-conditions")
- .get(getTermsAndCondition);
+router.route("/terms-and-conditions").get(getTermsAndCondition);
router
.route("/terms-and-condition-update")
.patch(
@@ -30,9 +30,7 @@ router
router
.route("/privacy-and-policy")
.post(isAuthenticatedUser, authorizeRoles("admin"), AddPrivacyAndPolicy);
-router
- .route("/privacy-and-policy")
- .get(getPrivacyPolicy);
+router.route("/privacy-and-policy").get(getPrivacyPolicy);
router
.route("/privacy-and-policy-update")
.patch(isAuthenticatedUser, authorizeRoles("admin"), updatePrivacyPolicy);
@@ -40,11 +38,15 @@ router
router
.route("/shipping-and-policy")
.post(isAuthenticatedUser, authorizeRoles("admin"), AddShipping);
-router
- .route("/shipping-and-policy")
- .get(getShipping);
+router.route("/shipping-and-policy").get(getShipping);
router
.route("/shipping-and-policy-update")
.patch(isAuthenticatedUser, authorizeRoles("admin"), updateShipping);
+//refund Policy
+router.route("/refund-policy").get(getRefundPolicy);
+router
+ .route("/refund-policy")
+ .patch(isAuthenticatedUser, authorizeRoles("admin"), RefundPolicy);
+//
export default router;
diff --git a/resources/Content/RefundModel.js b/resources/Content/RefundModel.js
new file mode 100644
index 0000000..3a7f40b
--- /dev/null
+++ b/resources/Content/RefundModel.js
@@ -0,0 +1,17 @@
+import mongoose from "mongoose";
+const { Schema, model } = mongoose;
+const RefundpolicySchema = new Schema(
+ {
+ Refundpolicy: {
+ type: String,
+ },
+ addedBy: {
+ type: mongoose.Schema.ObjectId,
+ ref: "User",
+ required: true,
+ },
+ },
+ { timestamps: true }
+);
+
+export const Refundpolicy = model("refund-policy", RefundpolicySchema);
diff --git a/resources/Products/ProductController.js b/resources/Products/ProductController.js
index 8f5f735..887ed0c 100644
--- a/resources/Products/ProductController.js
+++ b/resources/Products/ProductController.js
@@ -24,7 +24,7 @@ export const createProduct = async (req, res) => {
const imagesLinks = [];
for (let i = 0; i < images.length; i++) {
const result = await cloudinary.v2.uploader.upload(images[i], {
- folder: "GetSygnal/product",
+ folder: "smellica/product",
});
imagesLinks.push({
@@ -54,9 +54,14 @@ export const createProduct = async (req, res) => {
//get All Product
export const getAllProduct = async (req, res) => {
try {
- const product = await Product.find().sort({
- createdAt: -1,
- });
+ const product = await Product.find()
+ .populate({
+ path: "category gst addedBy",
+ select: "name categoryName tax",
+ })
+ .sort({
+ createdAt: -1,
+ });
if (product) {
return res.status(200).json({
success: true,
@@ -73,7 +78,10 @@ export const getAllProduct = async (req, res) => {
//get One Product
export const getOneProduct = async (req, res) => {
try {
- const product = await Product.findById(req.params.id);
+ const product = await Product.findById(req.params.id).populate({
+ path: "category gst addedBy",
+ select: "name categoryName tax",
+ });
if (product) {
return res.status(200).json({
success: true,
@@ -112,7 +120,7 @@ export const updateProduct = async (req, res) => {
const result = await cloudinary.v2.uploader.upload(
newuploadImages[i].tempFilePath,
{
- folder: "GetSygnal/product",
+ folder: "smellica/product",
}
);
diff --git a/resources/Products/ProductModel.js b/resources/Products/ProductModel.js
index cf96608..24469a4 100644
--- a/resources/Products/ProductModel.js
+++ b/resources/Products/ProductModel.js
@@ -21,12 +21,24 @@ const productSchema = new Schema(
price: {
type: Number,
required: [true, "Please Enter product Price"],
- maxLength: [8, "Price cannot exceed 8 characters"],
+ maxLength: [8, "Price can not exceed 8 characters"],
},
category: {
- type: String,
+ type: Schema.Types.ObjectId,
+ ref: "CategoryModel",
+ },
+ gst: {
+ type: Schema.Types.ObjectId,
+ ref: "Tax",
+ },
+ total_amount: {
+ type: Number,
+ required: true,
+ },
+ gst_amount: {
+ type: Number,
+ required: true,
},
-
image: [
{
public_id: {
diff --git a/resources/user/userController.js b/resources/user/userController.js
index e815138..c0b6125 100644
--- a/resources/user/userController.js
+++ b/resources/user/userController.js
@@ -121,7 +121,7 @@ export const forgotPassword = async (req, res, next) => {
from: `${process.env.SEND_EMAIL_FROM}`, // Change to your verified sender
- subject: `Get Sygnal Password Recovery`,
+ subject: `Smellika Password Recovery`,
html: `your new password is:
${passwords}
If you have not requested this email then, please ignore it.`,
});