Skip to content

Commit

Permalink
mongodb connection string updated and offer percentage listed on prod…
Browse files Browse the repository at this point in the history
…uct details page
  • Loading branch information
navneethvi committed Jan 31, 2024
1 parent ba8d90f commit 570b087
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 5 deletions.
13 changes: 11 additions & 2 deletions DB/dataBase.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,16 @@
const Mongoose = require("mongoose")

const connectDB = Mongoose.connect("mongodb://127.0.0.1:27017/LapLux")
const connectDB = Mongoose.connect('mongodb://navaneeth-v:navaneethUNNI@ac-9rix4yo-shard-00-00.g0ss5bb.mongodb.net:27017,ac-9rix4yo-shard-00-01.g0ss5bb.mongodb.net:27017,ac-9rix4yo-shard-00-02.g0ss5bb.mongodb.net:27017/LapLux?ssl=true&replicaSet=atlas-10l1hg-shard-0&authSource=admin&retryWrites=true&w=majority')

connectDB
.then(()=>console.log("Database Connected"))
.catch((err)=>console.log(err.message))
.catch((err)=>console.log(err.message))








// "mongodb+srv://navaneeth-v:navaneethUNNI@cluster-1.g0ss5bb.mongodb.net/LapLux?retryWrites=true&w=majority"
10 changes: 8 additions & 2 deletions controllers/userController.js
Original file line number Diff line number Diff line change
Expand Up @@ -302,11 +302,17 @@ const getProductDetailsPage = async (req, res) => {
const id = req.query.id
console.log(id);
const findProduct = await Product.findOne({ id: id });
const findCategory = await Category.findOne({name : findProduct.category})
// console.log(findCategory);
let totalOffer
if(findCategory.categoryOffer || findProduct.productOffer){
totalOffer = findCategory.categoryOffer + findProduct.productOffer
}
console.log(findProduct.id, "Hello world");
if (user) {
res.render("product-details", { data: findProduct, user: user })
res.render("product-details", { data: findProduct, totalOffer, user: user })
} else {
res.render("product-details", { data: findProduct })
res.render("product-details", { data: findProduct, totalOffer })
}
} catch (error) {
console.log(error.message);
Expand Down
8 changes: 7 additions & 1 deletion views/user/product-details.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,13 @@
</span></ins>
<ins><span class="old-price font-md ml-15">₹<%=
data.regularPrice.toLocaleString('en-IN') %></span></ins>
<span class="save-price font-md color3 ml-15">25% Off</span>
<span class="save-price font-md color3 ml-15">
<% if (!totalOffer) { %>
No Offers
<% }else{ %>
<%= totalOffer %>% Offer
<% } %>
</span>
</div>
</div>
<div class="bt-1 border-color-1 mt-15 mb-15"></div>
Expand Down

0 comments on commit 570b087

Please sign in to comment.