Skip to content

Commit 04cbbfd

Browse files
committed
Display title on booking form
1 parent 0a1891b commit 04cbbfd

File tree

4 files changed

+17
-2
lines changed

4 files changed

+17
-2
lines changed

projects/train-platform/src/assets/i18n/de.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
}
1414
},
1515
"booking": {
16+
"title": "Reise {{ id }} buchen",
1617
"reserveSeatQuestion": "Möchten Sie einen Sitzplatz reservieren?",
1718
"firstClassQuestion": "Möchten Sie in der ersten Klasse sitzen?",
1819
"bookAction": "Buchen",

projects/train-platform/src/assets/i18n/en.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
}
1414
},
1515
"booking": {
16+
"title": "Book journey {{ id }}",
1617
"reserveSeatQuestion": "Do you want to reserve a seat?",
1718
"firstClassQuestion": "Do you want to sit in first class?",
1819
"bookAction": "Book",

projects/train-platform/src/booking/booking/booking.component.html

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
<h2 *ngIf="journeyId$ | async as journeyId">
2+
{{ "booking.title" | translate: { id: journeyId } }}
3+
</h2>
14
<div class="booking-options">
25
<div>
36
<label>{{ "booking.reserveSeatQuestion" | translate }}</label>

projects/train-platform/src/booking/booking/booking.component.ts

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,20 @@
1-
import { Component } from '@angular/core';
1+
import { Component, OnInit } from '@angular/core';
22
import { ActivatedRoute } from '@angular/router';
33
import { HotToastService } from '@ngneat/hot-toast';
44
import { TranslateService } from '@ngx-translate/core';
5+
import { Observable } from 'rxjs';
6+
import { filter, map } from 'rxjs/operators';
57
import { BookingService } from '../booking.service';
68

79
@Component({
810
selector: 'app-booking',
911
templateUrl: './booking.component.html',
1012
styleUrls: ['./booking.component.css'],
1113
})
12-
export class BookingComponent {
14+
export class BookingComponent implements OnInit {
1315
reserveSeat = false;
1416
firstClass = false;
17+
journeyId$!: Observable<string>;
1518

1619
constructor(
1720
private bookingService: BookingService,
@@ -20,6 +23,13 @@ export class BookingComponent {
2023
private translateService: TranslateService
2124
) {}
2225

26+
ngOnInit(): void {
27+
this.journeyId$ = this.route.params.pipe(
28+
map((params) => params.journeyId),
29+
filter((journeyId) => journeyId)
30+
);
31+
}
32+
2333
book(): void {
2434
this.bookingService
2535
.book(this.route.snapshot.params.journeyId, {

0 commit comments

Comments
 (0)