From 505f6cd134ec4bb4ad4dae5014bfe93c9cd7f12d Mon Sep 17 00:00:00 2001 From: Mann Patel <130435633+MannPatel0@users.noreply.github.com> Date: Mon, 21 Apr 2025 01:19:39 -0600 Subject: [PATCH] updating alerts ui/ux --- backend/routes/transaction.js | 2 ++ backend/utils/database.js | 1 - frontend/src/pages/ProductDetail.jsx | 15 +++++++++------ mysql-code/Schema.sql | 2 +- 4 files changed, 12 insertions(+), 8 deletions(-) diff --git a/backend/routes/transaction.js b/backend/routes/transaction.js index c29611e..30d4453 100644 --- a/backend/routes/transaction.js +++ b/backend/routes/transaction.js @@ -7,6 +7,8 @@ const { getAllTransactions, updatePaymentStatus, deleteTransaction, + getTransactionWithPagination, + removeTransation, } = require("../controllers/transaction"); const router = express.Router(); diff --git a/backend/utils/database.js b/backend/utils/database.js index 7e9a4c9..379d5df 100644 --- a/backend/utils/database.js +++ b/backend/utils/database.js @@ -4,7 +4,6 @@ const pool = mysql.createPool({ host: "localhost", user: "root", database: "Marketplace", - password: "12345678" }); // const pool = mysql.createPool( diff --git a/frontend/src/pages/ProductDetail.jsx b/frontend/src/pages/ProductDetail.jsx index e5b1143..c3d892d 100644 --- a/frontend/src/pages/ProductDetail.jsx +++ b/frontend/src/pages/ProductDetail.jsx @@ -30,6 +30,8 @@ const ProductDetail = () => { const [reviews, setReviews] = useState([]); const [showReviewForm, setShowReviewForm] = useState(false); const [showAlert, setShowAlert] = useState(false); + const [showAlert1, setShowAlert1] = useState(false); + const storedUser = JSON.parse(sessionStorage.getItem("user")); const toggleFavorite = async (id) => { @@ -303,6 +305,12 @@ const ProductDetail = () => { onClose={() => setShowAlert(false)} /> )} + {showAlert1 && ( + setShowAlert1(false)} + /> + )}
@@ -438,13 +446,8 @@ const ProductDetail = () => { const result = await response.json(); if (result.success) { - alert("Transaction created successfully!"); - } else { - throw new Error( - result.message || "Failed to create transaction", - ); + setShowAlert1(true); } - // Toggle contact options visibility setShowContactOptions(!showContactOptions); } catch (error) { diff --git a/mysql-code/Schema.sql b/mysql-code/Schema.sql index e65a325..cc8b772 100644 --- a/mysql-code/Schema.sql +++ b/mysql-code/Schema.sql @@ -79,7 +79,7 @@ CREATE TABLE Review ( -- Transaction Entity (Many-to-One with User, Many-to-One with Product) CREATE TABLE Transaction ( - TransactionID INT PRIMARY KEY, + TransactionID INT AUTO_INCREMENT PRIMARY KEY, UserID INT, ProductID INT, Date DATETIME DEFAULT CURRENT_TIMESTAMP,