http service tests

This commit is contained in:
2025-10-24 01:30:39 +02:00
parent 10d004ded8
commit 21722cef59
4 changed files with 85 additions and 15 deletions

View File

@@ -1,3 +1,24 @@
<p>Diese Komponente später löschen, nur ein Proof Of Concept für die Modellverwendung!</p>
<p>{{ ticket.id }}</p>
<p>{{ ticket.code }}</p>
<div>
<h2>Kinosaal Übersicht</h2>
<ul>
@for (kinosaal of kinosaele; track kinosaal.id) {
<li>
{{ kinosaal.id }} - {{ kinosaal.name }}
</li>
} @empty {
<li>
Keine Kinosäle vorhanden.
</li>
}
</ul>
<div>
<input
type="text"
placeholder="Neuer Kinosaal Name"
[(ngModel)]="newKinosaalName"
/>
<button (click)="addKinosaal()">Hinzufügen</button>
</div>
</div>

View File

@@ -1,5 +1,6 @@
import { Component } from '@angular/core';
import { Eintrittskarte, Kinosaal, Vorstellung } from '@infinimotion/model-frontend';
import { Component, inject, OnInit } from '@angular/core';
import { Kinosaal } from '@infinimotion/model-frontend';
import { HttpService } from '../http.service';
@Component({
selector: 'app-poc-model-component',
@@ -7,12 +8,34 @@ import { Eintrittskarte, Kinosaal, Vorstellung } from '@infinimotion/model-front
templateUrl: './poc-model-component.html',
styleUrl: './poc-model-component.css',
})
export class PocModelComponent {
ticket: Eintrittskarte = {
id: 12345,
code: 'ABCDEF',
show: undefined as any,
seat: undefined as any,
state: undefined as any,
};
export class PocModelComponent implements OnInit {
private http = inject(HttpService);
kinosaele: Kinosaal[] = [];
newKinosaalName = '';
ngOnInit(): void {
this.loadKinosaele();
}
loadKinosaele() {
this.http.getAllKinosaal().subscribe({
next: (data) => (this.kinosaele = Array.isArray(data) ? data : [data]),
error: (err) => console.error('Fehler beim Laden der Kinosaele', err),
});
}
addKinosaal() {
if (!this.newKinosaalName.trim()) return;
const kinosaalToAdd: Omit<Kinosaal, 'id'> = { name: this.newKinosaalName };
this.http.addKinosaal(kinosaalToAdd).subscribe({
next: (added) => {
this.kinosaele.push(added);
this.newKinosaalName = '';
},
error: (err) => console.error('Fehler beim Hinzufügen', err),
});
}
}