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 { try {
const [transactions] = await db.execute( const [transactions] = await db.execute(
`SELECT `SELECT
TransactionID, T.TransactionID,
UserID, T.UserID,
ProductID, T.ProductID,
Date, T.Date,
PaymentStatus T.PaymentStatus,
FROM Transaction` 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({ res.json({

View File

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

View File

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