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 484de792b7..792de5a268 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 @@ -14,7 +14,7 @@ const BelowPages = () => { const placeFormBellowAllPages = formSettings.placeFormBellowAllPages || false; const placeFormBellowAllPosts = formSettings.placeFormBellowAllPosts || false; - const { setPlaceFormBellowAllPages, setPlaceFormBellowAllPosts } = useDispatch('mailpoet-form-editor'); + const { changeFormSettings } = useDispatch('mailpoet-form-editor'); const [ localPlaceFormBellowAllPages, @@ -26,8 +26,11 @@ const BelowPages = () => { ] = useState(placeFormBellowAllPosts); const save = () => { - setPlaceFormBellowAllPages(localPlaceFormBellowAllPages); - setPlaceFormBellowAllPosts(localPlaceFormBellowAllPosts); + changeFormSettings({ + ...formSettings, + placeFormBellowAllPages: localPlaceFormBellowAllPages, + placeFormBellowAllPosts: localPlaceFormBellowAllPosts, + }); }; return ( diff --git a/assets/js/src/form_editor/components/form_settings/form_placement_options/fixed_bar.tsx b/assets/js/src/form_editor/components/form_settings/form_placement_options/fixed_bar.tsx index 0548a4bbfd..b13e43d313 100644 --- a/assets/js/src/form_editor/components/form_settings/form_placement_options/fixed_bar.tsx +++ b/assets/js/src/form_editor/components/form_settings/form_placement_options/fixed_bar.tsx @@ -21,12 +21,7 @@ const FixedBar = () => { const placeFixedBarFormOnAllPages = formSettings.placeFixedBarFormOnAllPages || false; const placeFixedBarFormOnAllPosts = formSettings.placeFixedBarFormOnAllPosts || false; - const { - setPlaceFixedBarFormOnAllPages, - setPlaceFixedBarFormOnAllPosts, - setFixedBarFormDelay, - setFixedBarFormPosition, - } = useDispatch('mailpoet-form-editor'); + const { changeFormSettings } = useDispatch('mailpoet-form-editor'); const [ localPlaceFixedBarFormOnAllPages, @@ -46,10 +41,13 @@ const FixedBar = () => { ] = useState(fixedBarFormPosition); const save = () => { - setPlaceFixedBarFormOnAllPages(localPlaceFixedBarFormOnAllPages); - setPlaceFixedBarFormOnAllPosts(localPlaceFixedBarFormOnAllPosts); - setFixedBarFormDelay(localDelay); - setFixedBarFormPosition(localPosition); + changeFormSettings({ + ...formSettings, + placeFixedBarFormOnAllPages: localPlaceFixedBarFormOnAllPages, + placeFixedBarFormOnAllPosts: localPlaceFixedBarFormOnAllPosts, + fixedBarFormDelay: localDelay, + fixedBarFormPosition: localPosition, + }); }; return ( diff --git a/assets/js/src/form_editor/components/form_settings/form_placement_options/popup.tsx b/assets/js/src/form_editor/components/form_settings/form_placement_options/popup.tsx index 1f9c1ac779..354605c70e 100644 --- a/assets/js/src/form_editor/components/form_settings/form_placement_options/popup.tsx +++ b/assets/js/src/form_editor/components/form_settings/form_placement_options/popup.tsx @@ -16,15 +16,11 @@ const Popup = () => { ); const popupFormDelay = formSettings.popupFormDelay === undefined ? 15 - : formSettings.fixedBarFormDelay; + : formSettings.popupFormDelay; const placePopupFormOnAllPages = formSettings.placePopupFormOnAllPages || false; const placePopupFormOnAllPosts = formSettings.placePopupFormOnAllPosts || false; - const { - setPlacePopupFormOnAllPages, - setPlacePopupFormOnAllPosts, - setPopupFormDelay, - } = useDispatch('mailpoet-form-editor'); + const { changeFormSettings } = useDispatch('mailpoet-form-editor'); const [ localPlacePopupFormOnAllPages, @@ -40,9 +36,12 @@ const Popup = () => { ] = useState(popupFormDelay); const save = () => { - setPlacePopupFormOnAllPages(localPlacePopupFormOnAllPages); - setPlacePopupFormOnAllPosts(localPlacePopupFormOnAllPosts); - setPopupFormDelay(localDelay); + changeFormSettings({ + ...formSettings, + placePopupFormOnAllPages: localPlacePopupFormOnAllPages, + placePopupFormOnAllPosts: localPlacePopupFormOnAllPosts, + popupFormDelay: localDelay, + }); }; return ( diff --git a/assets/js/src/form_editor/store/actions.jsx b/assets/js/src/form_editor/store/actions.jsx index e0227c9543..f15555c690 100644 --- a/assets/js/src/form_editor/store/actions.jsx +++ b/assets/js/src/form_editor/store/actions.jsx @@ -20,69 +20,6 @@ export function changeFormName(name) { }; } -export function setPlaceFormBellowAllPages(place) { - return { - type: 'PLACE_FORM_BELLOW_ALL_PAGES', - place, - }; -} - -export function setPlaceFormBellowAllPosts(place) { - return { - type: 'PLACE_FORM_BELLOW_ALL_POSTS', - place, - }; -} - -export function setPlacePopupFormOnAllPages(place) { - return { - type: 'PLACE_POPUP_FORM_ON_ALL_PAGES', - place, - }; -} - -export function setPlacePopupFormOnAllPosts(place) { - return { - type: 'PLACE_POPUP_FORM_ON_ALL_POSTS', - place, - }; -} - -export function setPopupFormDelay(delay) { - return { - type: 'SET_POPUP_FORM_DELAY', - delay, - }; -} - -export function setPlaceFixedBarFormOnAllPages(place) { - return { - type: 'PLACE_FIXED_BAR_FORM_ON_ALL_PAGES', - place, - }; -} - -export function setPlaceFixedBarFormOnAllPosts(place) { - return { - type: 'PLACE_FIXED_BAR_FORM_ON_ALL_POSTS', - place, - }; -} - -export function setFixedBarFormDelay(delay) { - return { - type: 'SET_FIXED_BAR_FORM_DELAY', - delay, - }; -} - -export function setFixedBarFormPosition(position) { - return { - type: 'SET_FIXED_BAR_FORM_POSITION', - position, - }; -} - export function deleteCustomFieldStarted() { return { type: 'DELETE_CUSTOM_FIELD_STARTED', diff --git a/assets/js/src/form_editor/store/reducer.jsx b/assets/js/src/form_editor/store/reducer.jsx index cbda1c77af..026b29a096 100644 --- a/assets/js/src/form_editor/store/reducer.jsx +++ b/assets/js/src/form_editor/store/reducer.jsx @@ -4,17 +4,6 @@ import createCustomFieldFailed from './reducers/create_custom_field_failed.jsx'; import customFieldEdited from './reducers/custom_field_edited.jsx'; import createCustomFieldStartedFactory from './reducers/create_custom_field_started.jsx'; import changeFormName from './reducers/change_form_name.jsx'; -import { - placeFormBellowAllPages, - placeFormBellowAllPosts, - placePopupFormOnAllPages, - placePopupFormOnAllPosts, - setPopupFormDelay, - placeFixedBarFormOnAllPosts, - placeFixedBarFormOnAllPages, - setFixedBarFormDelay, - setFixedBarFormPosition, -} from './reducers/form_placement.jsx'; import changeFormSettings from './reducers/change_form_settings.jsx'; import changeFormStyles from './reducers/change_form_styles.jsx'; import removeNotice from './reducers/remove_notice.jsx'; @@ -63,15 +52,6 @@ export default (defaultState) => (state = defaultState, action) => { case 'DELETE_CUSTOM_FIELD_STARTED': return customFieldDeleteStart(state, action); case 'DELETE_CUSTOM_FIELD_DONE': return customFieldDeleteDone(state, action); case 'DELETE_CUSTOM_FIELD_FAILED': return customFieldDeleteFailed(state, action); - case 'PLACE_FORM_BELLOW_ALL_PAGES': return placeFormBellowAllPages(state, action); - case 'PLACE_FORM_BELLOW_ALL_POSTS': return placeFormBellowAllPosts(state, action); - case 'PLACE_POPUP_FORM_ON_ALL_PAGES': return placePopupFormOnAllPages(state, action); - case 'PLACE_POPUP_FORM_ON_ALL_POSTS': return placePopupFormOnAllPosts(state, action); - case 'SET_POPUP_FORM_DELAY': return setPopupFormDelay(state, action); - case 'PLACE_FIXED_BAR_FORM_ON_ALL_PAGES': return placeFixedBarFormOnAllPages(state, action); - case 'PLACE_FIXED_BAR_FORM_ON_ALL_POSTS': return placeFixedBarFormOnAllPosts(state, action); - case 'SET_FIXED_BAR_FORM_DELAY': return setFixedBarFormDelay(state, action); - case 'SET_FIXED_BAR_FORM_POSITION': return setFixedBarFormPosition(state, action); default: return state; } diff --git a/assets/js/src/form_editor/store/reducers/form_placement.jsx b/assets/js/src/form_editor/store/reducers/form_placement.jsx deleted file mode 100644 index ac9bbf27b0..0000000000 --- a/assets/js/src/form_editor/store/reducers/form_placement.jsx +++ /dev/null @@ -1,53 +0,0 @@ -import { curry } from 'lodash'; - -const formPlacement = curry((placement, state, action) => ({ - ...state, - hasUnsavedChanges: true, - formData: { - ...state.formData, - settings: { - ...state.formData.settings, - [placement]: action.place, - }, - }, -})); - -export const placeFormBellowAllPosts = formPlacement('placeFormBellowAllPosts'); - -export const placeFormBellowAllPages = formPlacement('placeFormBellowAllPages'); - -export const placePopupFormOnAllPages = formPlacement('placePopupFormOnAllPages'); - -export const placePopupFormOnAllPosts = formPlacement('placePopupFormOnAllPosts'); - -export const placeFixedBarFormOnAllPages = formPlacement('placeFixedBarFormOnAllPages'); - -export const placeFixedBarFormOnAllPosts = formPlacement('placeFixedBarFormOnAllPosts'); - -export const formPlacementDelay = curry((delayFormName, state, action) => ({ - ...state, - hasUnsavedChanges: true, - formData: { - ...state.formData, - settings: { - ...state.formData.settings, - [delayFormName]: action.delay, - }, - }, -})); - -export const setPopupFormDelay = formPlacementDelay('popupFormDelay'); - -export const setFixedBarFormDelay = formPlacementDelay('fixedBarFormDelay'); - -export const setFixedBarFormPosition = (state, action) => ({ - ...state, - hasUnsavedChanges: true, - formData: { - ...state.formData, - settings: { - ...state.formData.settings, - fixedBarFormPosition: action.position, - }, - }, -});