diff --git a/app/src/app/components/reservations-chart/reservations-chart.component.ts b/app/src/app/components/reservations-chart/reservations-chart.component.ts index 39a2a5c..b454cc3 100644 --- a/app/src/app/components/reservations-chart/reservations-chart.component.ts +++ b/app/src/app/components/reservations-chart/reservations-chart.component.ts @@ -11,6 +11,9 @@ import {OccupationService} from '../../services/occupation/occupation.service'; import {RefugeReservationService} from "../../services/reservations/refuge-reservation.service"; import {WeekReservations} from "../../schemas/reservations/reservation"; import {toShortString} from "../../schemas/night/night"; +import {TranslateService} from "@ngx-translate/core"; +import {AlertController} from "@ionic/angular"; +import {Router} from "@angular/router"; @Component({ selector: 'app-reservations-chart', @@ -40,7 +43,7 @@ export class ReservationsChartComponent implements OnInit { }; xAxisTickFormatting = (value: string) => { if (value === this.today) { - return 'Today'; + return this.translateService.instant('REFUGE.OCCUPATION.TODAY'); } return value; }; @@ -49,6 +52,9 @@ export class ReservationsChartComponent implements OnInit { private changeDetectorRef: ChangeDetectorRef, private occupationService: OccupationService, private reservationService: RefugeReservationService, + private translateService: TranslateService, + private alertController: AlertController, + private router: Router, ) { } @@ -80,12 +86,28 @@ export class ReservationsChartComponent implements OnInit { this.formatChartReservations(); console.log(this.formattedChartReservations) }, - error: (err) => { - console.log("error" + err); - } + error: () => this.handleClientError().then(), }); } + private async handleClientError() { + const alert = await this.alertController.create({ + header: this.translateService.instant('HOME.CLIENT_ERROR.HEADER'), + subHeader: this.translateService.instant('HOME.CLIENT_ERROR.SUBHEADER'), + message: this.translateService.instant('HOME.CLIENT_ERROR.MESSAGE'), + buttons: [ + { + text: this.translateService.instant('HOME.CLIENT_ERROR.OKAY_BUTTON'), + handler: () => { + this.alertController.dismiss().then(); + this.router.navigate(['/home']).then(); + }, + }, + ], + }); + return await alert.present(); + } + previousWeek() { this.offset--; this.updateChart() diff --git a/app/src/assets/i18n/ca.json b/app/src/assets/i18n/ca.json index b2d68bf..1ec4ce6 100644 --- a/app/src/assets/i18n/ca.json +++ b/app/src/assets/i18n/ca.json @@ -102,7 +102,8 @@ "OCCUPATION": { "HISTORIAL": "Històric d'ocupació", "XLABEL": "Dia", - "YLABEL": "Reserves" + "YLABEL": "Reserves", + "TODAY": "Avui" } }, "RESERVATIONS": { diff --git a/app/src/assets/i18n/en.json b/app/src/assets/i18n/en.json index 5cd0521..8137046 100644 --- a/app/src/assets/i18n/en.json +++ b/app/src/assets/i18n/en.json @@ -102,7 +102,8 @@ "OCCUPATION": { "HISTORIAL": "Occupation historic", "XLABEL": "Day", - "YLABEL": "Reservations" + "YLABEL": "Reservations", + "TODAY": "Today" } }, "RESERVATIONS": { diff --git a/app/src/assets/i18n/es.json b/app/src/assets/i18n/es.json index 6b2159d..0d55ff9 100644 --- a/app/src/assets/i18n/es.json +++ b/app/src/assets/i18n/es.json @@ -102,7 +102,8 @@ "OCCUPATION": { "HISTORIAL": "Histórico de ocupación", "XLABEL": "Día", - "YLABEL": "Reservas" + "YLABEL": "Reservas", + "TODAY": "Hoy" } }, "RESERVATIONS": { diff --git a/app/src/assets/i18n/fr.json b/app/src/assets/i18n/fr.json index d22a2e5..b4adff3 100644 --- a/app/src/assets/i18n/fr.json +++ b/app/src/assets/i18n/fr.json @@ -102,7 +102,8 @@ "OCCUPATION": { "HISTORIAL": "Historique d'occupation", "XLABEL": "Jour", - "YLABEL": "Réservations" + "YLABEL": "Réservations", + "TODAY": "Aujourd'hui" } }, "RESERVATIONS": {