2024-10-31 16:01:55 +08:00
|
|
|
import React, {useRef, useState} from "react";
|
2023-12-12 18:21:09 +08:00
|
|
|
import {ProcessOptions} from "./Options";
|
2024-01-03 17:34:26 +08:00
|
|
|
import {Notification} from "./Notification";
|
2024-10-31 16:01:55 +08:00
|
|
|
import {Overlay} from "react-bootstrap";
|
2023-11-30 17:26:17 +08:00
|
|
|
|
2024-10-31 16:01:55 +08:00
|
|
|
export function DialogPopup({options, data, target, id, options_class,
|
|
|
|
sideMenuIsOpen, displayNotification, onHideNotification, horizontal}) {
|
2023-11-30 17:26:17 +08:00
|
|
|
const [show, setShow] = useState(false);
|
2024-10-31 16:01:55 +08:00
|
|
|
const ref = useRef(null);
|
|
|
|
|
|
|
|
let div_classes = `overlayVariant border rounded ${options_class || ""}`;
|
2023-11-30 17:26:17 +08:00
|
|
|
|
2023-12-13 15:17:14 +08:00
|
|
|
const handleClick = (_event) => {
|
2023-11-30 17:26:17 +08:00
|
|
|
setShow(!show);
|
|
|
|
};
|
|
|
|
|
2024-10-31 16:01:55 +08:00
|
|
|
return (<>
|
|
|
|
<Notification
|
|
|
|
id={"processed_options_notification" + id}
|
|
|
|
tip="Customization options available"
|
|
|
|
sideMenuIsOpen={sideMenuIsOpen}
|
|
|
|
show={displayNotification}
|
|
|
|
onHide={onHideNotification}
|
|
|
|
content={
|
|
|
|
<img className="alert-info" ref={ref}
|
|
|
|
src={show ? "/images/shop/icon-close.svg" : "/images/shop/icon-customize.svg"}
|
|
|
|
onClick={handleClick}/>
|
|
|
|
}
|
|
|
|
/>
|
|
|
|
<Overlay target={ref.current}
|
|
|
|
show={show}
|
|
|
|
placement={horizontal ? "right" : "bottom"}
|
|
|
|
onHide={() => setShow(false)}
|
|
|
|
rootClose={true}>
|
|
|
|
{({
|
|
|
|
placement: _placement,
|
|
|
|
arrowProps: _arrowProps,
|
|
|
|
show: _show,
|
|
|
|
popper: _popper,
|
|
|
|
hasDoneInitialMeasure: _hasDoneInitialMeasure,
|
|
|
|
...props
|
|
|
|
}) => (
|
|
|
|
<div style={{'display': show ? 'flex' : 'none', ...props.style}} {...props} className={div_classes}>
|
|
|
|
<ProcessOptions
|
|
|
|
options={options}
|
|
|
|
data={data}
|
|
|
|
key={"processed_options_" + id}
|
|
|
|
id={"processed_options_" + id}
|
|
|
|
target={target}
|
|
|
|
/>
|
|
|
|
</div>
|
|
|
|
)}
|
|
|
|
</Overlay>
|
|
|
|
</>);
|
2023-11-30 17:26:17 +08:00
|
|
|
}
|
|
|
|
|