CFE-6 bug fix toast and make better flow for remove and add toast in page
This commit is contained in:
@@ -1,10 +1,8 @@
|
||||
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 = (notificationType, t, status, message) => {
|
||||
const {pushToastList} = useToast();
|
||||
const ErrorNotification = (pushToastList, notificationType, t, status, message) => {
|
||||
const toastId = toast(
|
||||
() => (
|
||||
<>
|
||||
|
||||
@@ -1,9 +1,6 @@
|
||||
import {toast} from "react-toastify";
|
||||
import useToast from "@/lib/app/hooks/useToast";
|
||||
|
||||
const PendingNotification = (notificationType, t) => {
|
||||
const {pushToastList} = useToast();
|
||||
|
||||
const PendingNotification = (pushToastList, notificationType, t) => {
|
||||
const toastId = toast(t("notifications.pending"), {
|
||||
containerId: 'validation',
|
||||
autoClose: false,
|
||||
|
||||
@@ -2,7 +2,7 @@ import BeenhereIcon from "@mui/icons-material/Beenhere";
|
||||
import {Box, Typography} from "@mui/material";
|
||||
import {toast} from "react-toastify";
|
||||
|
||||
const SuccessNotification = (notificationType, t, status) => {
|
||||
const SuccessNotification = (pushToastList, notificationType, t, status) => {
|
||||
const toastId = toast(
|
||||
() => (
|
||||
<>
|
||||
@@ -38,7 +38,7 @@ const SuccessNotification = (notificationType, t, status) => {
|
||||
draggable: true,
|
||||
}
|
||||
);
|
||||
notification_type_id.success.push(toastId);
|
||||
pushToastList(notificationType, toastId);
|
||||
};
|
||||
|
||||
export default SuccessNotification;
|
||||
@@ -2,7 +2,7 @@ import ReportIcon from "@mui/icons-material/Report";
|
||||
import {Box, Typography} from "@mui/material";
|
||||
import {toast} from "react-toastify";
|
||||
|
||||
const WarningNotification = (notificationType, t, status) => {
|
||||
const WarningNotification = (pushToastList, notificationType, t, status) => {
|
||||
const toastId = toast(
|
||||
() => (
|
||||
<>
|
||||
@@ -36,7 +36,7 @@ const WarningNotification = (notificationType, t, status) => {
|
||||
draggable: false,
|
||||
}
|
||||
);
|
||||
notification_type_id.warning.push(toastId);
|
||||
pushToastList(notificationType, toastId);
|
||||
};
|
||||
|
||||
export default WarningNotification;
|
||||
@@ -3,23 +3,23 @@ import WarningNotification from "@/core/components/notifications/WarningNotifica
|
||||
import ErrorNotification from "@/core/components/notifications/ErrorNotification";
|
||||
import SuccessNotification from "@/core/components/notifications/SuccessNotification";
|
||||
|
||||
const Notifications = (notificationType, t, status, message) => {
|
||||
const Notifications = (pushToastList, notificationType, t, status, message) => {
|
||||
switch (notificationType) {
|
||||
case "pending":
|
||||
pendingNotification(notificationType, t);
|
||||
pendingNotification(pushToastList, notificationType, t);
|
||||
break;
|
||||
case "warning":
|
||||
WarningNotification(notificationType, t, status);
|
||||
WarningNotification(pushToastList, notificationType, t, status);
|
||||
break;
|
||||
case "error":
|
||||
if (message) {
|
||||
ErrorNotification(notificationType, t, status, message)
|
||||
ErrorNotification(pushToastList, notificationType, t, status, message)
|
||||
} else {
|
||||
ErrorNotification(notificationType, t, status)
|
||||
ErrorNotification(pushToastList, notificationType, t, status)
|
||||
}
|
||||
break;
|
||||
case "success":
|
||||
SuccessNotification(notificationType, t, status);
|
||||
SuccessNotification(pushToastList, notificationType, t, status);
|
||||
break;
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user