Skip to content

Commit

Permalink
feat(ZMS-2936): add error message logic
Browse files Browse the repository at this point in the history
  • Loading branch information
lehju committed Nov 28, 2024
1 parent 6babda9 commit c192ef0
Show file tree
Hide file tree
Showing 3 changed files with 86 additions and 37 deletions.
115 changes: 78 additions & 37 deletions zmscitizenview/src/components/Appointment/AppointmentView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -9,40 +9,70 @@
:active-item="activeStep"
@change-step="changeStep"
/>
<service-finder
v-if="currentView === 0"
:preselected-service-id="serviceId"
:preselected-offive-id="locationId"
:t="t"
@next="setServices"
/>
<calendar-view
v-if="currentView === 1"
:selected-service-map="selectedServiceMap"
:t="t"
@back="decreaseCurrentView"
@next="nextReserveAppointment"
/>
<customer-info
v-if="currentView === 2"
:t="t"
@back="decreaseCurrentView"
@next="nextUpdateAppointment"
/>
<appointment-summary
v-if="currentView === 3 && !updateAppointmentError"
:t="t"
@back="decreaseCurrentView"
@book-appointment="nextBookAppointment"
/>
<div v-if="currentView === 3 && updateAppointmentError">
<muc-callout type="error">
<template #content>
{{ t("updateAppointmentErrorText") }}
</template>

<template #header>{{ t("updateAppointmentErrorHeader") }}</template>
</muc-callout>
<div v-if="currentView === 0">
<service-finder
:preselected-service-id="serviceId"
:preselected-offive-id="locationId"
:t="t"
@next="setServices"
/>
</div>
<div v-if="currentView === 1">
<calendar-view
:selected-service-map="selectedServiceMap"
:t="t"
@back="decreaseCurrentView"
@next="nextReserveAppointment"
/>
<div v-if="appointmentNotAvailableError">
<muc-callout type="error">
<template #content>
{{ t("selectedDateNoLongerAvailableText") }}
</template>

<template #header>{{
t("selectedDateNoLongerAvailableHeader")
}}</template>
</muc-callout>
</div>
</div>
<div v-if="currentView === 2">
<customer-info
:t="t"
@back="decreaseCurrentView"
@next="nextUpdateAppointment"
/>
</div>
<div v-if="currentView === 3">
<!-- Delete tooManyAppointmentsWithSameMailError if contact is transferred from backend call offices-and-services -->
<appointment-summary
v-if="
!updateAppointmentError && !tooManyAppointmentsWithSameMailError
"
:t="t"
@back="decreaseCurrentView"
@book-appointment="nextBookAppointment"
/>
<div v-if="tooManyAppointmentsWithSameMailError">
<muc-callout type="error">
<template #content>
{{ t("tooManyAppointmentsWithSameMailErrorText") }}
</template>

<template #header>{{
t("tooManyAppointmentsWithSameMailErrorHeader")
}}</template>
</muc-callout>
</div>
<div v-if="updateAppointmentError">
<muc-callout type="error">
<template #content>
{{ t("updateAppointmentErrorText") }}
</template>

