diff --git a/assets/js/src/form_editor/components/form_settings/form_placement_options/below_pages.tsx b/assets/js/src/form_editor/components/form_settings/form_placement_options/below_pages.tsx
index 367abc2f9f..f09ea9db89 100644
--- a/assets/js/src/form_editor/components/form_settings/form_placement_options/below_pages.tsx
+++ b/assets/js/src/form_editor/components/form_settings/form_placement_options/below_pages.tsx
@@ -1,10 +1,9 @@
-import React, { useState } from 'react';
+import React from 'react';
import MailPoet from 'mailpoet';
import { useSelect, useDispatch } from '@wordpress/data';
-import FormPlacementSettings from './form_placement_settings';
-import Toggle from '../../../../common/toggle';
import Icon from './icons/below_pages_icon';
+import FormPlacementOption from './form_placement_option';
const BelowPages = () => {
const formSettings = useSelect(
@@ -14,56 +13,16 @@ const BelowPages = () => {
const placeFormBellowAllPages = formSettings.placeFormBellowAllPages || false;
const placeFormBellowAllPosts = formSettings.placeFormBellowAllPosts || false;
- const { changeFormSettings } = useDispatch('mailpoet-form-editor');
-
- const [
- localPlaceFormBellowAllPages,
- setLocalPlaceFormBellowAllPages,
- ] = useState(placeFormBellowAllPages);
- const [
- localPlaceFormBellowAllPosts,
- setLocalPlaceFormBellowAllPosts,
- ] = useState(placeFormBellowAllPosts);
-
- const save = () => {
- changeFormSettings({
- ...formSettings,
- placeFormBellowAllPages: localPlaceFormBellowAllPages,
- placeFormBellowAllPosts: localPlaceFormBellowAllPosts,
- });
- };
+ const { showPreview } = useDispatch('mailpoet-form-editor');
return (
-
-
-
- {MailPoet.I18n.t('placeFormBellowAllPages')}
-
-
-
-
-
- {MailPoet.I18n.t('placeFormBellowAllPosts')}
-
-
-
-
-
-
+ onClick={() => (showPreview('below_post'))}
+ canBeActive
+ />
);
};
diff --git a/assets/js/src/form_editor/components/preview/below_posts_settings.tsx b/assets/js/src/form_editor/components/preview/below_posts_settings.tsx
new file mode 100644
index 0000000000..081f49b1c1
--- /dev/null
+++ b/assets/js/src/form_editor/components/preview/below_posts_settings.tsx
@@ -0,0 +1,46 @@
+import React from 'react';
+import MailPoet from 'mailpoet';
+import Toggle from 'common/toggle';
+import { useSelect, useDispatch } from '@wordpress/data';
+import { partial } from 'lodash';
+
+const BelowPostsSettings = () => {
+ const formSettings = useSelect(
+ (select) => select('mailpoet-form-editor').getFormSettings(),
+ []
+ );
+ const { changeFormSettings } = useDispatch('mailpoet-form-editor');
+
+ const updateSettings = (key, value) => {
+ const settings = { ...formSettings };
+ settings[key] = value;
+ changeFormSettings(settings);
+ };
+
+ return (
+
+
+ {MailPoet.I18n.t('placeFormBellowAllPages')}
+
+
+
+
+
+ {MailPoet.I18n.t('placeFormBellowAllPosts')}
+
+
+
+
+
+ );
+};
+
+export default BelowPostsSettings;
diff --git a/assets/js/src/form_editor/components/preview/preview.tsx b/assets/js/src/form_editor/components/preview/preview.tsx
index ff40baf954..17c95deeb6 100644
--- a/assets/js/src/form_editor/components/preview/preview.tsx
+++ b/assets/js/src/form_editor/components/preview/preview.tsx
@@ -9,6 +9,7 @@ import { useDispatch, useSelect } from '@wordpress/data';
import Preview from 'common/preview/preview.jsx';
import Modal from 'common/modal/modal.jsx';
import { onChange } from 'common/functions';
+import BelowPostsSettings from './below_posts_settings';
const FormPreview = () => {
const [iframeLoaded, setIframeLoaded] = useState(false);
@@ -86,7 +87,7 @@ const FormPreview = () => {
- Todo width and placement settings.
+ {previewSettings.formType === 'below_post' && }
click('[data-automation-id="form-placement-option-Below pages"]');
$i->waitForElement('[data-automation-id="place-form-bellow-all-posts-toggle"]');
$i->checkOption('[data-automation-id="place-form-bellow-all-posts-toggle"]');
- $i->click('.automation-id-save-form-placement');
+ $i->click('.mailpoet-modal-close');
$i->click('[data-automation-id="form_save_button"]');
$i->waitForText('Form saved', 10, '.automation-dismissible-notices');