import React, { FC, useState, useEffect } from 'react'; import ReactTooltip from 'react-tooltip'; import { toast } from 'react-toastify'; import Title from '../core/Title'; import { getNonce } from './../Helpers'; import Icons from '../icons'; type Props = { settings: { theme: string; button_access: boolean; error_msg: string; }; setSettings: any; }; const Settings: FC = ({ settings, setSettings }) => { const [_, setThemeAppearance] = useState(settings?.theme); const handleChangeThemeAppearance = (e) => { const target = e.target; if (target.checked) { setThemeAppearance(target.value); } setSettings({ ...settings, theme: target.value, }); }; const handleChange = (e): void => { const data = { ...settings, [e.target.name]: e.target.name === 'button_access' ? e.target.checked : e.target.value, }; setSettings(data); }; const handleSubmit = (): void => { wp.ajax.send('save_settings', { data: { nonce: getNonce(), settings: JSON.stringify(settings), context: 'additional-settings', }, success({ message }) { toast.success(message); }, error(err: any) { console.error(err); }, }); }; return (
<h6> Theme{' '} <span data-tip="Choose the look and appearance of the turnstile widget"> {Icons.tooltip_icon} </span> </h6>
<h6> Submit button access{' '} <span data-tip="When enabled user can click on submit button without completing the Turnstile check. If disabled the submit button will not be clickable until the Turnstile check is completed. "> {Icons.tooltip_icon} </span> </h6>
handleChange(e)} checked={settings?.button_access} />
{settings.button_access ? (

The user can click on submit button without completing the Turnstile check

) : (

The submit button is not clickable until the Turnstile check is completed

)}
<h6> Custom message{' '} <span data-tip="Type in the text that you want to show on the Turnstile widget"> {Icons.tooltip_icon} </span> </h6> handleChange(e)} value={settings?.error_msg} />

* Leaving it blank will show the default “Please verify you are human” message

); }; export default Settings;