Skip to content

Commit

Permalink
Added more specific reservation period collision error notification (#…
Browse files Browse the repository at this point in the history
…328)

Instead of showing general "something went wrong" error notification, period collision errors will show new more specific error notification.
  • Loading branch information
SanttuA authored May 24, 2024
1 parent 8e729ed commit c02a5dd
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 3 deletions.
3 changes: 2 additions & 1 deletion app/i18n/messages/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,7 @@
"Notifications.cannotReserveDuringMaintenance": "Cannot make reservations during maintenance.",
"Notifications.continousFreeDaysError": "You can only select a continuous period of available days",
"Notifications.errorMessage": "Something went wrong. Please try again in a moment.",
"Notifications.error.period": "The resource is not reservable at your selected time. Please choose a new time from the calendar.",
"Notifications.loginErrorMessage": "Failed to login. Please try again in a moment.",
"Notifications.userFetchErrorMessage": "Failed to retrieve user info. Please try again in a moment.",
"Notifications.loginMessage": "Sign in to continue.",
Expand Down Expand Up @@ -554,4 +555,4 @@
"UserReservationsPage.regularEmptyMessage": "No standard reservations",
"UserReservationsPage.regularReservationsHeader": "Standard reservations",
"UserReservationsPage.title": "My reservations"
}
}
3 changes: 2 additions & 1 deletion app/i18n/messages/fi.json
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,7 @@
"Notifications.cannotReserveDuringMaintenance": "Huoltotyön aikana ei voi tehdä varauksia.",
"Notifications.continousFreeDaysError": "Voit valita vain yhtenäisen jakson vapaita päiviä",
"Notifications.errorMessage": "Jotain meni vikaan. Yritä hetken päästä uudelleen.",
"Notifications.error.period": "Kohde ei ole varattavissa valitsemallasi ajalle. Valitse kalenterista uusi aika.",
"Notifications.loginErrorMessage": "Kirjautuminen epäonnistui. Yritä hetken päästä uudelleen.",
"Notifications.userFetchErrorMessage": "Käyttäjätietojen hakeminen epäonnistui. Yritä hetken päästä uudelleen.",
"Notifications.loginMessage": "Kirjaudu sisään jatkaaksesi.",
Expand Down Expand Up @@ -554,4 +555,4 @@
"UserReservationsPage.regularEmptyMessage": "Ei tavallisia varauksia näytettäväksi.",
"UserReservationsPage.regularReservationsHeader": "Tavalliset varaukset",
"UserReservationsPage.title": "Omat varaukset"
}
}
3 changes: 2 additions & 1 deletion app/i18n/messages/sv.json
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,7 @@
"Notifications.cannotReserveDuringMaintenance": "Det går inte att göra reservationer under underhåll.",
"Notifications.continousFreeDaysError": "Du kan bara välja en sammanhängande period av lediga dagar",
"Notifications.errorMessage": "Ett fel uppstod. Försök på nytt om en liten stund.",
"Notifications.error.period": "Resursen är inte bokningsbar vid den valda tiden. Vänligen välj en ny tid från kalendern.",
"Notifications.loginErrorMessage": "Inloggning misslyckades. Försök igen om en liten stund.",
"Notifications.userFetchErrorMessage": "Användarinformations hämtning misslyckades. Försök igen om en liten stund.",
"Notifications.loginMessage": "Logga in för att fortsätta.",
Expand Down Expand Up @@ -556,4 +557,4 @@
"UserReservationsPage.regularEmptyMessage": "Det finns inga vanliga bokningar att visa.",
"UserReservationsPage.regularReservationsHeader": "Vanliga bokningar",
"UserReservationsPage.title": "Mina bokningar"
}
}
7 changes: 7 additions & 0 deletions app/state/reducers/notificationsReducer.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,13 @@ function getErrorNotification(error) {
};
}

if (error.response && error.response.period) {
return {
...defaults,
messageId: 'Notifications.error.period',
};
}

if (error.response && error.response.detail) {
return {
...defaults,
Expand Down
11 changes: 11 additions & 0 deletions app/state/reducers/notificationsReducer.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,17 @@ describe('state/reducers/notificationReducer', () => {
expect(actualNotifications[0].message).toEqual('some recurring error');
});

test('show period error when period is specified', () => {
const action = errorAction({
response: {
period: 'some period error'
},
});

const actualNotifications = notificationsReducer(initialState, action);
expect(actualNotifications[0].messageId).toEqual('Notifications.error.period');
});

test('show detail message when response is specified', () => {
const action = errorAction({
response: {
Expand Down

0 comments on commit c02a5dd

Please sign in to comment.