import analytics from '@automattic/jetpack-analytics'; import { __ } from '@wordpress/i18n'; import classNames from 'classnames'; import Card from 'components/card'; import CompactFormToggle from 'components/form-toggle/compact'; import React, { useCallback } from 'react'; import 'scss/rna-styles.scss'; import './style.scss'; const SEARCH_DESCRIPTION = __( 'Earn income by allowing Jetpack to display high quality ads.', 'jetpack-wordads' ); /** * Search settings component to be used within the Performance section. * * @param {object} props - Component properties. * @param {Function} props.updateOptions - function to update settings. * @param {boolean} props.isSavingOptions - true if Saving options. * @param {boolean} props.isModuleEnabled - true if WordAds module is enabled. * @param {boolean} props.isTogglingModule - true if toggling WordAds module. * @returns {React.Component} Search settings component. */ export default function WordAdsModuleControl( { updateOptions, isSavingOptions, isModuleEnabled, isTogglingModule, } ) { const toggleSearchModule = useCallback( () => { const newOption = { module_active: ! isModuleEnabled, }; updateOptions( newOption ); analytics.tracks.recordEvent( 'jetpack_wordads_module_toggle', newOption ); }, [ isModuleEnabled, updateOptions ] ); const renderSearchToggle = () => { return (
{ __( 'Enable WordAds', 'jetpack-wordads' ) }

{ SEARCH_DESCRIPTION }

); }; return (
{ renderSearchToggle() }
); }