From ffe42d2a74596b92453dc8025f3684f3e041ada8 Mon Sep 17 00:00:00 2001 From: alex Date: Thu, 25 Jan 2024 22:24:04 +0100 Subject: [PATCH] notifications --- public/locales/de/translation.json | 13 +++++++-- public/locales/en/translation.json | 9 +++++- src/Pages/Store/Calendar/index.js | 47 +++++++++++++++++++----------- src/Pages/Store/Employees/index.js | 22 +++++++++----- src/Pages/Store/Services/index.js | 42 ++++++++++++++------------ src/utils.js | 2 -- 6 files changed, 86 insertions(+), 49 deletions(-) diff --git a/public/locales/de/translation.json b/public/locales/de/translation.json index eb7fa50..3350525 100644 --- a/public/locales/de/translation.json +++ b/public/locales/de/translation.json @@ -130,12 +130,13 @@ "serviceActivityDescription": "Beschreibung der Tätigkeit", "serviceActivityDescriptionPlaceholder": "Geben Sie die Beschreibung der Tätigkeit ein", "serviceActivityPrice": "Preis der Tätigkeit", - "serviceActivityPricePlaceholder": "Geben Sie den Preis der Tätigkeit ein", + "serviceActivityPricePlaceholder": "20", "serviceActivityPriceUnit": "€", "serviceActivityDurationMinutes": "Dauer der Tätigkeit", - "serviceActivityDurationMinutesPlaceholder": "Geben Sie die Dauer der Tätigkeit in Minuten ein", + "serviceActivityDurationMinutesPlaceholder": "15", "serviceActivityDurationMinutesUnit": "Minuten", "serviceActivityResponsible": "Verantwortliche Mitarbeiter", + "serviceActivityResponsibleDescription": "Geben Sie für diese Tätigkeit geeignete Mitarbeiter an, die diese Tätigkeit durchführen können. Diese werden Kunden bei der Buchung dieser Tätigkeit als Auswahlmöglichkeit angezeigt.", "inputRules": { "serviceNameRequired": "Name der Dienstleistung ist erforderlich", "serviceNameMinLength": "Name der Dienstleistung muss mindestens {{minLength}} Zeichen lang sein", @@ -196,7 +197,13 @@ "title": "Google Kalender trennen", "description": "Aus Sicherheitsgründen müssen Sie Ihr Passwort eingeben, um die Verbindung zu Ihrem Google Kalender zu trennen.", "checkboxDeleteCalendars": "Kalender für Öffnungszeiten und Termine löschen (Alle Termine werden gelöscht und können nicht wiederhergestellt werden)", - "button": "Google Kalender trennen" + "button": "Google Kalender trennen", + "request": { + "400": { + "title": "Passwort ungültig", + "description": "Bitte überprüfen Sie Ihr Passwort und versuchen Sie es erneut." + } + } }, "calendarFrameCustomerView": "Terminkalenderansicht der Kunden" }, diff --git a/public/locales/en/translation.json b/public/locales/en/translation.json index 3cf0136..172844f 100644 --- a/public/locales/en/translation.json +++ b/public/locales/en/translation.json @@ -139,6 +139,7 @@ "serviceActivityDurationMinutesPlaceholder": "Enter the duration of the activity in minutes", "serviceActivityDurationMinutesUnit": "Minutes", "serviceActivityResponsible": "Responsible employees", + "serviceActivityResponsibleDescription": "Specify suitable employees who can carry out this activity. These are displayed to customers as a selection option when booking this activity.", "inputRules": { "serviceNameRequired": "Service name is required", "serviceNameMinLength": "Service name must be at least {{minLength}} characters long", @@ -199,7 +200,13 @@ "title": "Unlink Google Calendar", "description": "For security reasons, you need to enter your password to unlink your Google Calendar.", "checkboxDeleteCalendars": "Delete calendar for opening hours and appointments (all appointments are deleted and cannot be restored)", - "button": "Unlink Google Calendar" + "button": "Unlink Google Calendar", + "request": { + "400": { + "title": "Password incorrect", + "description": "Please check your password and try again." + } + } }, "calendarFrameCustomerView": "Appointment diary view of customers" }, diff --git a/src/Pages/Store/Calendar/index.js b/src/Pages/Store/Calendar/index.js index e6ec25c..7414157 100644 --- a/src/Pages/Store/Calendar/index.js +++ b/src/Pages/Store/Calendar/index.js @@ -18,6 +18,7 @@ import { EncodeStringToBase64, getUserSessionFromLocalStorage, myFetch, + showInputsInvalidNotification, } from "../../../utils"; import { useEffect, useRef, useState } from "react"; import MyCenteredContainer from "../../../Components/MyContainer"; @@ -310,25 +311,37 @@ function CardPersonalCalendarSettings({ settings }) { onCancel={handleModalClose} isConfirmButtonLoading={isRequesting} onConfirm={() => { - formUnlinkCalendar.validateFields().then((values) => { - setIsRequesting(true); + formUnlinkCalendar + .validateFields() + .then((values) => { + setIsRequesting(true); - myFetch({ - url: "/calendar/settings/personal/unlink", - method: "POST", - body: { - password: EncodeStringToBase64(values.password), - }, - notificationApi: notificationApi, - t: t, + myFetch({ + url: "/calendar/settings/personal/unlink", + method: "POST", + body: { + password: EncodeStringToBase64(values.password), + }, + notificationApi: notificationApi, + t: t, + }) + .then(() => window.location.reload()) + .catch((errStatus) => { + setIsRequesting(false); + + if (errStatus === 400) { + notificationApi["error"]({ + message: t( + "calendar.unlinkGoogleCalendar.request.400.title" + ), + description: t( + "calendar.unlinkGoogleCalendar.request.400.description" + ), + }); + } + }); }) - .then(() => window.location.reload()) - .catch((errStatus) => { - console.log(errStatus); - setIsRequesting(false); - // TODO: show error message - }); - }); + .catch(() => showInputsInvalidNotification(notificationApi, t)); }} /> } diff --git a/src/Pages/Store/Employees/index.js b/src/Pages/Store/Employees/index.js index 6a67c9c..d5fc4ae 100644 --- a/src/Pages/Store/Employees/index.js +++ b/src/Pages/Store/Employees/index.js @@ -13,7 +13,11 @@ import MyModal, { MyModalCloseSaveButtonFooter, } from "../../../Components/MyModal"; import { useEffect, useState } from "react"; -import { myFetch, EncodeStringToBase64 } from "../../../utils"; +import { + myFetch, + EncodeStringToBase64, + showInputsInvalidNotification, +} from "../../../utils"; import { useTranslation } from "react-i18next"; import MyTable from "../../../Components/MyTable"; import { @@ -198,6 +202,8 @@ function ModalAddEditEmployee({ fetchEmployees, }) { const { t } = useTranslation(); + const [notificationApi, notificationContextHolder] = + notification.useNotification(); const { storeId } = useParams(); const screenBreakpoint = useBreakpoint(); const [form] = Form.useForm(); @@ -240,6 +246,8 @@ function ModalAddEditEmployee({ return ( <> + {notificationContextHolder} +