// import {toast} from "react-toastify"; import DialogTitle from "@mui/material/DialogTitle"; import DialogContent from "@mui/material/DialogContent"; import DialogContentText from "@mui/material/DialogContentText"; 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 function getDeletedRecordWithRefList(referenceList, updatedList){ return referenceList.filter(x => !updatedList.includes(x)) ; } export function getIdList(input){ const output = input.map(function (obj) { return obj.id; }); return output; } export function getObjectById(list, id){ const obj = list.find((element) => { return element.id === id; }); return obj === undefined || Object.keys(obj).length <= 0? null : obj } export function removeObjectWithId(arr, id) { const arrCopy = Array.from(arr); const objWithIdIndex = arrCopy.findIndex((obj) => obj.id === id); arrCopy.splice(objWithIdIndex, 1); return arrCopy; } export function getDateString(queryDateArray) { return( queryDateArray[0] + "-" + queryDateArray[1] + "-" + queryDateArray[2] + " " + queryDateArray[3] + ":" + queryDateArray[4] + ":" + queryDateArray[5] ) } 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", })}; 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", })}; 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", })}; 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", })}; export const notifyLockSuccess = () => { toast.success('Lock success!', { position: "bottom-right", autoClose: 5000, hideProgressBar: false, closeOnClick: true, pauseOnHover: true, draggable: true, progress: undefined, theme: "light", })}; export const notifyUnlockSuccess = () => { toast.success('Unlock success!', { position: "bottom-right", autoClose: 5000, hideProgressBar: false, closeOnClick: true, pauseOnHover: true, draggable: true, progress: undefined, theme: "light", })}; export const notifyActiveSuccess = () => { toast.success('Active success!', { position: "bottom-right", autoClose: 5000, hideProgressBar: false, closeOnClick: true, pauseOnHover: true, draggable: true, progress: undefined, theme: "light", })}; 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", })}; export const notifyActionSuccess = (actionMsg) => { toast.success(`${actionMsg}`, { position: "bottom-right", autoClose: 5000, hideProgressBar: false, closeOnClick: true, pauseOnHover: true, draggable: true, progress: undefined, theme: "light", })}; export const notifyActionError = (actionMsg) => { toast.error(`${actionMsg}`, { position: "bottom-right", autoClose: 5000, hideProgressBar: false, closeOnClick: true, pauseOnHover: true, draggable: true, progress: undefined, theme: "light", })}; export function prettyJson(json){ console.log(json); console.log(JSON.stringify(json, null, 2)); return (