<template #header>{{ t("updateAppointmentErrorHeader") }}</template>
</muc-callout>
</div>
</div>
</div>
<div
Expand Down Expand Up @@ -92,6 +122,7 @@ import { MucCallout, MucStepper } from "@muenchen/muc-patternlab-vue";
import { onMounted, provide, ref, watch } from "vue";
import { AppointmentDTO } from "@/api/models/AppointmentDTO";
import { ErrorDTO } from "@/api/models/ErrorDTO";
import {
confirmAppointment,
preconfirmAppointment,
Expand Down Expand Up @@ -164,7 +195,9 @@ const selectedTimeslot = ref<number>(0);
const customerData = ref<CustomerData>(new CustomerData("", "", "", "", ""));
const appointment = ref<AppointmentImpl>();
const appointmentNotAvailableError = ref<boolean>(false);
const updateAppointmentError = ref<boolean>(false);
const tooManyAppointmentsWithSameMailError = ref<boolean>(false);
const confirmAppointmentSuccess = ref<boolean>(false);
const confirmAppointmentError = ref<boolean>(false);
Expand Down Expand Up @@ -221,7 +254,6 @@ const setServices = () => {
};
const nextReserveAppointment = () => {
increaseCurrentView();
reserveAppointment(
selectedTimeslot.value,
Array.from(selectedServiceMap.value.keys()),
Expand All @@ -230,8 +262,11 @@ const nextReserveAppointment = () => {
).then((data) => {
if ((data as AppointmentDTO).processId !== undefined) {
appointment.value = data as AppointmentDTO;
increaseCurrentView();
} else {
// error.value = true;
if ((data as ErrorDTO).errorCode === "appointmentNotAvailable") {
appointmentNotAvailableError.value = true;
}
}
});
};
Expand All @@ -252,7 +287,13 @@ const nextUpdateAppointment = () => {
if ((data as AppointmentDTO).processId !== undefined) {
appointment.value = data as AppointmentDTO;
} else {
updateAppointmentError.value = true;
if (
(data as ErrorDTO).errorCode === "tooManyAppointmentsWithSameMail"
) {
tooManyAppointmentsWithSameMailError.value = true;
} else {
updateAppointmentError.value = true;
}
}
increaseCurrentView();
});
Expand Down
4 changes: 4 additions & 0 deletions zmscitizenview/src/utils/de-DE.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,15 @@
"remarks": "Bemerkungen",
"remarkCompletionInstructions": "Sie möchten uns zu Ihrem Termin noch etwas mitteilen? Geben Sie hier an, wenn Sie Hilfe benötigen, auf Übersetzungen angewiesen sind oder sonstige Anliegen haben.",
"selectedAppointment": "Ausgewählter Termin",
"selectedDateNoLongerAvailableHeader": "Ihr gewählter Termin ist nicht mehr verfügbar.",
"selectedDateNoLongerAvailableText": "Leider hat inzwischen eine andere Person Ihren gewünschten Termin gebucht. Bitte wählen Sie einen neuen Termin aus.",
"service": "Leistung",
"serviceSearch": "Bürgerservice-Suche",
"telephoneNumber": "Telefonnummer",
"termsOfUse": "Einwilligungen",
"time": "Zeit",
"tooManyAppointmentsWithSameMailErrorHeader": "Sie haben bereits zu viele Termine gebucht.",
"tooManyAppointmentsWithSameMailErrorText": "Sie können mit Ihrer E-Mail-Adresse höchstens drei Termine auf einmal vereinbaren. Bitte sagen Sie einen anderen Termin ab, bevor Sie einen neuen Termin buchen.",
"updateAppointmentErrorHeader": "Terminupdate fehlgeschlagen",
"updateAppointmentErrorText": "Terminupdate fehlgeschlagen.",
"your": "Ihr",
Expand Down
4 changes: 4 additions & 0 deletions zmscitizenview/src/utils/en-US.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,15 @@
"remarks": "Remarks",
"remarkCompletionInstructions": "Would you like to tell us something else about your appointment? Please indicate here if you need help, require translations or have any other concerns.",
"selectedAppointment": "Selected Appointment",
"selectedDateNoLongerAvailableHeader": "Your selected date is no longer available.",
"selectedDateNoLongerAvailableText": "Unfortunately, another person has now booked your desired appointment. Please select a new date.",
"service": "Service",
"serviceSearch": "Search for citizen services",
"telephoneNumber": "Telephone number",
"termsOfUse": "Terms of Use",
"time": "Zeit",
"tooManyAppointmentsWithSameMailErrorHeader": "You have already booked too many appointments.",
"tooManyAppointmentsWithSameMailErrorText": "You can book a maximum of three appointments at once with your e-mail address. Please cancel another appointment before you book a new one.",
"updateAppointmentErrorHeader": "Appointment update failed.",
"updateAppointmentErrorText": "Appointment update failed.",
"your": "Ihr",
Expand Down

0 comments on commit c192ef0

Please sign in to comment.