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/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/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/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. +
+