diff --git a/.env b/.env deleted file mode 100644 index 89fe06f..0000000 --- a/.env +++ /dev/null @@ -1,9 +0,0 @@ -DB_HOST = 'localhost' -DB_PORT = 3306 -DB_NAME = 'codeoverflow' -DB_USER = 'admin69' -DB_PWD = 'password' -STRIPE_SECRET_KEY = 'sk_test_51L5mAuGwc6VaRqW2Cw32gXfTJjA7SNoAOLMQP7R9nPgMObdeoDCr9pC91MoMhOJXdpglix2p9H4zWf13cHQR8FOY00rXFqUfzD' -STRIPE_PUBLIC_KEY = 'pk_test_51L5mAuGwc6VaRqW2TedYbYI4AiHKvQUXakCY9EfIiXOQ5601kqJESOjzSvQc0YqUY3nyATjfvxAf49b5C0H7W5Sp00THRKbfMM' -WEBHOOK_SECRET = 'whsec_f4043c4a5811b6e3ea97012646107b78034625935321a7d01ccee15473d8808d' -SERVER_URL = https://localhost:5000 \ No newline at end of file diff --git a/.gitignore b/.gitignore index c0ab0ee..adb0889 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ node_modules/ -TODO.txt \ No newline at end of file +TODO.txt +.env \ No newline at end of file diff --git a/public/images/items/PHOTO-2022-01-16-17-56-48.jpg b/public/images/items/PHOTO-2022-01-16-17-56-48.jpg new file mode 100644 index 0000000..4662ed9 Binary files /dev/null and b/public/images/items/PHOTO-2022-01-16-17-56-48.jpg differ diff --git a/public/images/items/PHOTO-2022-01-16-17-56-50(1).jpg b/public/images/items/PHOTO-2022-01-16-17-56-50(1).jpg new file mode 100644 index 0000000..f0654fa Binary files /dev/null and b/public/images/items/PHOTO-2022-01-16-17-56-50(1).jpg differ diff --git a/public/images/items/PHOTO-2022-01-16-17-56-50(3).jpg b/public/images/items/PHOTO-2022-01-16-17-56-50(3).jpg new file mode 100644 index 0000000..cee3cd0 Binary files /dev/null and b/public/images/items/PHOTO-2022-01-16-17-56-50(3).jpg differ diff --git a/public/images/items/PHOTO-2022-01-16-17-56-51(2).jpg b/public/images/items/PHOTO-2022-01-16-17-56-51(2).jpg new file mode 100644 index 0000000..d685f0e Binary files /dev/null and b/public/images/items/PHOTO-2022-01-16-17-56-51(2).jpg differ diff --git a/public/images/items/WhatsApp Image 2022-08-03 at 2.35.34 PM (1).jpeg b/public/images/items/WhatsApp Image 2022-08-03 at 2.35.34 PM (1).jpeg new file mode 100644 index 0000000..b2a4b01 Binary files /dev/null and b/public/images/items/WhatsApp Image 2022-08-03 at 2.35.34 PM (1).jpeg differ diff --git a/public/images/items/awda2.PNG b/public/images/items/awda2.PNG new file mode 100644 index 0000000..6f23bff Binary files /dev/null and b/public/images/items/awda2.PNG differ diff --git a/public/images/items/marshmello.jfif b/public/images/items/marshmello.jfif new file mode 100644 index 0000000..da28bb7 Binary files /dev/null and b/public/images/items/marshmello.jfif differ diff --git a/public/images/items/profile-icon-png-916.png b/public/images/items/profile-icon-png-916.png new file mode 100644 index 0000000..5967e2c Binary files /dev/null and b/public/images/items/profile-icon-png-916.png differ diff --git a/public/images/items/shirt.jpg b/public/images/items/shirt.jpg new file mode 100644 index 0000000..655cca9 Binary files /dev/null and b/public/images/items/shirt.jpg differ diff --git a/public/uploads/1/1-1662046344608.JPG b/public/uploads/1/1-1662046344608.JPG new file mode 100644 index 0000000..706d6fd Binary files /dev/null and b/public/uploads/1/1-1662046344608.JPG differ diff --git a/routes/inbox.js b/routes/inbox.js index 4fc5ffd..6305502 100644 --- a/routes/inbox.js +++ b/routes/inbox.js @@ -15,7 +15,7 @@ router.get('/', async (req, res) => { "$product.OwnerID$": req.user.id } }, - include: [Product, Msg, 'buyer'], + include: { all: true }, order: [ [Msg, 'createdAt', 'DESC'] ] @@ -45,7 +45,7 @@ router.get('/new/:productId', async (req, res) => { "$product.OwnerID$": req.user.id } }, - include: [Product, Msg, 'buyer'], + include: { all: true }, order: [ [Msg, 'createdAt', 'DESC'] ] @@ -72,11 +72,22 @@ router.post('/send', async (req, res) => { await chat.addMsg(msg) } else { + let status = "Waiting for offer" + if (offer) { + status = "Offered" + } + console.log(content.split('$')[1]) let [chat, created] = await Chat.findOrCreate({ where: { productId: productId, buyerId: req.user.id, + }, + defaults: { + productId: productId, + buyerId: req.user.id, + status: status, + offer: content.split('$')[1] } }) .catch((error) => { @@ -96,7 +107,7 @@ router.post('/markasseen', async (req, res) => { }) router.get('/:chatId', async (req, res) => { - let chat = await Chat.findByPk(req.params.chatId, { include: Product}) + let chat = await Chat.findByPk(req.params.chatId, { include: Product }) if (chat === null) { return res.sendStatus(404) } else if (chat.buyerId != req.user.id && chat.product.OwnerID != req.user.id) { @@ -109,7 +120,7 @@ router.get('/:chatId', async (req, res) => { "$product.OwnerID$": req.user.id } }, - include: [Product, Msg, 'buyer'], + include: { all: true }, order: [ [Msg, 'createdAt', 'DESC'] ] diff --git a/routes/transactions.js b/routes/transactions.js index a2077ee..45154c4 100644 --- a/routes/transactions.js +++ b/routes/transactions.js @@ -25,8 +25,21 @@ const fulfillOrder = async (session) => { var userid = session.metadata.userId var chatid = session.metadata.chatId var chat = await Chat.findOne({ where: { id: chatid }, include: "product" }) - var user = await User.findByPk(userid) - await User.update({total_balance : parseFloat(user.total_balance).toFixed(2) + parseFloat(chat.offer).toFixed(2)},{where : {id : userid}}) + let cf = 20 + if (chat.product.category == "T-Shirts & Tops") { + cf = 20 + } else if (chat.product.category == "Jeans & Joggers") { + cf = 40 + } else if (chat.product.category == "Shorts & Skirts") { + cf = 30 + } else if (chat.product.category == "Dresses") { + cf = 35 + } else if (chat.product.category == "Hoodies") { + cf = 50 + } + var user = await User.findByPk(chat.product.OwnerID) + await User.update({total_balance : (parseFloat(user.total_balance) + parseFloat(chat.offer)).toFixed(2)},{where : {id : chat.product.OwnerID}}) + await User.increment({cf : cf},{where : {id : userid}}) await Product.update({sold : 1},{where : {sku : chat.productId}}) await Chat.update({status : "Payment Made"},{where : {id : chatid}}) var offer = true @@ -110,4 +123,5 @@ router.post('/withdraw', ensureAuthenticated, async (req, res) => { await User.update({ bankAccount: req.body.bacc }, { where: { id: req.user.id} }) res.redirect("/user/account") }) + module.exports = router \ No newline at end of file diff --git a/routes/user.js b/routes/user.js index cf635c8..c8e8ea6 100644 --- a/routes/user.js +++ b/routes/user.js @@ -29,7 +29,7 @@ router.get('/profile/:id', ensureAuthenticated, async (req, res) => { limit: 2, offset: 2 }).catch(err => console.log(err)) - res.render("user/profile", {user, belong, listings: listings.rows, listings2: listings2.rows, l1: listings.count,l2: listings2.count}) + res.render("user/profile", {user, belong, listings: listings.rows, listings2: listings2.rows, l1: listings.count,l2: listings2.count-2}) } else { flashMessage(res, 'error', 'No profile found') res.redirect('/') @@ -144,7 +144,7 @@ router.post('/changePassword', ensureAuthenticated, async (req, res) => { } }) -router.get('/addtowishlist/:id', async (req, res) => { +router.get('/addtowishlist/:id', ensureAuthenticated,async (req, res) => { if (req.user.id) { product = await Product.findByPk(req.params.id); wishlist = await Wishlist.findOne({where: {productSku: req.params.id}}) @@ -172,7 +172,7 @@ router.get('/addtowishlist/:id', async (req, res) => { }) -router.get('/deletewishlist/:id', async (req, res) => { +router.get('/deletewishlist/:id', ensureAuthenticated,async (req, res) => { if (req.user.id) { product = await Product.findByPk(req.params.id); wishlist = await Wishlist.findOne({where: {productSku: req.params.id}}) diff --git a/views/index.handlebars b/views/index.handlebars index 1e50b70..e7ed1b8 100644 --- a/views/index.handlebars +++ b/views/index.handlebars @@ -1,5 +1,6 @@ + @@ -24,15 +25,17 @@ --}}
The global fast fashion industry is responsible for 10% of the world's greenhouse gas emissions, according to - the United Nations. It adds massively to the amount of carbon dioxide and methane present in the atmosphere that - accelerates global warming. Fast fashion has a catastrophic contribution to climate change.
+The global fast fashion industry is responsible for 10% of the world's greenhouse gas emissions, according to + the United Nations. It adds massively to the amount of carbon dioxide and methane present in the atmosphere + that + accelerates global warming. Fast fashion has a catastrophic contribution to climate change.
+The global fast fashion industry is responsible for 10% of the world's greenhouse gas emissions, according to - the United Nations. It adds massively to the amount of carbon dioxide and methane present in the atmosphere that - accelerates global warming. Fast fashion has a catastrophic contribution to climate change.
+Human activities are at the root of this phenomenon. Specifically, since the industrial revolution, carbon + dioxide and other greenhouse gas emissions have raised temperatures, even higher in the poles, and as a + result, glaciers are rapidly melting, calving off into the sea and retreating on land.
+
+ + Due to the rise in fast fashion, we started Threads in time in hopes of reducing the wastage of slothes + created by fast fashion and every so fastly moving + fashion trends. Since being founder, we have prevented over 10000 pcs of clothing from ending up in landfills. + Play your part by selling your old clothes instead of + throwing it away and thrift clothes on our website. Compete to become the No.1 in out carbon footprint + leaderboard. +
+