mirror of
https://github.com/naturalcrit/homebrewery.git
synced 2025-12-24 16:22:44 +00:00
Merge branch 'master' into addAdminFixScriptTool-#3801
This commit is contained in:
@@ -1,25 +1,25 @@
|
||||
// Dialog box, for popups and modal blocking messages
|
||||
import React from "react";
|
||||
import React from 'react';
|
||||
const { useRef, useEffect } = React;
|
||||
|
||||
function Dialog({ dismisskeys, closeText = 'Close', blocking = false, ...rest }) {
|
||||
function Dialog({ dismisskeys = [], closeText = 'Close', blocking = false, ...rest }) {
|
||||
const dialogRef = useRef(null);
|
||||
|
||||
useEffect(()=>{
|
||||
if (dismisskeys.length !== 0) {
|
||||
if(dismisskeys.length !== 0) {
|
||||
blocking ? dialogRef.current?.showModal() : dialogRef.current?.show();
|
||||
}
|
||||
}, [dialogRef.current, dismisskeys]);
|
||||
|
||||
const dismiss = () => {
|
||||
dismisskeys.forEach(key => {
|
||||
if (key) {
|
||||
const dismiss = ()=>{
|
||||
dismisskeys.forEach((key)=>{
|
||||
if(key) {
|
||||
localStorage.setItem(key, 'true');
|
||||
}
|
||||
});
|
||||
dialogRef.current?.close();
|
||||
};
|
||||
|
||||
|
||||
return (
|
||||
<dialog ref={dialogRef} onCancel={dismiss} {...rest}>
|
||||
{rest.children}
|
||||
|
||||
Reference in New Issue
Block a user