Skip to content

Commit

Permalink
feat: more information about past date
Browse files Browse the repository at this point in the history
  • Loading branch information
Pablito2020 committed Nov 21, 2023
1 parent ce40bb1 commit 0c51fef
Show file tree
Hide file tree
Showing 8 changed files with 31 additions and 12 deletions.
4 changes: 2 additions & 2 deletions app/src/app/app.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,8 @@
<ng-container *ngIf="hasConnectionError$ | async as error">
<ion-alert
isOpen="{{ error }}"
header="You are offline!"
message="You are offline or the server is not reachable. Please check your internet connection and try again."
header="{{ 'HOME.CLIENT_ERROR.HEADER' | translate }}"
message="{{ 'HOME.CLIENT_ERROR.SUBHEADER' | translate }}"
[buttons]="alertButtons"
></ion-alert>
</ng-container>
2 changes: 1 addition & 1 deletion app/src/app/app.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export class AppComponent implements OnInit {
isMapLoading$: Observable<boolean> = this.store.select(isMapLoading);
public alertButtons = [
{
text: 'OK',
text: this.translateService.instant('HOME.CLIENT_ERROR.OKAY_BUTTON'),
role: 'confirm',
handler: () => {
this.store.dispatch(fixFatalError());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
</ion-col>
<ion-alert
trigger="present-info-alert"
header="'REFUGE.RESERVATIONS.INFO.HEADER' | translate"
message="'REFUGE.RESERVATIONS.INFO.BODY' | translate"
header="{{ 'REFUGE.RESERVATIONS.INFO.HEADER' | translate }}"
message="{{ 'REFUGE.RESERVATIONS.INFO.BODY' | translate }}"
[buttons]="alertButtons"
></ion-alert>
</ion-row>
Expand Down
12 changes: 10 additions & 2 deletions app/src/app/pages/reservations/reservations.store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -239,10 +239,11 @@ export class ReservationsComponentStore extends ComponentStore<ReservationsState
}),
),
)
.with(CreateReservationDataError.INVALID_DATE, () =>
.with(CreateReservationDataError.INVALID_DATE_ALREADY_RESERVED, () =>
this.store.dispatch(
customMinorError({
error: 'RESERVATIONS.CREATE_OPERATION.INVALID_DATE',
error:
'RESERVATIONS.CREATE_OPERATION.INVALID_DATE_ALREADY_RESERVED',
}),
),
)
Expand All @@ -253,6 +254,13 @@ export class ReservationsComponentStore extends ComponentStore<ReservationsState
}),
),
)
.with(CreateReservationDataError.INVALID_DATE_PAST_DATE, () =>
this.store.dispatch(
customMinorError({
error: 'RESERVATIONS.CREATE_OPERATION.INVALID_DATE_PAST',
}),
),
)
.otherwise((error) => this.store.dispatch(minorError({ error })));
}

Expand Down
12 changes: 10 additions & 2 deletions app/src/app/schemas/reservations/create-reservation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ import { getErrorFrom } from '../errors/all-errors';

export enum CreateReservationDataError {
REFUGE_OR_USER_NOT_FOUND = 'REFUGE_OR_USER_NOT_FOUND',
INVALID_DATE = 'INVALID_DATE',
INVALID_DATE_ALREADY_RESERVED = 'INVALID_DATE_ALREADY_RESERVED',
INVALID_DATE_PAST_DATE = 'INVALID_DATE_IS_PAST',
NTP_SERVER_IS_DOWN = 'NTP_SERVER_IS_DOWN',
}

Expand All @@ -28,7 +29,14 @@ export namespace CreateReservationError {
'User already has a reservation on this date',
)
)
return CreateReservationDataError.INVALID_DATE;
return CreateReservationDataError.INVALID_DATE_ALREADY_RESERVED;
if (
error.error.detail !== undefined &&
error.error.detail.includes(
'You cannot make a reservation for a past date',
)
)
return CreateReservationDataError.INVALID_DATE_PAST_DATE;
return PermissionsErrors.NOT_ALLOWED_OPERATION_FOR_USER;
})
.with(
Expand Down
3 changes: 2 additions & 1 deletion app/src/assets/i18n/ca.json
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,8 @@
},
"CREATE_OPERATION": {
"CORRECT": "Reserva al dia {{day}} creada!",
"INVALID_DATE": "La data seleccionada no és vàlida.",
"INVALID_DATE_PAST": "No pots seleccionar una data passada",
"INVALID_DATE_ALREADY_RESERVED": "No pots seleccionar una data ja reservada",
"NOT_ALLOWED_CREATION_FOR_USER": "No pots crear una reserva per a un altre usuari",
"REFUGE_OR_USER_NOT_FOUND": "Refugi o usuari ha estat eliminat, refresca la pàgina"
},
Expand Down
3 changes: 2 additions & 1 deletion app/src/assets/i18n/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,8 @@
},
"CREATE_OPERATION": {
"CORRECT": "Reservation on day {{day}} created!",
"INVALID_DATE": "The selected date is invalid!",
"INVALID_DATE_PAST": "Can't select past date!",
"INVALID_DATE_ALREADY_RESERVED": "Can't select a date that is already reserved!",
"NOT_ALLOWED_CREATION_FOR_USER": "You can't create a reservation for another user",
"REFUGE_OR_USER_NOT_FOUND": "Refuge or user has been deleted, refresh the page"
},
Expand Down
3 changes: 2 additions & 1 deletion app/src/assets/i18n/es.json
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,8 @@
},
"CREATE_OPERATION": {
"CORRECT": "¡Reserva en el día {{day}} creada!",
"INVALID_DATE": "La fecha seleccionada no es válida.",
"INVALID_DATE_PAST": "No puedes seleccionar una fecha en el pasado",
"INVALID_DATE_ALREADY_RESERVED": "No puedes seleccionar una fecha que ya está reservada",
"NOT_ALLOWED_CREATION_FOR_USER": "No puedes crear una reserva para otro usuario",
"REFUGE_OR_USER_NOT_FOUND": "Refugio o usuario ha sido eliminado, actualiza la página"
},
Expand Down

0 comments on commit 0c51fef

Please sign in to comment.