|
|
|
@@ -6,7 +6,6 @@ import DialogActions from "@mui/material/DialogActions"; |
|
|
|
import { Button } from "@mui/material"; |
|
|
|
import Dialog from "@mui/material/Dialog"; |
|
|
|
import * as React from "react"; |
|
|
|
import { toast } from "react-toastify"; |
|
|
|
|
|
|
|
export const clickableLink=(link, label)=> { |
|
|
|
return <a href={link}>{label}</a>; |
|
|
|
@@ -83,152 +82,71 @@ export function getDateString(queryDateArray) { |
|
|
|
) |
|
|
|
} |
|
|
|
|
|
|
|
const NOTIFICATION_EVENT_NAME = "pnsps-notification"; |
|
|
|
|
|
|
|
const dispatchNotification = (type, message) => { |
|
|
|
window.dispatchEvent( |
|
|
|
new CustomEvent(NOTIFICATION_EVENT_NAME, { |
|
|
|
detail: { |
|
|
|
type, |
|
|
|
message |
|
|
|
} |
|
|
|
}) |
|
|
|
); |
|
|
|
}; |
|
|
|
|
|
|
|
export const notifySaveSuccess = () => { |
|
|
|
const userType = JSON.parse(localStorage.getItem("userData")).type |
|
|
|
toast.success(userType === "GLD" ? 'Save success!' : "儲存成功!", { |
|
|
|
position: "bottom-right", |
|
|
|
autoClose: 5000, |
|
|
|
hideProgressBar: false, |
|
|
|
closeOnClick: true, |
|
|
|
pauseOnHover: true, |
|
|
|
draggable: true, |
|
|
|
progress: undefined, |
|
|
|
theme: "light", |
|
|
|
}) |
|
|
|
const userType = JSON.parse(localStorage.getItem("userData")).type; |
|
|
|
const msg = userType === "GLD" ? "Save success!" : "儲存成功!"; |
|
|
|
dispatchNotification("success", msg); |
|
|
|
}; |
|
|
|
|
|
|
|
export const notifyCreateSuccess = () => { |
|
|
|
const userType = JSON.parse(localStorage.getItem("userData")).type |
|
|
|
toast.success(userType === "GLD" ? 'Create success!' : "創建成功!", { |
|
|
|
position: "bottom-right", |
|
|
|
autoClose: 5000, |
|
|
|
hideProgressBar: false, |
|
|
|
closeOnClick: true, |
|
|
|
pauseOnHover: true, |
|
|
|
draggable: true, |
|
|
|
progress: undefined, |
|
|
|
theme: "light", |
|
|
|
}) |
|
|
|
const userType = JSON.parse(localStorage.getItem("userData")).type; |
|
|
|
const msg = userType === "GLD" ? "Create success!" : "創建成功!"; |
|
|
|
dispatchNotification("success", msg); |
|
|
|
}; |
|
|
|
|
|
|
|
export const notifyVerifySuccess = () => { |
|
|
|
const userType = JSON.parse(localStorage.getItem("userData")).type |
|
|
|
toast.success(userType === "GLD" ? 'Verify success!' : "驗證成功!", { |
|
|
|
position: "bottom-right", |
|
|
|
autoClose: 5000, |
|
|
|
hideProgressBar: false, |
|
|
|
closeOnClick: true, |
|
|
|
pauseOnHover: true, |
|
|
|
draggable: true, |
|
|
|
progress: undefined, |
|
|
|
theme: "light", |
|
|
|
}) |
|
|
|
const userType = JSON.parse(localStorage.getItem("userData")).type; |
|
|
|
const msg = userType === "GLD" ? "Verify success!" : "驗證成功!"; |
|
|
|
dispatchNotification("success", msg); |
|
|
|
}; |
|
|
|
|
|
|
|
export const notifyDeleteSuccess = () => { |
|
|
|
const userType = JSON.parse(localStorage.getItem("userData")).type |
|
|
|
toast.success(userType === "GLD" ? 'Delete success!' : "刪除成功!", { |
|
|
|
position: "bottom-right", |
|
|
|
autoClose: 5000, |
|
|
|
hideProgressBar: false, |
|
|
|
closeOnClick: true, |
|
|
|
pauseOnHover: true, |
|
|
|
draggable: true, |
|
|
|
progress: undefined, |
|
|
|
theme: "light", |
|
|
|
}) |
|
|
|
const userType = JSON.parse(localStorage.getItem("userData")).type; |
|
|
|
const msg = userType === "GLD" ? "Delete success!" : "刪除成功!"; |
|
|
|
dispatchNotification("success", msg); |
|
|
|
}; |
|
|
|
|
|
|
|
export const notifyLockSuccess = () => { |
|
|
|
toast.success('Lock success!', { |
|
|
|
position: "bottom-right", |
|
|
|
autoClose: 5000, |
|
|
|
hideProgressBar: false, |
|
|
|
closeOnClick: true, |
|
|
|
pauseOnHover: true, |
|
|
|
draggable: true, |
|
|
|
progress: undefined, |
|
|
|
theme: "light", |
|
|
|
}) |
|
|
|
dispatchNotification("success", "Lock success!"); |
|
|
|
}; |
|
|
|
|
|
|
|
export const notifyUnlockSuccess = () => { |
|
|
|
toast.success('Unlock success!', { |
|
|
|
position: "bottom-right", |
|
|
|
autoClose: 5000, |
|
|
|
hideProgressBar: false, |
|
|
|
closeOnClick: true, |
|
|
|
pauseOnHover: true, |
|
|
|
draggable: true, |
|
|
|
progress: undefined, |
|
|
|
theme: "light", |
|
|
|
}) |
|
|
|
dispatchNotification("success", "Unlock success!"); |
|
|
|
}; |
|
|
|
|
|
|
|
export const notifyActiveSuccess = () => { |
|
|
|
toast.success('Active success!', { |
|
|
|
position: "bottom-right", |
|
|
|
autoClose: 5000, |
|
|
|
hideProgressBar: false, |
|
|
|
closeOnClick: true, |
|
|
|
pauseOnHover: true, |
|
|
|
draggable: true, |
|
|
|
progress: undefined, |
|
|
|
theme: "light", |
|
|
|
}) |
|
|
|
dispatchNotification("success", "Active success!"); |
|
|
|
}; |
|
|
|
|
|
|
|
export const notifyDownloadSuccess = () => { |
|
|
|
const userType = JSON.parse(localStorage.getItem("userData")).type |
|
|
|
toast.success(userType === "GLD" ? 'Download success!' : "下載成功!", { |
|
|
|
position: "bottom-right", |
|
|
|
autoClose: 5000, |
|
|
|
hideProgressBar: false, |
|
|
|
closeOnClick: true, |
|
|
|
pauseOnHover: true, |
|
|
|
draggable: true, |
|
|
|
progress: undefined, |
|
|
|
theme: "light", |
|
|
|
}) |
|
|
|
const userType = JSON.parse(localStorage.getItem("userData")).type; |
|
|
|
const msg = userType === "GLD" ? "Download success!" : "下載成功!"; |
|
|
|
dispatchNotification("success", msg); |
|
|
|
}; |
|
|
|
|
|
|
|
export const notifyActionSuccess = (actionMsg) => { |
|
|
|
toast.success(actionMsg??"Success", { |
|
|
|
position: "bottom-right", |
|
|
|
autoClose: 5000, |
|
|
|
hideProgressBar: false, |
|
|
|
closeOnClick: true, |
|
|
|
pauseOnHover: true, |
|
|
|
draggable: true, |
|
|
|
progress: undefined, |
|
|
|
theme: "light", |
|
|
|
}) |
|
|
|
dispatchNotification("success", actionMsg ?? "Success"); |
|
|
|
}; |
|
|
|
|
|
|
|
export const notifyActionError = (actionMsg) => { |
|
|
|
toast.error(`${actionMsg}`, { |
|
|
|
position: "bottom-right", |
|
|
|
autoClose: 20000, |
|
|
|
hideProgressBar: false, |
|
|
|
closeOnClick: true, |
|
|
|
pauseOnHover: true, |
|
|
|
draggable: true, |
|
|
|
progress: undefined, |
|
|
|
theme: "light", |
|
|
|
}) |
|
|
|
dispatchNotification("error", `${actionMsg}`); |
|
|
|
}; |
|
|
|
|
|
|
|
export const notifyActionWarning = (actionMsg) => { |
|
|
|
toast.warn(`${actionMsg}`, { |
|
|
|
position: "bottom-right", |
|
|
|
autoClose: 5000, |
|
|
|
hideProgressBar: false, |
|
|
|
closeOnClick: true, |
|
|
|
pauseOnHover: true, |
|
|
|
draggable: true, |
|
|
|
progress: undefined, |
|
|
|
theme: "light", |
|
|
|
}) |
|
|
|
dispatchNotification("warning", `${actionMsg}`); |
|
|
|
} |
|
|
|
|
|
|
|
export function prettyJson(json) { |
|
|
|
|