From ac5a90570614b8ac55d17506d762f74d71feca39 Mon Sep 17 00:00:00 2001 From: Thomas Fink Date: Mon, 16 Sep 2024 16:45:49 +0200 Subject: [PATCH 1/8] point local env to new citizen api --- .../src/main/resources/application-local.yml | 6 +-- frontend/.env.example | 20 +++++----- .../store/modules/api/actions.spec.js | 38 +++++++++---------- frontend/src/store/index.js | 20 +++++----- 4 files changed, 42 insertions(+), 42 deletions(-) diff --git a/apigateway/src/main/resources/application-local.yml b/apigateway/src/main/resources/application-local.yml index f67ba00..4ea988d 100644 --- a/apigateway/src/main/resources/application-local.yml +++ b/apigateway/src/main/resources/application-local.yml @@ -23,11 +23,11 @@ spring: maxAge: 3600 routes: - id: backend - uri: "http://localhost:3001/" + uri: "http://127.0.0.1:55003/terminvereinbarung/api/citizen" predicates: - Path=/buergeransicht/api/backend/** filters: - - RewritePath=/buergeransicht/api/backend/(?.*), /api/$\{segment}/ + - RewritePath=/buergeransicht/api/backend/(?.*), /terminvereinbarung/api/citizen/$\{segment} - RemoveResponseHeader=WWW-Authenticate default-filters: - RemoveResponseHeader=Expires @@ -41,4 +41,4 @@ spring: server: port: 8080 config: - map5xxto400: true \ No newline at end of file + map5xxto400: true diff --git a/frontend/.env.example b/frontend/.env.example index 2951e2d..d1735a3 100644 --- a/frontend/.env.example +++ b/frontend/.env.example @@ -1,11 +1,11 @@ VUE_APP_ZMS_API_BASE=http://localhost:8080 -VUE_APP_ZMS_API_PROVIDERS_AND_SERVICES_ENDPOINT=/buergeransicht/api/backend/offices-and-services -VUE_APP_ZMS_API_CALENDAR_ENDPOINT=/buergeransicht/api/backend/available-days -VUE_APP_ZMS_API_AVAILABLE_TIME_SLOTS_ENDPOINT=/buergeransicht/api/backend/available-appointments -VUE_APP_ZMS_API_RESERVE_APPOINTMENT_ENDPOINT=/buergeransicht/api/backend/reserve-appointment -VUE_APP_ZMS_API_APPOINTMENT_ENDPOINT=/buergeransicht/api/backend/appointment -VUE_APP_ZMS_API_UPDATE_APPOINTMENT_ENDPOINT=/buergeransicht/api/backend/update-appointment -VUE_APP_ZMS_API_CONFIRM_RESERVATION_ENDPOINT=/buergeransicht/api/backend/confirm-appointment -VUE_APP_ZMS_API_CANCEL_APPOINTMENT_ENDPOINT=/buergeransicht/api/backend/cancel-appointment -VUE_APP_ZMS_API_PRECONFIRM_RESERVATION_ENDPOINT=/buergeransicht/api/backend/preconfirm-appointment -VUE_APP_ZMS_API_CAPTCHA_DETAILS_ENDPOINT=/buergeransicht/api/backend/captcha-details \ No newline at end of file +VUE_APP_ZMS_API_PROVIDERS_AND_SERVICES_ENDPOINT=/buergeransicht/api/backend/offices-and-services/ +VUE_APP_ZMS_API_CALENDAR_ENDPOINT=/buergeransicht/api/backend/available-days/ +VUE_APP_ZMS_API_AVAILABLE_TIME_SLOTS_ENDPOINT=/buergeransicht/api/backend/available-appointments/ +VUE_APP_ZMS_API_RESERVE_APPOINTMENT_ENDPOINT=/buergeransicht/api/backend/reserve-appointment/ +VUE_APP_ZMS_API_APPOINTMENT_ENDPOINT=/buergeransicht/api/backend/appointment/ +VUE_APP_ZMS_API_UPDATE_APPOINTMENT_ENDPOINT=/buergeransicht/api/backend/update-appointment/ +VUE_APP_ZMS_API_CONFIRM_RESERVATION_ENDPOINT=/buergeransicht/api/backend/confirm-appointment/ +VUE_APP_ZMS_API_CANCEL_APPOINTMENT_ENDPOINT=/buergeransicht/api/backend/cancel-appointment/ +VUE_APP_ZMS_API_PRECONFIRM_RESERVATION_ENDPOINT=/buergeransicht/api/backend/preconfirm-appointment/ +VUE_APP_ZMS_API_CAPTCHA_DETAILS_ENDPOINT=/buergeransicht/api/backend/captcha-details/ \ No newline at end of file diff --git a/frontend/__tests__/store/modules/api/actions.spec.js b/frontend/__tests__/store/modules/api/actions.spec.js index e49bed3..adecc8b 100644 --- a/frontend/__tests__/store/modules/api/actions.spec.js +++ b/frontend/__tests__/store/modules/api/actions.spec.js @@ -9,16 +9,16 @@ store.rootState = { settings: { endpoints: { 'VUE_APP_ZMS_API_BASE': 'http://localhost:8082', - 'VUE_APP_ZMS_API_PROVIDERS_AND_SERVICES_ENDPOINT': '/api/backend/offices-and-services', - 'VUE_APP_ZMS_API_CALENDAR_ENDPOINT': '/api/backend/available-days', - 'VUE_APP_ZMS_API_AVAILABLE_TIME_SLOTS_ENDPOINT': '/api/backend/available-appointments', - 'VUE_APP_ZMS_API_RESERVE_APPOINTMENT_ENDPOINT': '/api/backend/reserve-appointment', - 'VUE_APP_ZMS_API_APPOINTMENT_ENDPOINT': '/api/backend/appointment', - 'VUE_APP_ZMS_API_UPDATE_APPOINTMENT_ENDPOINT': '/api/backend/update-appointment', - 'VUE_APP_ZMS_API_CONFIRM_RESERVATION_ENDPOINT': '/api/backend/confirm-appointment', - 'VUE_APP_ZMS_API_CANCEL_APPOINTMENT_ENDPOINT': '/api/backend/cancel-appointment', - 'VUE_APP_ZMS_API_PRECONFIRM_RESERVATION_ENDPOINT': '/api/backend/preconfirm-appointment', - 'VUE_APP_ZMS_API_CAPTCHA_DETAILS_ENDPOINT': '/api/backend/captcha-details' + 'VUE_APP_ZMS_API_PROVIDERS_AND_SERVICES_ENDPOINT': '/api/backend/offices-and-services/', + 'VUE_APP_ZMS_API_CALENDAR_ENDPOINT': '/api/backend/available-days/', + 'VUE_APP_ZMS_API_AVAILABLE_TIME_SLOTS_ENDPOINT': '/api/backend/available-appointments/', + 'VUE_APP_ZMS_API_RESERVE_APPOINTMENT_ENDPOINT': '/api/backend/reserve-appointment/', + 'VUE_APP_ZMS_API_APPOINTMENT_ENDPOINT': '/api/backend/appointment/', + 'VUE_APP_ZMS_API_UPDATE_APPOINTMENT_ENDPOINT': '/api/backend/update-appointment/', + 'VUE_APP_ZMS_API_CONFIRM_RESERVATION_ENDPOINT': '/api/backend/confirm-appointment/', + 'VUE_APP_ZMS_API_CANCEL_APPOINTMENT_ENDPOINT': '/api/backend/cancel-appointment/', + 'VUE_APP_ZMS_API_PRECONFIRM_RESERVATION_ENDPOINT': '/api/backend/preconfirm-appointment/', + 'VUE_APP_ZMS_API_CAPTCHA_DETAILS_ENDPOINT': '/api/backend/captcha-details/' } } } @@ -32,7 +32,7 @@ describe('API actions', () => { it('confirmReservation calls API to confirm reservation', async () => { const res = await actions.confirmReservation(store, {processId: 'aaa', authKey: 'bbb'}) expect(fetch.mock.calls.length).toEqual(1); - expect(fetch.mock.calls[0][0]).toBe('http://localhost:8082/api/backend/confirm-appointment') + expect(fetch.mock.calls[0][0]).toBe('http://localhost:8082/api/backend/confirm-appointment/') expect(fetch.mock.calls[0][1].body).toBe(JSON.stringify({ processId: 'aaa', authKey: 'bbb' @@ -42,7 +42,7 @@ describe('API actions', () => { it('preconfirmReservation calls API to pre-confirm reservation', async () => { const res = await actions.preconfirmReservation(store, {processId: 'aaa', authKey: 'bbb'}) expect(fetch.mock.calls.length).toEqual(1); - expect(fetch.mock.calls[0][0]).toBe('http://localhost:8082/api/backend/preconfirm-appointment') + expect(fetch.mock.calls[0][0]).toBe('http://localhost:8082/api/backend/preconfirm-appointment/') expect(fetch.mock.calls[0][1].body).toBe(JSON.stringify({ processId: 'aaa', authKey: 'bbb' @@ -52,7 +52,7 @@ describe('API actions', () => { it('cancelAppointment calls API to cancel reservation', async () => { const res = await actions.cancelAppointment(store, {processId: 'aaa', authKey: 'bbb'}) expect(fetch.mock.calls.length).toEqual(1); - expect(fetch.mock.calls[0][0]).toBe('http://localhost:8082/api/backend/cancel-appointment') + expect(fetch.mock.calls[0][0]).toBe('http://localhost:8082/api/backend/cancel-appointment/') expect(fetch.mock.calls[0][1].body).toBe(JSON.stringify({ processId: 'aaa', authKey: 'bbb' @@ -70,21 +70,21 @@ describe('API actions', () => { }) expect(fetch.mock.calls.length).toEqual(1); - //expect(fetch.mock.calls[0][0]).toBe('http://localhost:8082/api/backend/available-days?startDate=2020-5-13&endDate=2020-11-13&officeId=111&serviceId=111%2C222&serviceCount=1%2C2') + //expect(fetch.mock.calls[0][0]).toBe('http://localhost:8082/api/backend/available-days/?startDate=2020-5-13&endDate=2020-11-13&officeId=111&serviceId=111%2C222&serviceCount=1%2C2') }) it('fetchServicesAndProviders calls API to fetch services and providers', async () => { const res = await actions.fetchServicesAndProviders(store) expect(fetch.mock.calls.length).toEqual(1); - expect(fetch.mock.calls[0][0]).toBe('http://localhost:8082/api/backend/offices-and-services') + expect(fetch.mock.calls[0][0]).toBe('http://localhost:8082/api/backend/offices-and-services/') }) it('fetchAppointment calls API to fetch appointment', async () => { const res = await actions.fetchAppointment(store, {processId: 'aaa', authKey: 'bbb', scope: 'ccc'}) expect(fetch.mock.calls.length).toEqual(1); - expect(fetch.mock.calls[0][0]).toBe('http://localhost:8082/api/backend/appointment?processId=aaa&authKey=bbb&scope=ccc') + expect(fetch.mock.calls[0][0]).toBe('http://localhost:8082/api/backend/appointment/?processId=aaa&authKey=bbb&scope=ccc') }) it('fetchAvailableTimeSlots calls API to fetch available time slots', async () => { @@ -99,7 +99,7 @@ describe('API actions', () => { }) expect(fetch.mock.calls.length).toEqual(1); - //expect(fetch.mock.calls[0][0]).toBe('http://localhost:8082/api/backend/available-appointments?date=2023-3-1&officeId=111&serviceId=222%2C333&serviceCount=2%2C3') + //expect(fetch.mock.calls[0][0]).toBe('http://localhost:8082/api/backend/available-appointments/?date=2023-3-1&officeId=111&serviceId=222%2C333&serviceCount=2%2C3') }) it('updateAppointmentData calls API to update appointment data', async () => { @@ -113,7 +113,7 @@ describe('API actions', () => { }) expect(fetch.mock.calls.length).toEqual(1); - expect(fetch.mock.calls[0][0]).toBe('http://localhost:8082/api/backend/update-appointment') + expect(fetch.mock.calls[0][0]).toBe('http://localhost:8082/api/backend/update-appointment/') expect(fetch.mock.calls[0][1].body).toBe(JSON.stringify({ "processId": 'aaa', "authKey": 'bbb', @@ -133,7 +133,7 @@ describe('API actions', () => { }) expect(fetch.mock.calls.length).toEqual(1); - expect(fetch.mock.calls[0][0]).toBe('http://localhost:8082/api/backend/reserve-appointment') + expect(fetch.mock.calls[0][0]).toBe('http://localhost:8082/api/backend/reserve-appointment/') expect(fetch.mock.calls[0][1].body).toBe(JSON.stringify({ "timestamp": 1589373217, "serviceCount": [2], diff --git a/frontend/src/store/index.js b/frontend/src/store/index.js index b6f73da..3e5550a 100644 --- a/frontend/src/store/index.js +++ b/frontend/src/store/index.js @@ -40,16 +40,16 @@ const store = new Vuex.Store({ }, endpoints: { 'VUE_APP_ZMS_API_BASE': `${process.env.VUE_APP_API_URL}`, - 'VUE_APP_ZMS_API_PROVIDERS_AND_SERVICES_ENDPOINT': '/api/backend/offices-and-services', - 'VUE_APP_ZMS_API_CALENDAR_ENDPOINT': '/api/backend/available-days', - 'VUE_APP_ZMS_API_AVAILABLE_TIME_SLOTS_ENDPOINT': '/api/backend/available-appointments', - 'VUE_APP_ZMS_API_RESERVE_APPOINTMENT_ENDPOINT': '/api/backend/reserve-appointment', - 'VUE_APP_ZMS_API_APPOINTMENT_ENDPOINT': '/api/backend/appointment', - 'VUE_APP_ZMS_API_UPDATE_APPOINTMENT_ENDPOINT': '/api/backend/update-appointment', - 'VUE_APP_ZMS_API_CONFIRM_RESERVATION_ENDPOINT': '/api/backend/confirm-appointment', - 'VUE_APP_ZMS_API_CANCEL_APPOINTMENT_ENDPOINT': '/api/backend/cancel-appointment', - 'VUE_APP_ZMS_API_PRECONFIRM_RESERVATION_ENDPOINT': '/api/backend/preconfirm-appointment', - 'VUE_APP_ZMS_API_CAPTCHA_DETAILS_ENDPOINT': '/api/backend/captcha-details' + 'VUE_APP_ZMS_API_PROVIDERS_AND_SERVICES_ENDPOINT': '/api/backend/offices-and-services/', + 'VUE_APP_ZMS_API_CALENDAR_ENDPOINT': '/api/backend/available-days/', + 'VUE_APP_ZMS_API_AVAILABLE_TIME_SLOTS_ENDPOINT': '/api/backend/available-appointments/', + 'VUE_APP_ZMS_API_RESERVE_APPOINTMENT_ENDPOINT': '/api/backend/reserve-appointment/', + 'VUE_APP_ZMS_API_APPOINTMENT_ENDPOINT': '/api/backend/appointment/', + 'VUE_APP_ZMS_API_UPDATE_APPOINTMENT_ENDPOINT': '/api/backend/update-appointment/', + 'VUE_APP_ZMS_API_CONFIRM_RESERVATION_ENDPOINT': '/api/backend/confirm-appointment/', + 'VUE_APP_ZMS_API_CANCEL_APPOINTMENT_ENDPOINT': '/api/backend/cancel-appointment/', + 'VUE_APP_ZMS_API_PRECONFIRM_RESERVATION_ENDPOINT': '/api/backend/preconfirm-appointment/', + 'VUE_APP_ZMS_API_CAPTCHA_DETAILS_ENDPOINT': '/api/backend/captcha-details/' } } }, From 9c83c8ef798e7c92772990206cae2da17b41947a Mon Sep 17 00:00:00 2001 From: Thomas Fink Date: Mon, 2 Dec 2024 19:38:04 +0100 Subject: [PATCH 2/8] feat(MPDZBS-877): set local env to citizen api --- apigateway/src/main/resources/application-local.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apigateway/src/main/resources/application-local.yml b/apigateway/src/main/resources/application-local.yml index 4ea988d..cd0d2ea 100644 --- a/apigateway/src/main/resources/application-local.yml +++ b/apigateway/src/main/resources/application-local.yml @@ -23,7 +23,7 @@ spring: maxAge: 3600 routes: - id: backend - uri: "http://127.0.0.1:55003/terminvereinbarung/api/citizen" + uri: "http://zms.ddev.site/terminvereinbarung/api/citizen" predicates: - Path=/buergeransicht/api/backend/** filters: From d75d4ec57a9fd090f843c927f2db67edd540d7eb Mon Sep 17 00:00:00 2001 From: Thomas Fink Date: Tue, 3 Dec 2024 12:14:25 +0100 Subject: [PATCH 3/8] feat(MPDZBS): improve application and network error handling for zmscitizenapi --- frontend/src/App.vue | 11 +++- frontend/src/components/AppointmentForm.vue | 7 +++ frontend/src/components/CustomerInfo.vue | 11 +++- frontend/src/components/TheCalendar.vue | 50 ++++++++++++----- frontend/src/store/actions.js | 16 +++--- frontend/src/store/modules/api/actions.js | 60 ++++++++++----------- frontend/src/translations/de/index.js | 4 +- frontend/src/translations/en/index.js | 4 +- 8 files changed, 105 insertions(+), 58 deletions(-) diff --git a/frontend/src/App.vue b/frontend/src/App.vue index a7c880f..aaee8a8 100644 --- a/frontend/src/App.vue +++ b/frontend/src/App.vue @@ -103,6 +103,13 @@ export default { this.$store.state.openedPanel = 3 this.$store.state.confirmedAppointment = true }) + .catch(error => { + if (error.errors && Array.isArray(error.errors)) { + this.dateError = error.errors[0]?.errorMessage || this.$t('applicationError'); + } else { + this.dateError = this.$t('networkError'); + } + }); } this.$store.dispatch('setUpCaptchaDetails'); }) @@ -128,8 +135,8 @@ export default { Promise.all(promises).then(() => { this.stylesLoaded = true; this.loadData(); - }).catch((error) => { - console.error('Error loading styles:', error); + }).catch((errors) => { + console.error('Error loading styles:', errors); }); } }, diff --git a/frontend/src/components/AppointmentForm.vue b/frontend/src/components/AppointmentForm.vue index 629964d..7eacb87 100644 --- a/frontend/src/components/AppointmentForm.vue +++ b/frontend/src/components/AppointmentForm.vue @@ -430,6 +430,13 @@ export default { this.disabled = false this.$store.state.confirmedAppointment = false }) + .catch(error => { + if (error.errors && Array.isArray(error.errors)) { + this.dateError = error.errors[0]?.errorMessage || this.$t('applicationError'); + } else { + this.dateError = this.$t('networkError'); + } + }); }, openPanel(step) { this.$store.commit('goToStep', step) diff --git a/frontend/src/components/CustomerInfo.vue b/frontend/src/components/CustomerInfo.vue index 7e4e3a0..947c098 100644 --- a/frontend/src/components/CustomerInfo.vue +++ b/frontend/src/components/CustomerInfo.vue @@ -251,10 +251,17 @@ export default { this.$emit('next') window.scrollTo(0, 0) this.$v.$reset() - }, (error) => { - console.error(error) + }, (errors) => { + console.error(errors) this.$store.state.error = 'tooManyAppointmentsWithSameMail' }) + .catch(error => { + if (error.errors && Array.isArray(error.errors)) { + this.dateError = error.errors[0]?.errorMessage || this.$t('applicationError'); + } else { + this.dateError = this.$t('networkError'); + } + }); }, validTelephoneFormat(value) { const phoneRegex = /^\+?\d+$/; diff --git a/frontend/src/components/TheCalendar.vue b/frontend/src/components/TheCalendar.vue index 9abb98c..2bc9090 100644 --- a/frontend/src/components/TheCalendar.vue +++ b/frontend/src/components/TheCalendar.vue @@ -4,7 +4,8 @@ {{ provider.name }} @@ -146,7 +147,7 @@ export default { } }, methods: { - selectedServiceIds: function() { + selectedServiceIds: function () { let selectedServiceIds = [] Object.entries(this.$store.state.data.appointmentCounts).map(([serviceId, count]) => { @@ -158,7 +159,7 @@ export default { return selectedServiceIds }, filteredProviders: function () { - if (! this.$store.state.data.service || ! this.$store.state.data.service.providers) { + if (!this.$store.state.data.service || !this.$store.state.data.service.providers) { return [] } @@ -167,7 +168,7 @@ export default { if (this.$store.state.data.service.subServices) { this.$store.state.data.service.subServices.map((subservice) => { if (this.selectedServiceIds().indexOf(parseInt(subservice.id)) !== -1) { - providers = providers.filter(function(provider) { + providers = providers.filter(function (provider) { return subservice.providers.indexOf(provider.id) !== -1; }); } @@ -223,12 +224,12 @@ export default { this.$store.dispatch('API/fetchAvailableTimeSlots', { date: momentDate, provider: { ...this.provider, slots: 1 }, serviceIds: Object.keys(selectedServices), serviceCounts: Object.values(selectedServices) }) .then(data => { - if (data.errorMessage) { + if (data.errors && Array.isArray(data.errors) && data.errors[0] && data.errors[0].errorMessage) { this.selectableDates = this.selectableDates.filter(selectableDate => { return selectableDate !== date }) - this.dateError = data.errorMessage + this.dateError = data.errors[0].errorMessage return } @@ -246,6 +247,13 @@ export default { window.location.hash = '#appointments' } }) + .catch(error => { + if (error.errors && Array.isArray(error.errors)) { + this.dateError = error.errors[0]?.errorMessage || this.$t('applicationError'); + } else { + this.dateError = this.$t('networkError'); + } + }); }, handleTimeSlotSelection: function (timeSlot) { this.selectedTimeSlot = timeSlot; @@ -271,12 +279,12 @@ export default { this.$store.dispatch('API/reserveAppointment', { timeSlot, serviceIds: Object.keys(selectedServices), serviceCounts: Object.values(selectedServices), providerId: this.provider.id, captchaSolution: this.captchaSolution }) .then(data => { - if (data.errorMessage) { - this.timeSlotError = data.errorMessage + if (data.errors && Array.isArray(data.errors) && data.errors[0] && data.errors[0].errorMessage) { + this.timeSlotError = data.errors[0].errorMessage return } - if (data.error) { + if (data.errors) { this.timeSlotError = this.$t('errorTryAgainLater') return } @@ -292,6 +300,13 @@ export default { }, () => { this.timeSlotError = this.$t('noAppointmentsAvailable') }) + .catch(error => { + if (error.errors && Array.isArray(error.errors)) { + this.dateError = error.errors[0]?.errorMessage || this.$t('applicationError'); + } else { + this.dateError = this.$t('networkError'); + } + }); if (!this.timeSlotError && oldAppointment && !this.$store.state.isRebooking) { this.$store.dispatch('API/cancelAppointment', oldAppointment) @@ -329,14 +344,21 @@ export default { this.$store.dispatch('API/fetchAvailableDays', { provider: this.provider, serviceIds: Object.keys(selectedServices), serviceCounts: Object.values(selectedServices) }) .then(data => { let availableDays = data.availableDays ?? [] - if (data.errorMessage) { - this.dateError = data.errorMessage + if (data.errors && Array.isArray(data.errors) && data.errors[0] && data.errors[0].errorMessage) { + this.dateError = data.errors[0].errorMessage } this.selectableDates = availableDays this.getAppointmentsOfDay(availableDays[0], false) }) + .catch(error => { + if (error.errors && Array.isArray(error.errors)) { + this.dateError = error.errors[0]?.errorMessage || this.$t('applicationError'); + } else { + this.dateError = this.$t('networkError'); + } + }); }, handleCaptchaDone(solution) { this.captchaSolution = solution; @@ -344,8 +366,8 @@ export default { this.chooseAppointment(this.selectedTimeSlot); } }, - handleCaptchaError(error) { - console.error("Captcha error:", error); + handleCaptchaError(errors) { + console.error("Captcha errors:", errors); // Handle the error, possibly show a message to the user } }, @@ -361,7 +383,7 @@ export default { } if (this.$store.state.preselectedProvider - && (!this.provider || this.$store.state.preselectedProvider.id !== this.provider.id)) { + && (!this.provider || this.$store.state.preselectedProvider.id !== this.provider.id)) { this.showForProvider(this.$store.state.preselectedProvider) diff --git a/frontend/src/store/actions.js b/frontend/src/store/actions.js index 82a5a4e..7da8643 100644 --- a/frontend/src/store/actions.js +++ b/frontend/src/store/actions.js @@ -15,8 +15,8 @@ export default { store.commit('data/setAppointment', appointment) resolve(true) - }, (error) => { - reject(error) + }, (errors) => { + reject(errors) }) }) }, @@ -27,9 +27,9 @@ export default { store.commit('setCaptchaDetails', data); resolve(data); }) - .catch(error => { + .catch(errors => { store.commit('setError', 'captcha-details-error'); - reject(error); + reject(errors); }); }); }, @@ -100,7 +100,7 @@ export default { store.state.errorCode = 'appointmentDoesntExist' return } - } catch (error) { + } catch (errors) { store.state.errorCode = 'appointmentDoesntExist' return } @@ -126,15 +126,15 @@ export default { store.state.errorCode = 'appointmentDoesntExist' return } - } catch (error) { + } catch (errors) { store.state.errorCode = 'appointmentDoesntExist' return } store.dispatch('API/fetchAppointment', { processId: appointmentData.id, authKey: appointmentData.authKey, scope: appointmentData.scope }) .then(data => { - if (data.errorMessage) { - store.state.errorMessage = data.errorMessage + if (data.errors && Array.isArray(data.errors) && data.errors[0] && data.errors[0].errorMessage) { + store.state.errorMessage = data.errors[0].errorMessage return } diff --git a/frontend/src/store/modules/api/actions.js b/frontend/src/store/modules/api/actions.js index 8c6989a..0f290f6 100644 --- a/frontend/src/store/modules/api/actions.js +++ b/frontend/src/store/modules/api/actions.js @@ -19,12 +19,12 @@ export default { return response.json(); }) .then(data => { - if (data.error) { + if (data.errors) { reject(data); } resolve(data); - }, error => { - reject(error); + }, errors => { + reject(errors); }); }); }, @@ -46,13 +46,13 @@ export default { return response.json(); }) .then(data => { - if (data.error) { + if (data.errors) { reject(data) } resolve(data) - }, error => { - reject(error) + }, errors => { + reject(errors) }) }) }, @@ -76,13 +76,13 @@ export default { return response.json(); }) .then(data => { - if (data.error || data.errorCode) { + if (data.errors || data.errors[0].errorCode) { reject(data); } resolve(data); - }, error => { - reject(error); + }, errors => { + reject(errors); }); }); }, @@ -106,13 +106,13 @@ export default { }) )) .then(data => { - if (data.error) { + if (data.errors) { reject(data) } resolve(data) - }, error => { - reject(error) + }, errors => { + reject(errors) }) }) }, @@ -135,13 +135,13 @@ export default { return response.json(); }) .then(data => { - if (data.error) { + if (data.errors) { reject(data) } resolve(data) - }, error => { - reject(error) + }, errors => { + reject(errors) }) }) }, @@ -160,12 +160,12 @@ export default { return response.json(); }) .then(data => { - if (data.error) { + if (data.errors) { reject(data); } resolve(data); - }, error => { - reject(error); + }, errors => { + reject(errors); }); }); }, @@ -184,13 +184,13 @@ export default { return response.json(); }) .then(data => { - if (data.error) { + if (data.errors) { reject(data) } resolve(data) - }, error => { - reject(error) + }, errors => { + reject(errors) }) }) }, @@ -211,13 +211,13 @@ export default { return response.json(); }) .then(data => { - if (data.error) { + if (data.errors) { reject(data) } resolve(data) - }, error => { - reject(error) + }, errors => { + reject(errors) }) }) }, @@ -249,13 +249,13 @@ export default { return response.json(); }) .then(data => { - if (data.errorCode) { + if (data.errors) { reject(data) } resolve(data) - }, error => { - reject(error) + }, errors => { + reject(errors) }) }) }, @@ -281,12 +281,12 @@ export default { return response.json(); }) .then(data => { - if (data.error) { + if (data.errors) { reject(data); } resolve(data); - }, error => { - reject(error); + }, errors => { + reject(errors); }); }); } diff --git a/frontend/src/translations/de/index.js b/frontend/src/translations/de/index.js index c7a904d..4cc83db 100644 --- a/frontend/src/translations/de/index.js +++ b/frontend/src/translations/de/index.js @@ -73,5 +73,7 @@ export default { de: 'Deutsch', en: 'Englisch', }, - oftenBookedTogether: 'Oft zusammen gebucht' + oftenBookedTogether: 'Oft zusammen gebucht', + networkError: 'Es ist ein Netzwerkfehler oder ein unerwarteter Fehler aufgetreten. Bitte versuchen Sie es erneut.', + applicationError: 'Unbekannter Anwendungs-Fehler.' } diff --git a/frontend/src/translations/en/index.js b/frontend/src/translations/en/index.js index ada24bb..99a1e46 100644 --- a/frontend/src/translations/en/index.js +++ b/frontend/src/translations/en/index.js @@ -49,5 +49,7 @@ export default { de: 'German', en: 'English', }, - oftenBookedTogether: 'Often booked together' + oftenBookedTogether: 'Often booked together', + networkError: 'A network or unexpected error occurred. Please try again.', + applicationError: 'Unknown application error.' } \ No newline at end of file From 9a15297109c54734719570db563e643d3c084d0e Mon Sep 17 00:00:00 2001 From: Thomas Fink Date: Tue, 3 Dec 2024 12:17:26 +0100 Subject: [PATCH 4/8] fix(MPDZBS): error handling for preconfirmReservation --- frontend/src/store/modules/api/actions.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frontend/src/store/modules/api/actions.js b/frontend/src/store/modules/api/actions.js index 0f290f6..5a62ee1 100644 --- a/frontend/src/store/modules/api/actions.js +++ b/frontend/src/store/modules/api/actions.js @@ -76,7 +76,7 @@ export default { return response.json(); }) .then(data => { - if (data.errors || data.errors[0].errorCode) { + if (data.errors) { reject(data); } From c7cbdc8e98bb8f0fda7d980435c96b1b30f6edc7 Mon Sep 17 00:00:00 2001 From: Thomas Fink Date: Tue, 3 Dec 2024 12:23:33 +0100 Subject: [PATCH 5/8] fix(MPDZBS): add logging to test --- frontend/__tests__/store/actions.spec.js | 1 + 1 file changed, 1 insertion(+) diff --git a/frontend/__tests__/store/actions.spec.js b/frontend/__tests__/store/actions.spec.js index d3e1f5c..4070d98 100644 --- a/frontend/__tests__/store/actions.spec.js +++ b/frontend/__tests__/store/actions.spec.js @@ -205,6 +205,7 @@ describe('Actions', () => { appointmentHash: 'eyJpZCI6IDEyMzQ1LCJhdXRoS2V5IjogImJiYmIifQ==' }) + console.log(store.state.errorMessage); expect(store.state.errorMessage).toBe('Not valid appointment') }) From 6243fb11a07c5e6cc3102c373283adb10cdd8c58 Mon Sep 17 00:00:00 2001 From: Thomas Fink Date: Tue, 3 Dec 2024 12:38:06 +0100 Subject: [PATCH 6/8] fix(MPDZBS): try fixing one test --- frontend/__tests__/store/actions.spec.js | 25 +++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/frontend/__tests__/store/actions.spec.js b/frontend/__tests__/store/actions.spec.js index 4070d98..edb43a8 100644 --- a/frontend/__tests__/store/actions.spec.js +++ b/frontend/__tests__/store/actions.spec.js @@ -195,19 +195,22 @@ describe('Actions', () => { const mockMethods = jest.fn(() => { return new Promise((resolve) => { resolve({ - errorMessage: 'Not valid appointment' - }) - }) - }) - store.dispatch = mockMethods - + errors: [ + { + errorMessage: 'Not valid appointment' + } + ] + }); + }); + }); + store.dispatch = mockMethods; + await actions.setUpAppointment(store, { appointmentHash: 'eyJpZCI6IDEyMzQ1LCJhdXRoS2V5IjogImJiYmIifQ==' - }) - - console.log(store.state.errorMessage); - expect(store.state.errorMessage).toBe('Not valid appointment') - }) + }); + + expect(store.state.errorMessage).toBe('Not valid appointment'); + }); it('setAppointmentFromResponse set up appointment in store', async () => { const commitMethods = jest.fn() From 44b40a45e574c6cc630ad3c74a002b735468b775 Mon Sep 17 00:00:00 2001 From: Thomas Fink Date: Tue, 3 Dec 2024 12:40:53 +0100 Subject: [PATCH 7/8] fix(MPDZBS): try fixing more tests --- .../__tests__/components/Calendar.spec.js | 24 ++++++++++++++----- 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/frontend/__tests__/components/Calendar.spec.js b/frontend/__tests__/components/Calendar.spec.js index cef4fcc..956d356 100644 --- a/frontend/__tests__/components/Calendar.spec.js +++ b/frontend/__tests__/components/Calendar.spec.js @@ -227,8 +227,12 @@ describe('Calendar', () => { const mockCallback = jest.fn(() => { return new Promise((resolve, reject) => { resolve({ - 'errorMessage': 'Something went wrong' - }) + errors: [ + { + errorMessage: 'Something went wrong' + } + ] + }); }) }) @@ -246,8 +250,12 @@ describe('Calendar', () => { const mockCallback = jest.fn(() => { return new Promise((resolve, reject) => { resolve({ - 'errorMessage': 'Something went wrong' - }) + errors: [ + { + errorMessage: 'Something went wrong' + } + ] + }); }) }) @@ -293,8 +301,12 @@ describe('Calendar', () => { const mockCallback = jest.fn((method, parameters) => { return new Promise((resolve, reject) => { resolve({ - 'errorMessage': 'Ooops. Something went wrong' - }) + errors: [ + { + errorMessage: 'Something went wrong' + } + ] + }); }) }) From d5c6d7cb34588ac3a20fa05c0d3b20cd374c410b Mon Sep 17 00:00:00 2001 From: Thomas Fink Date: Tue, 3 Dec 2024 12:45:14 +0100 Subject: [PATCH 8/8] fix(MPDZBS): try fixing more tests --- frontend/__tests__/components/Calendar.spec.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/frontend/__tests__/components/Calendar.spec.js b/frontend/__tests__/components/Calendar.spec.js index 956d356..30fcd74 100644 --- a/frontend/__tests__/components/Calendar.spec.js +++ b/frontend/__tests__/components/Calendar.spec.js @@ -328,8 +328,12 @@ describe('Calendar', () => { if (method === 'API/reserveAppointment') { return new Promise((resolve, reject) => { resolve({ - 'error': 'Failed.' - }) + errors: [ + { + 'error': 'Failed.' + } + ] + }); }) } })