Updated seat-selection component to show the actual number of selected seats and calculate the total price per seat category. Integrated SelectedSeatsService and replaced hardcoded values with computed properties for better accuracy and maintainability.
28 lines
841 B
TypeScript
28 lines
841 B
TypeScript
import { SelectedSeatsService } from './../selected-seats.service';
|
|
import { Component, computed, inject, input } from '@angular/core';
|
|
import { Sitzkategorie } from '@infinimotion/model-frontend';
|
|
|
|
@Component({
|
|
selector: 'app-seat-selection',
|
|
standalone: false,
|
|
templateUrl: './seat-selection.component.html',
|
|
styleUrl: './seat-selection.component.css'
|
|
})
|
|
export class SeatSelectionComponent {
|
|
seatCategory = input.required<Sitzkategorie>();
|
|
|
|
SelectedSeatsService = inject(SelectedSeatsService);
|
|
|
|
selectedSeatsByCategory = computed(() =>
|
|
this.SelectedSeatsService.getSelectedSeatsByCategory(this.seatCategory().id).length
|
|
);
|
|
|
|
totalPrice = computed(() =>
|
|
this.selectedSeatsByCategory() * this.seatCategory().price
|
|
);
|
|
|
|
getPriceDisplay(price: number): string {
|
|
return `${(price / 100).toFixed(2)} €`;
|
|
}
|
|
}
|