CFE-6 notification bug fix

This commit is contained in:
2023-10-30 16:35:08 +03:30
parent 3be39d451c
commit 73ca237817
10 changed files with 102 additions and 36 deletions

View File

@@ -1,9 +1,11 @@
import DangerousIcon from "@mui/icons-material/Dangerous";
import {Box, Typography} from "@mui/material";
import {toast} from "react-toastify";
import useToast from "@/lib/app/hooks/useToast";
const ErrorNotification = (t, status, message) => {
toast(
const ErrorNotification = (notificationType, t, status, message) => {
const {pushToastList} = useToast();
const toastId = toast(
() => (
<>
<Box
@@ -35,6 +37,7 @@ const ErrorNotification = (t, status, message) => {
draggable: false,
}
);
pushToastList(notificationType, toastId);
};
export default ErrorNotification;

View File

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

View File

@@ -2,8 +2,8 @@ import BeenhereIcon from "@mui/icons-material/Beenhere";
import {Box, Typography} from "@mui/material";
import {toast} from "react-toastify";
const SuccessNotification = (t, status) => {
toast(
const SuccessNotification = (notificationType, t, status) => {
const toastId = toast(
() => (
<>
<Box
@@ -38,6 +38,7 @@ const SuccessNotification = (t, status) => {
draggable: true,
}
);
notification_type_id.success.push(toastId);
};
export default SuccessNotification;

View File

@@ -2,8 +2,8 @@ import ReportIcon from "@mui/icons-material/Report";
import {Box, Typography} from "@mui/material";
import {toast} from "react-toastify";
const WarningNotification = (t, status) => {
toast(
const WarningNotification = (notificationType, t, status) => {
const toastId = toast(
() => (
<>
<Box
@@ -36,6 +36,7 @@ const WarningNotification = (t, status) => {
draggable: false,
}
);
notification_type_id.warning.push(toastId);
};
export default WarningNotification;

View File

@@ -4,21 +4,23 @@ import ErrorNotification from "@/core/components/notifications/ErrorNotification
import SuccessNotification from "@/core/components/notifications/SuccessNotification";
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);
switch (notificationType) {
case "pending":
pendingNotification(notificationType, t);
break;
case "warning":
WarningNotification(notificationType, t, status);
break;
case "error":
if (message) {
ErrorNotification(notificationType, t, status, message)
} else {
ErrorNotification(notificationType, t, status)
}
break;
case "success":
SuccessNotification(notificationType, t, status);
break;
}
};