| Server IP : 193.146.211.90 / Your IP : 10.85.6.55 Web Server : Apache System : Linux wordpress-gti-69dcdb54f7-n4wdq 6.11.8-arch1-2 #1 SMP PREEMPT_DYNAMIC Fri, 15 Nov 2024 15:35:07 +0000 x86_64 User : 1001 ( 1001) PHP Version : 8.2.25 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : OFF | Perl : ON | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : /bitnami/wordpress/wp-content/plugins/presto-player/src/admin/settings/components/ |
Upload File : |
const { ToggleControl, Modal, Button } = wp.components;
const { dispatch } = wp.data;
const { useState } = wp.element;
const { __ } = wp.i18n;
import classNames from "classnames";
export default ({ option, value, optionName, className }) => {
const [confirm, setConfirm] = useState(false);
return (
<div
className={classNames(
className,
"presto-settings__setting is-toggle-control"
)}
>
<ToggleControl
label={option?.description || option?.name}
checked={value}
help={option?.help}
onChange={(value) => {
if (option?.confirm && value) {
setConfirm(true);
return;
}
dispatch("presto-player/settings").updateSetting(
option.id,
value,
optionName
);
}}
/>
{confirm && (
<Modal
className="presto-player__modal-confirm"
title={option?.confirm?.title}
style={{ "max-width": "350px" }}
onRequestClose={() => setConfirm(false)}
>
{option?.confirm?.heading && <h2>{option?.confirm?.heading}</h2>}
{option?.confirm?.message && <p>{option?.confirm?.message}</p>}
<Button
className="presto-player__modal-confirm-button"
isDestructive
onClick={() => {
dispatch("presto-player/settings").updateSetting(
option.id,
true,
optionName
);
setConfirm(false);
}}
>
{__("Okay", "presto-player")}
</Button>
<Button onClick={() => setConfirm(false)}>
{__("Cancel", "presto-player")}
</Button>
</Modal>
)}
</div>
);
};