From 25f2c3d8af8dda75244651a705ce40d82c69d6b8 Mon Sep 17 00:00:00 2001 From: noahnghg <157671712+noahnghg@users.noreply.github.com> Date: Sun, 20 Apr 2025 21:18:43 -0600 Subject: [PATCH] adding stuff to the onClick --- backend/controllers/transaction.js | 3 ++- backend/utils/database.js | 1 + backend/utils/helper.js | 2 +- frontend/src/pages/ProductDetail.jsx | 34 +++++++++++++++++++++++++++- mysql-code/Schema.sql | 3 ++- 5 files changed, 39 insertions(+), 4 deletions(-) diff --git a/backend/controllers/transaction.js b/backend/controllers/transaction.js index 6072d2f..22c17b3 100644 --- a/backend/controllers/transaction.js +++ b/backend/controllers/transaction.js @@ -7,10 +7,11 @@ exports.createTransaction = async (req, res) => { const { userID, productID, date, paymentStatus } = req.body; try { + const formattedDate = new Date(date).toISOString().slice(0, 19).replace("T", " "); const [result] = await db.execute( `INSERT INTO Transaction (UserID, ProductID, Date, PaymentStatus) VALUES (?, ?, ?, ?)`, - [userID, productID, date, paymentStatus] + [userID, productID, formattedDate, paymentStatus] ); res.json({ diff --git a/backend/utils/database.js b/backend/utils/database.js index 6e75c3a..4459545 100644 --- a/backend/utils/database.js +++ b/backend/utils/database.js @@ -4,6 +4,7 @@ const pool = mysql.createPool({ host: "localhost", user: "root", database: "Marketplace", + password: "12345678" }); module.exports = pool.promise(); diff --git a/backend/utils/helper.js b/backend/utils/helper.js index 406a897..1d39b48 100644 --- a/backend/utils/helper.js +++ b/backend/utils/helper.js @@ -18,7 +18,7 @@ async function sendVerificationEmail(email, verificationCode) { // Clean up expired verification codes (run this periodically) function cleanupExpiredCodes() { - db_con.query( + db.query( "DELETE FROM AuthVerification WHERE Date < DATE_SUB(NOW(), INTERVAL 15 MINUTE) AND Authenticated = 0", (err, result) => { if (err) { diff --git a/frontend/src/pages/ProductDetail.jsx b/frontend/src/pages/ProductDetail.jsx index a5f0d73..4bae56e 100644 --- a/frontend/src/pages/ProductDetail.jsx +++ b/frontend/src/pages/ProductDetail.jsx @@ -417,7 +417,39 @@ const ProductDetail = () => {