diff --git a/src/app/order/order.component.html b/src/app/order/order.component.html index 951bfdc..4ee64b6 100644 --- a/src/app/order/order.component.html +++ b/src/app/order/order.component.html @@ -41,13 +41,13 @@ Tickets gesamt:

- 75,00 € + {{ getPriceDisplay(totalPrice()) }}

- - + +
diff --git a/src/app/order/order.component.ts b/src/app/order/order.component.ts index 3f3b094..5e66746 100644 --- a/src/app/order/order.component.ts +++ b/src/app/order/order.component.ts @@ -1,6 +1,7 @@ +import { SelectedSeatsService } from './../selected-seats.service'; import { LoadingService } from './../loading.service'; import { Sitzkategorie, Vorstellung } from '@infinimotion/model-frontend'; -import { Component, inject, input } from '@angular/core'; +import { Component, computed, inject, input } from '@angular/core'; import { FormBuilder, Validators } from '@angular/forms'; @Component({ @@ -15,6 +16,7 @@ export class OrderComponent { private _formBuilder = inject(FormBuilder); loadingService = inject(LoadingService); + private selectedSeatsService = inject(SelectedSeatsService); firstFormGroup = this._formBuilder.group({ firstCtrl: ['', Validators.required], @@ -22,4 +24,12 @@ export class OrderComponent { secondFormGroup = this._formBuilder.group({ secondCtrl: ['', Validators.required], }); + + totalPrice = computed(() => + this.selectedSeatsService.getSelectedSeatsList().reduce((sum, seat) => sum + seat.row.category.price, 0) + ); + + getPriceDisplay(price: number): string { + return `${(price / 100).toFixed(2)} €`; + } } diff --git a/src/app/seat-selection/seat-selection.component.html b/src/app/seat-selection/seat-selection.component.html index 0531616..53562eb 100644 --- a/src/app/seat-selection/seat-selection.component.html +++ b/src/app/seat-selection/seat-selection.component.html @@ -6,6 +6,6 @@

{{ getPriceDisplay(seatCategory().price) }}

-

× {{selectedSeatsByCategory()}}

-

{{ getPriceDisplay(totalPrice())}}

+

× {{ selectedSeatsByCategory() }}

+

{{ getPriceDisplay(totalCategoryPrice()) }}

diff --git a/src/app/seat-selection/seat-selection.component.ts b/src/app/seat-selection/seat-selection.component.ts index 07d4307..9c5ca14 100644 --- a/src/app/seat-selection/seat-selection.component.ts +++ b/src/app/seat-selection/seat-selection.component.ts @@ -17,7 +17,7 @@ export class SeatSelectionComponent { this.SelectedSeatsService.getSelectedSeatsByCategory(this.seatCategory().id).length ); - totalPrice = computed(() => + totalCategoryPrice = computed(() => this.selectedSeatsByCategory() * this.seatCategory().price );