upsi dupsi, da sind noch die componenten 🤡

This commit is contained in:
Marcel-Anker
2025-11-02 18:42:40 +01:00
parent c2d5868dba
commit 5cf71a43ed
13 changed files with 137 additions and 0 deletions

View File

@@ -0,0 +1,5 @@
export enum TheaterSeatState {
AVAILABLE,
RESERVED,
BOOKED,
}

View File

@@ -0,0 +1 @@

View File

@@ -0,0 +1,3 @@
@for (entry of rowSeatList(); track $index) {
<app-seat class="my-1" [seatState]="entry.state" [seatCategory]="entry.seat.row.category"></app-seat>
}

View File

@@ -0,0 +1,14 @@
import {Component, input} from '@angular/core';
import {Sitzplatz} from '@infinimotion/model-frontend';
import {TheaterSeatState} from '../model/theater-seat-state.model';
@Component({
selector: 'app-seat-row',
standalone: false,
templateUrl: './seat-row.component.html',
styleUrl: './seat-row.component.css'
})
export class SeatRowComponent {
rowSeatList = input.required<{ seat: Sitzplatz, state: TheaterSeatState }[]>();
}

View File

View File

@@ -0,0 +1,15 @@
<button class="mx-1 hover:opacity-50">
<mat-icon style="font-size: 30px; width: 30px; height: 30px">
@if(seatCategory().id ==1){
event_seat
}
@if(seatCategory().id == 2){
weekend
}
@if(seatCategory().id == 3){
chair
}
</mat-icon>
</button>

View File

@@ -0,0 +1,14 @@
import {Component, input} from '@angular/core';
import {TheaterSeatState} from '../model/theater-seat-state.model';
import {Sitzkategorie} from '@infinimotion/model-frontend';
@Component({
selector: 'app-seat',
standalone: false,
templateUrl: './seat.component.html',
styleUrl: './seat.component.css'
})
export class SeatComponent {
seatState = input.required<TheaterSeatState>();
seatCategory = input.required<Sitzkategorie>();
}

View File

@@ -0,0 +1,3 @@
@for (row of seatsPerRow(); track $index) {
<app-seat-row class="flex justify-center" [rowSeatList]="row"></app-seat-row>
}

View File

@@ -0,0 +1,13 @@
import {Component, input} from '@angular/core';
import {Sitzplatz} from '@infinimotion/model-frontend';
import {TheaterSeatState} from '../model/theater-seat-state.model';
@Component({
selector: 'app-theater-layout',
standalone: false,
templateUrl: './theater-layout.component.html',
styleUrl: './theater-layout.component.css'
})
export class TheaterLayoutComponent {
seatsPerRow = input.required<{ seat: Sitzplatz, state: TheaterSeatState }[][]>();
}

View File

@@ -0,0 +1,9 @@
<div class="m-auto w-200 h-10 bg-gray-300 mb-20" style="clip-path: polygon(0% 0%,100% 0%,90% 100%,10% 100%);">
<p class="flex justify-center text-2xl fond-bold p-1">
Leinwand
</p>
</div>
<div class="">
<app-theater-layout [seatsPerRow]="seatsPerRow"></app-theater-layout>
</div>

View File

@@ -0,0 +1,60 @@
import {Component, inject, input, OnInit} from '@angular/core';
import {HttpService} from '../http.service';
import {LoadingService} from '../loading.service';
import {catchError, of, tap} from 'rxjs';
import {Sitzplatz} from '@infinimotion/model-frontend';
import {TheaterSeatState} from '../model/theater-seat-state.model';
@Component({
selector: 'app-theater-overlay',
standalone: false,
templateUrl: './theater-overlay.component.html',
styleUrl: './theater-overlay.component.css'
})
export class TheaterOverlayComponent implements OnInit {
private http = inject(HttpService);
private loading = inject(LoadingService)
show = input.required<number>();
seatsPerRow: { seat: Sitzplatz, state: TheaterSeatState }[][] = []
ngOnInit() {
this.loadShowSeats();
}
loadShowSeats() {
this.loading.show();
this.http.getSeatsByShowId(2).pipe(
tap((data) => {
let rows = this.converter(data)
this.loading.hide();
this.seatsPerRow = rows
console.log(rows)
}),
catchError(err => {
this.loading.showError(err);
console.error('Fehler beim Laden der Vorstellung', err);
return of([]);
})
).subscribe();
}
converter(resp: { seats: Sitzplatz[], reserved: Sitzplatz[], booked: Sitzplatz[] }): {
seat: Sitzplatz,
state: TheaterSeatState
}[][] {
let rows: { seat: Sitzplatz, state: TheaterSeatState }[][] = [];
resp.seats.forEach(seat => {
if (!rows[seat.row.position]) {
rows[seat.row.position] = [];
}
let state = resp.booked.find(other => other.id == seat.id) ? TheaterSeatState.BOOKED : resp.booked.find(other => other.id == seat.id) ? TheaterSeatState.RESERVED : TheaterSeatState.AVAILABLE;
rows[seat.row.position].push({seat: seat, state: state});
});
rows = rows.filter(row => row.length > 0).sort((a, b) => a[0].seat.row.position - b[0].seat.row.position);
rows.forEach(row => row.sort((a, b) => a.seat.position - b.seat.position));
return rows;
}
}