Add selection conflict info component and handle seat conflicts
Introduces SelectionConflictInfoComponent to display seat selection conflicts when a seat is removed due to external booking. Removes ShoppingCartComponent and its references. Updates SelectedSeatsService to track conflict state and modifies TheaterOverlayComponent to detect and handle seat conflicts, updating the UI accordingly.
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import { computed, Injectable, signal } from '@angular/core';
|
||||
import {Sitzplatz} from '@infinimotion/model-frontend';
|
||||
import { Sitzplatz } from '@infinimotion/model-frontend';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root',
|
||||
@@ -10,21 +10,25 @@ export class SelectedSeatsService {
|
||||
private seatIsSelectableSignal = signal(true);
|
||||
private committedSignal = signal(false);
|
||||
private debugSignal = signal(false);
|
||||
private hadConflictSignal = signal(false);
|
||||
|
||||
readonly selectedSeats = this.selectedSeatsSignal.asReadonly();
|
||||
readonly seatIsSelectable = this.seatIsSelectableSignal.asReadonly();
|
||||
readonly committed = this.committedSignal.asReadonly();
|
||||
readonly debug = this.debugSignal.asReadonly();
|
||||
readonly hadConflict = this.hadConflictSignal.asReadonly();
|
||||
|
||||
readonly totalSeats = computed(() => this.selectedSeats().length);
|
||||
readonly totalPrice = computed(() => this.selectedSeats().reduce((sum, seat) => sum + seat.row.category.price, 0));
|
||||
|
||||
pushSelectedSeat(selectedSeat: Sitzplatz): void {
|
||||
this.selectedSeatsSignal.update(seats => [...seats, selectedSeat]);
|
||||
this.setConflict(false);
|
||||
}
|
||||
|
||||
removeSelectedSeat(selectedSeat: Sitzplatz): void {
|
||||
this.selectedSeatsSignal.update(seats => seats.filter(seat => seat.id !== selectedSeat.id));
|
||||
this.setConflict(false);
|
||||
}
|
||||
|
||||
getSeatsByCategory(categoryId: number): Sitzplatz[] {
|
||||
@@ -58,4 +62,8 @@ export class SelectedSeatsService {
|
||||
isSeatSelected(seatId: number): boolean {
|
||||
return this.selectedSeats().some(seat => seat.id === seatId);
|
||||
}
|
||||
|
||||
setConflict(value: boolean): void {
|
||||
this.hadConflictSignal.set(value);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user