notifications

master
alex 2024-01-25 22:24:04 +01:00
parent a8f6f75d28
commit ffe42d2a74
6 changed files with 86 additions and 49 deletions

View File

@ -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"
},

View File

@ -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"
},

View File

@ -18,6 +18,7 @@ import {
EncodeStringToBase64,
getUserSessionFromLocalStorage,
myFetch,
showInputsInvalidNotification,
} from "../../../utils";
import { useEffect, useRef, useState } from "react";
import MyCenteredContainer from "../../../Components/MyContainer";
@ -310,7 +311,9 @@ function CardPersonalCalendarSettings({ settings }) {
onCancel={handleModalClose}
isConfirmButtonLoading={isRequesting}
onConfirm={() => {
formUnlinkCalendar.validateFields().then((values) => {
formUnlinkCalendar
.validateFields()
.then((values) => {
setIsRequesting(true);
myFetch({
@ -324,11 +327,21 @@ function CardPersonalCalendarSettings({ settings }) {
})
.then(() => window.location.reload())
.catch((errStatus) => {
console.log(errStatus);
setIsRequesting(false);
// TODO: show error message
if (errStatus === 400) {
notificationApi["error"]({
message: t(
"calendar.unlinkGoogleCalendar.request.400.title"
),
description: t(
"calendar.unlinkGoogleCalendar.request.400.description"
),
});
}
});
})
.catch(() => showInputsInvalidNotification(notificationApi, t));
}}
/>
}

View File

@ -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}
<Button
type="primary"
block={screenBreakpoint.xs}
@ -312,9 +320,9 @@ function ModalAddEditEmployee({
setIsRequesting(false);
});
})
.catch((info) => {
console.log("Validate Failed:", info);
});
.catch(() =>
showInputsInvalidNotification(notificationApi, t)
);
}}
/>
) : (
@ -404,9 +412,9 @@ function ModalAddEditEmployee({
setIsRequesting(false);
});
})
.catch((info) => {
console.log("Validate Failed:", info);
});
.catch(() =>
showInputsInvalidNotification(notificationApi, t)
);
}}
/>
)

View File

@ -1,4 +1,4 @@
import { PlusOutlined } from "@ant-design/icons";
import { InfoCircleOutlined, PlusOutlined } from "@ant-design/icons";
import {
Avatar,
Button,
@ -15,7 +15,11 @@ import {
} from "antd";
import { useTranslation } from "react-i18next";
import { useEffect, useState } from "react";
import { Constants, myFetch } from "../../../utils";
import {
Constants,
myFetch,
showInputsInvalidNotification,
} from "../../../utils";
import { useParams } from "react-router-dom";
import MyModal, {
MyModalCloseCreateButtonFooter,
@ -468,6 +472,7 @@ function ModalAddEditService({
setAddEditServiceModalOptions({
...addEditServiceModalOptions,
isOpen: false,
mode: "add",
});
form.resetFields();
@ -521,7 +526,7 @@ function ModalAddEditService({
setIsRequesting(true);
myFetch({
url: "/store/services",
url: "/store/services/service",
method: "POST",
body: {
storeId: storeId,
@ -540,9 +545,9 @@ function ModalAddEditService({
console.log(errStatus);
});
})
.catch((info) => {
console.log("Validate Failed:", info);
});
.catch(() =>
showInputsInvalidNotification(notificationApi, t)
);
}}
/>
) : (
@ -585,9 +590,9 @@ function ModalAddEditService({
console.log(errStatus);
});
})
.catch((info) => {
console.log("Validate Failed:", info);
});
.catch(() =>
showInputsInvalidNotification(notificationApi, t)
);
}}
/>
)
@ -665,10 +670,6 @@ function ModalAddEditServiceActivity({
)
);
} else {
form.setFieldsValue({
serviceActivityDurationHours: 0,
});
setSelectedEmployeesRowKeys(users.map((user) => user.user_id));
}
}, [addEditServiceActivityModalOptions.isOpen]);
@ -724,9 +725,9 @@ function ModalAddEditServiceActivity({
console.log(errStatus);
});
})
.catch((info) => {
console.log("Validate Failed:", info);
});
.catch(() =>
showInputsInvalidNotification(notificationApi, t)
);
}}
/>
) : (
@ -830,9 +831,9 @@ function ModalAddEditServiceActivity({
console.log(errStatus);
});
})
.catch((info) => {
console.log("Validate Failed:", info);
});
.catch(() =>
showInputsInvalidNotification(notificationApi, t)
);
}}
/>
)
@ -851,6 +852,9 @@ function ModalAddEditServiceActivity({
<Typography.Text>
{t("storeServices.serviceActivityResponsible")}
</Typography.Text>
<Typography.Text type="secondary">
{t("storeServices.serviceActivityResponsibleDescription")}
</Typography.Text>
<MyTable
props={{

View File

@ -200,8 +200,6 @@ export function myFetch({
//window.location.href = "/";
}
console.warn("response status", response.status);
throw response.status;
}