fix the routers and UI

This commit is contained in:
noahnghg
2025-04-20 23:36:58 -06:00
parent eff9d9d91b
commit 46bd77025f
3 changed files with 13 additions and 8 deletions

View File

@@ -91,12 +91,17 @@ exports.getAllTransactions = async (req, res) => {
try {
const [transactions] = await db.execute(
`SELECT
TransactionID,
UserID,
ProductID,
Date,
PaymentStatus
FROM Transaction`
T.TransactionID,
T.UserID,
T.ProductID,
T.Date,
T.PaymentStatus,
P.Name AS ProductName,
MIN(I.URL) AS Image_URL
FROM Transaction T
JOIN Product P ON T.ProductID = P.ProductID
LEFT JOIN Image_URL I ON P.ProductID = I.ProductID
GROUP BY T.TransactionID, T.UserID, T.ProductID, T.Date, T.PaymentStatus, P.Name`
);
res.json({

View File

@@ -19,7 +19,7 @@ router.get("/getTransactionsByProduct/:productID", txCtrl.getTransactionsByProdu
router.post("/getTransactionsByUser", txCtrl.getTransactionsByUser);
// Get all transactions in the system
router.get("/getAllTransactions", txCtrl.getAllTransactions);
router.post("/getAllTransactions", txCtrl.getAllTransactions);
// Update payment status on a transaction
router.patch("/updatePaymentStatus", txCtrl.updatePaymentStatus);

View File

@@ -9,7 +9,7 @@ const Transactions = () => {
const fetchTransactions = async () => {
try {
const response = await fetch(
"http://localhost:3030/api/transaction/getTransactionsByUser",
"http://localhost:3030/api/transaction/getAllTransactions",
{
method: "POST",
headers: { "Content-Type": "application/json" },