|
- // 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";
-
- 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 = () => toast.success('Save success!', {
- // position: "bottom-right",
- // autoClose: 5000,
- // hideProgressBar: false,
- // closeOnClick: true,
- // pauseOnHover: true,
- // draggable: true,
- // progress: undefined,
- // theme: "light",
- // });
-
- export const notifyDeleteSuccess = () => toast.success('Delete Success!', {
- 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 (
- <div>{JSON.stringify(json, null, 2)}</div>
- );
- }
-
- export function GeneralConfirmWindow({
- isWindowOpen,
- title,
- content,
- onNormalClose,
- onConfirmClose}){
- return (
- <Dialog
- open={isWindowOpen}
- onClose={onNormalClose}
- aria-labelledby="alert-dialog-title"
- aria-describedby="alert-dialog-description"
- >
- <DialogTitle id="alert-dialog-title">
- {title}
- </DialogTitle>
- <DialogContent>
- <DialogContentText id="alert-dialog-description">
- {content}
- </DialogContentText>
- </DialogContent>
- <DialogActions>
- <Button onClick={onNormalClose}>Cancel</Button>
- <Button onClick={onConfirmClose} autoFocus>
- Confirm
- </Button>
- </DialogActions>
- </Dialog>
- )
- }
|