diff --git a/assets/js/src/form_editor/templates/selection.tsx b/assets/js/src/form_editor/templates/selection.tsx index 21e22dde13..e41165375a 100644 --- a/assets/js/src/form_editor/templates/selection.tsx +++ b/assets/js/src/form_editor/templates/selection.tsx @@ -1,47 +1,72 @@ -import React from 'react'; -import Heading from 'common/typography/heading/heading'; +import React, { useState } from 'react'; import MailPoet from 'mailpoet'; import { useSelect, useDispatch } from '@wordpress/data'; import { Button } from '@wordpress/components'; - -import { TemplateType } from './store/types'; +import Categories from 'common/categories/categories'; +import Background from 'common/background/background'; +import { TemplateData } from './store/types'; export default () => { - const templates: Array = useSelect( + const [selectedCategory, setSelectedCategory] = useState('popup'); + + const categories = [ + { + name: 'popup', + label: MailPoet.I18n.t('popupCategory'), + }, + { + name: 'fixed_bar', + label: MailPoet.I18n.t('fixedBarCategory'), + }, + { + name: 'below_posts', + label: MailPoet.I18n.t('belowPagesCategory'), + }, + { + name: 'slide_in', + label: MailPoet.I18n.t('slideInCategory'), + }, + { + name: 'others', + label: MailPoet.I18n.t('othersCategory'), + }, + ]; + + const templates: TemplateData = useSelect( (select) => select('mailpoet-form-editor-templates').getTemplates(), [] ); - const selectTemplateFailed: boolean = useSelect( - (select) => select('mailpoet-form-editor-templates').getSelectTemplateFailed(), - [] - ); + + // const selectTemplateFailed: boolean = useSelect( + // (select) => select('mailpoet-form-editor-templates').getSelectTemplateFailed(), + // [] + // ); + const { selectTemplate } = useDispatch('mailpoet-form-editor-templates'); return (
- {MailPoet.I18n.t('heading')} - {selectTemplateFailed && (
Failed
)} -
    -
  1. - -
  2. - {templates.map((template, index) => ( -
  3. - -
  4. - ))} -
+ +
+ +
    + {templates[selectedCategory].map((template, index) => ( +
  1. + +
  2. + ))} +
+
+
); }; diff --git a/assets/js/src/form_editor/templates/store/types.ts b/assets/js/src/form_editor/templates/store/types.ts index 35ffc8e7c2..17675c3632 100644 --- a/assets/js/src/form_editor/templates/store/types.ts +++ b/assets/js/src/form_editor/templates/store/types.ts @@ -2,3 +2,7 @@ export type TemplateType = { id: string name: string }; + +export type TemplateData = { + [formType: string]: Array +} diff --git a/views/form/template_selection.html b/views/form/template_selection.html index 273d5625ae..1af50d6ff1 100644 --- a/views/form/template_selection.html +++ b/views/form/template_selection.html @@ -32,6 +32,11 @@ <%= localize({ 'heading': __('Select form template'), 'blankTemplate': _x('Blank template', 'the first item in the templates selection list'), + 'fixedBarCategory': _x('Fixed bar', 'This is a text on a widget that leads to settings for form placement - form type is fixed bar'), + 'slideInCategory': _x('Slide–in', 'This is a text on a widget that leads to settings for form placement - form type is slide in'), + 'popupCategory': _x('Pop up', 'This is a text on a widget that leads to settings for form placement - form type is pop up, it will be displayed on page in a small modal window'), + 'belowPagesCategory': _x('Below pages', 'This is a text on a widget that leads to settings for form placement'), + 'othersCategory': _x('Others (widget)', 'Placement of the form using theme widget'), }) %> <% endblock %>