fix the routers and UI
This commit is contained in:
@@ -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({
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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" },
|
||||
|
||||
Reference in New Issue
Block a user