CFE-6 debugging notifications

This commit is contained in:
2023-10-29 17:42:31 +03:30
parent ae5313ef2d
commit 3be39d451c
12 changed files with 89 additions and 114 deletions

View File

@@ -29,6 +29,7 @@ const ErrorNotification = (t, status, message) => {
</>
),
{
containerId: 'validation',
autoClose: false,
closeOnClick: false,
draggable: false,

View File

@@ -1,12 +1,14 @@
import {toast} from "react-toastify";
let a = {pending: []}
const PendingNotification = (t) => {
toast(t("notifications.pending"), {
containerId: 'validation',
autoClose: false,
closeButton: false,
closeOnClick: false,
draggable: false,
});
})
};
export default PendingNotification;

View File

@@ -30,6 +30,7 @@ const SuccessNotification = (t, status) => {
</>
),
{
containerId: 'validation',
autoClose: 3000,
hideProgressBar: true,
pauseOnHover: true,

View File

@@ -26,6 +26,8 @@ const UploadFileNotification = (t) => {
</>
),
{
containerId: 'validation',
toastId: 'upload',
autoClose: 3000,
hideProgressBar: true,
pauseOnHover: true,

View File

@@ -30,6 +30,7 @@ const WarningNotification = (t, status) => {
</>
),
{
containerId: 'validation',
autoClose: false,
closeOnClick: false,
draggable: false,

View File

@@ -1,54 +1,25 @@
import {toast} from "react-toastify";
import ErrorNotification from "./ErrorNotification";
import WarningNotification from "./WarningNotification";
import SuccessNotification from "./SuccessNotification";
import pendingNotification from "@/core/components/notifications/PendingNotification";
import WarningNotification from "@/core/components/notifications/WarningNotification";
import ErrorNotification from "@/core/components/notifications/ErrorNotification";
import SuccessNotification from "@/core/components/notifications/SuccessNotification";
const Notifications = async (t, response) => {
const {status, data} = response != undefined ? response : ""
toast.dismiss();
switch (status) {
case 200:
SuccessNotification(t, status);
break;
case 400:
ErrorNotification(t, status);
break;
case 401:
ErrorNotification(t, status);
break;
case 403:
ErrorNotification(t, status);
break;
case 422:
ErrorNotification(t, status, data.message);
break;
case 500:
WarningNotification(t, status);
break;
case 503:
WarningNotification(t, status);
break;
case 504:
WarningNotification(t, status);
break;
default:
toast(t("notifications.pending"), {
autoClose: false,
closeOnClick: false,
draggable: false,
});
break;
const Notifications = (notificationType, t, status, message) => {
let notification_type_id = {
pending: [],
error: [],
warning: [],
success: []
}
if (notificationType === "pending") {
pendingNotification(t);
} else if (notificationType === "warning") {
WarningNotification(t, status);
} else if (notificationType === "error") {
message ? ErrorNotification(t, status, message) : ErrorNotification(t, status);
} else if (notificationType === "success") {
SuccessNotification(t, status);
}
};
export default Notifications;
/*
usage document
** for pending use ( Notifications( t, undefined) ) this before your request.
** for success use ( Notifications( t, response) ) this inside .then() of your request.
** for Error and Warning use ( Notifications( t, error.response) ) this inside .catche() of your request.
end usage document
*/