|
|
|
@@ -1,4 +1,4 @@ |
|
|
|
// import {toast} from "react-toastify"; |
|
|
|
import { toast } from "react-toastify"; |
|
|
|
import DialogTitle from "@mui/material/DialogTitle"; |
|
|
|
import DialogContent from "@mui/material/DialogContent"; |
|
|
|
import DialogContentText from "@mui/material/DialogContentText"; |
|
|
|
@@ -82,71 +82,69 @@ export function getDateString(queryDateArray) { |
|
|
|
) |
|
|
|
} |
|
|
|
|
|
|
|
const NOTIFICATION_EVENT_NAME = "pnsps-notification"; |
|
|
|
|
|
|
|
const dispatchNotification = (type, message) => { |
|
|
|
window.dispatchEvent( |
|
|
|
new CustomEvent(NOTIFICATION_EVENT_NAME, { |
|
|
|
detail: { |
|
|
|
type, |
|
|
|
message |
|
|
|
} |
|
|
|
}) |
|
|
|
); |
|
|
|
const manualCloseToastOptions = { |
|
|
|
position: "bottom-right", |
|
|
|
autoClose: 30000, |
|
|
|
hideProgressBar: false, |
|
|
|
closeOnClick: true, |
|
|
|
pauseOnHover: true, |
|
|
|
draggable: true, |
|
|
|
progress: undefined, |
|
|
|
theme: "light", |
|
|
|
}; |
|
|
|
|
|
|
|
export const notifySaveSuccess = () => { |
|
|
|
const userType = JSON.parse(localStorage.getItem("userData")).type; |
|
|
|
const msg = userType === "GLD" ? "Save success!" : "儲存成功!"; |
|
|
|
dispatchNotification("success", msg); |
|
|
|
toast.success(msg, manualCloseToastOptions); |
|
|
|
}; |
|
|
|
|
|
|
|
export const notifyCreateSuccess = () => { |
|
|
|
const userType = JSON.parse(localStorage.getItem("userData")).type; |
|
|
|
const msg = userType === "GLD" ? "Create success!" : "創建成功!"; |
|
|
|
dispatchNotification("success", msg); |
|
|
|
toast.success(msg, manualCloseToastOptions); |
|
|
|
}; |
|
|
|
|
|
|
|
export const notifyVerifySuccess = () => { |
|
|
|
const userType = JSON.parse(localStorage.getItem("userData")).type; |
|
|
|
const msg = userType === "GLD" ? "Verify success!" : "驗證成功!"; |
|
|
|
dispatchNotification("success", msg); |
|
|
|
toast.success(msg, manualCloseToastOptions); |
|
|
|
}; |
|
|
|
|
|
|
|
export const notifyDeleteSuccess = () => { |
|
|
|
const userType = JSON.parse(localStorage.getItem("userData")).type; |
|
|
|
const msg = userType === "GLD" ? "Delete success!" : "刪除成功!"; |
|
|
|
dispatchNotification("success", msg); |
|
|
|
toast.success(msg, manualCloseToastOptions); |
|
|
|
}; |
|
|
|
|
|
|
|
export const notifyLockSuccess = () => { |
|
|
|
dispatchNotification("success", "Lock success!"); |
|
|
|
toast.success("Lock success!", manualCloseToastOptions); |
|
|
|
}; |
|
|
|
|
|
|
|
export const notifyUnlockSuccess = () => { |
|
|
|
dispatchNotification("success", "Unlock success!"); |
|
|
|
toast.success("Unlock success!", manualCloseToastOptions); |
|
|
|
}; |
|
|
|
|
|
|
|
export const notifyActiveSuccess = () => { |
|
|
|
dispatchNotification("success", "Active success!"); |
|
|
|
toast.success("Active success!", manualCloseToastOptions); |
|
|
|
}; |
|
|
|
|
|
|
|
export const notifyDownloadSuccess = () => { |
|
|
|
const userType = JSON.parse(localStorage.getItem("userData")).type; |
|
|
|
const msg = userType === "GLD" ? "Download success!" : "下載成功!"; |
|
|
|
dispatchNotification("success", msg); |
|
|
|
toast.success(msg, manualCloseToastOptions); |
|
|
|
}; |
|
|
|
|
|
|
|
export const notifyActionSuccess = (actionMsg) => { |
|
|
|
dispatchNotification("success", actionMsg ?? "Success"); |
|
|
|
toast.success(actionMsg ?? "Success", manualCloseToastOptions); |
|
|
|
}; |
|
|
|
|
|
|
|
export const notifyActionError = (actionMsg) => { |
|
|
|
dispatchNotification("error", `${actionMsg}`); |
|
|
|
toast.error(`${actionMsg}`, manualCloseToastOptions); |
|
|
|
}; |
|
|
|
|
|
|
|
export const notifyActionWarning = (actionMsg) => { |
|
|
|
dispatchNotification("warning", `${actionMsg}`); |
|
|
|
toast.warn(`${actionMsg}`, manualCloseToastOptions); |
|
|
|
} |
|
|
|
|
|
|
|
export function prettyJson(json) { |
|
|
|
|