403Webshell
Server IP : 82.208.35.60  /  Your IP : 216.73.216.238
Web Server : Apache/2.4.55 (FreeBSD) OpenSSL/1.1.1q-freebsd PHP/7.3.31
System : FreeBSD server7.d2m.cz 12.4-RELEASE-p9 FreeBSD 12.4-RELEASE-p9 GENERIC amd64
User : studiokobylisy_cz ( 1008)
PHP Version : 7.3.31
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : OFF  |  Perl : OFF  |  Python : OFF  |  Sudo : OFF  |  Pkexec : OFF
Directory :  /var/www/k633_cz/www/wp-content/plugins/complianz-gdpr/settings/src/Settings/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /var/www/k633_cz/www/wp-content/plugins/complianz-gdpr/settings/src/Settings/ButtonControl.js
import Button from "../Settings/Inputs/Button";
import * as cmplz_api from "../utils/api";
import useFields from "./Fields/FieldsData";
import useMenu from "../Menu/MenuData";
import {useState} from "@wordpress/element";

import { __experimentalConfirmDialog as ConfirmDialog } from '@wordpress/components';

const ButtonControl = ({label, field, disabled}) => {
	const {fetchFieldsData, showSavedSettingsNotice} = useFields();
	const {selectedSubMenuItem } = useMenu();
	const [ isOpen, setIsOpen ] = useState( false );

	let text = field.button_text ? field.button_text : field.label;

	if ( field.action ) {
		const clickHandler = async (e) => {
			if (field.warn) {
				setIsOpen( true );
			} else {
				await executeAction();
			}
		}

		const handleConfirm = async () => {
			setIsOpen( false );
			await executeAction();
		};

		const handleCancel = () => {
			setIsOpen( false );
		};

		const executeAction = async (e) => {
			let data = {};
			await cmplz_api.doAction(field.action, data).then((response) => {
				if (response.success) {
					fetchFieldsData(selectedSubMenuItem);
					showSavedSettingsNotice(response.message);
				}
			});
		}

		return (
			<>
				<Button
					text={text}
					style={'secondary'}
						disabled={disabled}
						onClick={(e)=>clickHandler(e)}
				/>
				<ConfirmDialog
					isOpen={ isOpen }
					onConfirm={ handleConfirm }
					onCancel={ handleCancel }
				>
					{field.warn}
				</ConfirmDialog>
			</>
		)
	} else {
		return (
				<Button
					style='secondary'
					label={text}
					disabled={disabled}
					href={field.url}
				/>
		)
	}
}
export default ButtonControl

Youez - 2016 - github.com/yon3zu
LinuXploit