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