2023-11-30 17:26:17 +08:00
|
|
|
import React, {useState} from "react";
|
2023-12-01 11:52:37 +08:00
|
|
|
import {useClickAway} from "./useClickAway";
|
2023-12-12 18:21:09 +08:00
|
|
|
import {ProcessOptions} from "./Options";
|
2024-01-03 17:34:26 +08:00
|
|
|
import {Notification} from "./Notification";
|
2023-11-30 17:26:17 +08:00
|
|
|
|
|
|
|
export function DialogPopup({options, data, target, id, big, first, last, options_class}) {
|
|
|
|
const [show, setShow] = useState(false);
|
|
|
|
const ref = useClickAway((e) => {
|
|
|
|
if (e.type === "mousedown") // ignore touchstart
|
|
|
|
setShow(false)
|
|
|
|
}
|
|
|
|
);
|
|
|
|
|
|
|
|
let div_classes = `overlayVariant border rounded ${big ? "overlay-bigcard" : "overlay-smallcard"} ${(!big && first) ? "overlay-first" : ""} ${(!big && last) ? "overlay-last" : ""} ${options_class || ""}`;
|
2023-12-13 15:17:14 +08:00
|
|
|
const handleClick = (_event) => {
|
2023-11-30 17:26:17 +08:00
|
|
|
setShow(!show);
|
|
|
|
};
|
|
|
|
|
|
|
|
return (
|
|
|
|
<div ref={ref}>
|
2024-01-03 17:34:26 +08:00
|
|
|
<Notification
|
|
|
|
id={"processed_options_notification" + id}
|
2024-01-05 13:15:43 +08:00
|
|
|
tip="Customization options available"
|
2024-01-03 17:34:26 +08:00
|
|
|
content={
|
|
|
|
<img className="alert-info" src={show ? "/images/shop/icon-close.svg" : "/images/shop/icon-customize.svg"}
|
|
|
|
onClick={handleClick}/>
|
|
|
|
}
|
|
|
|
/>
|
2023-11-30 17:26:17 +08:00
|
|
|
<div style={{'display': show ? 'flex' : 'none'}} className={div_classes}>
|
|
|
|
<ProcessOptions
|
|
|
|
options={options}
|
|
|
|
data={data}
|
|
|
|
key={"processed_options_" + id}
|
|
|
|
id={"processed_options_" + id}
|
|
|
|
target={target}
|
|
|
|
/>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|