From 40161a136a7d4921fa25ac11a4e35a98df624ba5 Mon Sep 17 00:00:00 2001 From: Tobias Zoghaib Date: Mon, 21 Oct 2024 14:57:03 +0200 Subject: [PATCH] Fix order process --- misc/database.drawio | 229 +++++++++--------- software/backend/routes/order.routes.ts | 15 +- .../src/components/basics/actionDialog.vue | 8 +- software/src/components/basics/cardView.vue | 8 +- .../navigation/navigationAppendItems.vue | 4 +- .../components/seatPlanMap/seatGroupTable.vue | 2 +- .../components/seatPlanMap/standingArea.vue | 2 +- software/src/data/api/orderApi.ts | 26 +- .../data/models/ordering/basketItemModel.ts | 6 +- software/src/locales/de.json | 3 +- software/src/locales/en.json | 3 +- .../concerts/concertBookingPage/index.vue | 2 +- software/src/pages/misc/basketPage/index.vue | 6 +- .../pages/misc/basketPage/orderingDialog.vue | 32 +-- .../pages/misc/basketPage/ticketsTable.vue | 10 +- software/src/stores/account.store.ts | 2 +- .../{basketStore.ts => basket.store.ts} | 67 +++-- 17 files changed, 212 insertions(+), 213 deletions(-) rename software/src/stores/{basketStore.ts => basket.store.ts} (62%) diff --git a/misc/database.drawio b/misc/database.drawio index d713698..ac00c45 100644 --- a/misc/database.drawio +++ b/misc/database.drawio @@ -1,20 +1,20 @@ - + - + - + - + - + @@ -23,43 +23,43 @@ - + - + - + - + - + - + - + - + - + - + - + - + @@ -67,13 +67,13 @@ - + - - + + @@ -108,51 +108,51 @@ - + - + - + - + - + - + - + - + - + - + - + - + - - + + @@ -167,7 +167,7 @@ - + @@ -185,22 +185,22 @@ - + - + - + - + - + @@ -223,13 +223,13 @@ - + - + @@ -244,16 +244,16 @@ - + - + - + - + @@ -262,52 +262,52 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -316,7 +316,7 @@ - + @@ -376,7 +376,7 @@ - + @@ -416,8 +416,8 @@ - - + + @@ -439,7 +439,7 @@ - + @@ -448,17 +448,17 @@ - + - + - + @@ -478,7 +478,7 @@ - + @@ -526,13 +526,13 @@ - + - + - + @@ -552,7 +552,7 @@ - + @@ -578,22 +578,22 @@ - + - + - + - + - + - + @@ -606,8 +606,8 @@ - - + + @@ -622,48 +622,48 @@ - + - + - + - + - + - + - + - + - + - + - - + + - + @@ -676,8 +676,7 @@ - - + @@ -688,31 +687,31 @@ - + - + - + - + - - + + - + @@ -721,21 +720,21 @@ - + - + - + - - + + @@ -750,13 +749,13 @@ - + - + - + @@ -768,10 +767,10 @@ - + - + @@ -836,10 +835,10 @@ - + - + diff --git a/software/backend/routes/order.routes.ts b/software/backend/routes/order.routes.ts index dbc2462..62b1a93 100644 --- a/software/backend/routes/order.routes.ts +++ b/software/backend/routes/order.routes.ts @@ -61,21 +61,22 @@ order.get("/:id", (req: Request, res: Response) => { // Place a new order order.post("/", (req: Request, res: Response) => { + console.log(req.body.tickets) Order.create(req.body) .then(async order => { - for (let orderItem of req.body.orderItems) { + for (let ticket of req.body.tickets) { Ticket.create({ - orderId: order.id, - quantity: orderItem.quantity, - orderPrice: orderItem.orderPrice, - productId: orderItem.productId + orderId: order.dataValues.id, + concertId: ticket.concertId, + orderPrice: ticket.orderPrice, + seatId: ticket.seatId }) Concert.decrement( "inStock", { - by: orderItem.quantity, - where: { id: orderItem.productId } + by: 1, + where: { id: ticket.concertId } } ) } diff --git a/software/src/components/basics/actionDialog.vue b/software/src/components/basics/actionDialog.vue index d607cfa..98e48df 100644 --- a/software/src/components/basics/actionDialog.vue +++ b/software/src/components/basics/actionDialog.vue @@ -1,5 +1,6 @@