Connect Orders database table with Payments and Addresses, visualize it in the frontend

This commit is contained in:
2024-09-24 23:41:35 +02:00
parent e00107ab6a
commit cbd01f6d59
19 changed files with 517 additions and 223 deletions

View File

@@ -4,7 +4,8 @@ import { Product } from "../models/product.model";
import { OrderItem } from "../models/orderItem.model";
import { Brand } from "../models/brand.model";
import { Category } from "../models/category.model";
import { Sequelize } from "sequelize-typescript";
import { Payment } from "../models/payment.model";
import { Address } from "../models/address.model";
export const order = Router()
@@ -27,7 +28,9 @@ order.get("/:id", (req: Request, res: Response) => {
}
},
]
}
},
Payment,
Address
]
})
.then(orders => {
@@ -49,7 +52,10 @@ order.post("/", (req: Request, res: Response) => {
Product.decrement(
"inStock",
{ where: { id: orderItem.productId } }
{
by: orderItem.quantity,
where: { id: orderItem.productId }
}
)
}