Update start from scratch and close to use the first template + pattern

[MAILPOET-6334]
This commit is contained in:
Rostislav Wolny
2024-12-19 10:04:57 +01:00
committed by Aschepikov
parent f368745289
commit 09747dd98a

View File

@@ -1,8 +1,15 @@
/**
* WordPress dependencies
*/
import { useState, useEffect, memo } from '@wordpress/element'; import { useState, useEffect, memo } from '@wordpress/element';
import { store as editorStore } from '@wordpress/editor'; import { store as editorStore } from '@wordpress/editor';
import { dispatch } from '@wordpress/data'; import { dispatch } from '@wordpress/data';
import { Modal, Button, Flex, FlexItem } from '@wordpress/components'; import { Modal, Button, Flex, FlexItem } from '@wordpress/components';
import { __ } from '@wordpress/i18n'; import { __ } from '@wordpress/i18n';
/**
* Internal dependencies
*/
import { usePreviewTemplates } from '../../hooks'; import { usePreviewTemplates } from '../../hooks';
import { import {
EmailEditorPostType, EmailEditorPostType,
@@ -13,8 +20,6 @@ import {
import { TemplateList } from './template-list'; import { TemplateList } from './template-list';
import { TemplateCategoriesListSidebar } from './template-categories-list-sidebar'; import { TemplateCategoriesListSidebar } from './template-categories-list-sidebar';
const BLANK_TEMPLATE = 'email-general';
const TemplateCategories: Array< { name: TemplateCategory; label: string } > = [ const TemplateCategories: Array< { name: TemplateCategory; label: string } > = [
{ {
name: 'recent', name: 'recent',
@@ -91,13 +96,11 @@ export function SelectTemplateModal( {
}; };
const handleCloseWithoutSelection = () => { const handleCloseWithoutSelection = () => {
const blankTemplate = templates.find( const template = templates[ 0 ] ?? null;
( template ) => template.slug === BLANK_TEMPLATE if ( ! template ) {
) as unknown as TemplatePreview;
if ( ! blankTemplate ) {
return; return;
} // Prevent close if blank template is still not loaded } // Prevent closing when templates are not loaded
handleTemplateSelection( blankTemplate ); handleTemplateSelection( template );
}; };
return ( return (