import { CircularProgress, Dialog, DialogContent, DialogContentText, } from "@mui/material"; import React, { PropsWithChildren } from "react"; type LoadingMessageContext = { show: (message: string) => void; hide: () => void; }; const LoadingMessageContextK = React.createContext(null); export function LoadingMessageProvider( p: PropsWithChildren ): React.ReactElement { const [open, setOpen] = React.useState(false); const [message, setMessage] = React.useState(""); const hook: LoadingMessageContext = { show(message) { setMessage(message); setOpen(true); }, hide() { setMessage(""); setOpen(false); }, }; return ( <> {p.children}
{message}
); } export function useLoadingMessage(): LoadingMessageContext { return React.useContext(LoadingMessageContextK)!; }