/* eslint-disable @woocommerce/dependency-group */ /* eslint-disable @typescript-eslint/ban-ts-comment */ /** * External dependencies */ import { __ } from '@wordpress/i18n'; import { createInterpolateElement, useCallback, useMemo, } from '@wordpress/element'; import { Link } from '@woocommerce/components'; import { Spinner } from '@wordpress/components'; // @ts-expect-error Missing type in core-data. import { __experimentalBlockPatternsList as BlockPatternList } from '@wordpress/block-editor'; import { recordEvent } from '@woocommerce/tracks'; /** * Internal dependencies */ import { SidebarNavigationScreen } from './sidebar-navigation-screen'; import { ADMIN_URL } from '~/utils/admin-settings'; import { useEditorBlocks } from '../hooks/use-editor-blocks'; import { useHomeTemplates } from '../hooks/use-home-templates'; import { BlockInstance } from '@wordpress/blocks'; export const SidebarNavigationScreenHomepage = () => { const { isLoading, homeTemplates } = useHomeTemplates(); const [ blocks, , onChange ] = useEditorBlocks(); const onClickPattern = useCallback( ( _pattern, selectedBlocks ) => { onChange( [ blocks[ 0 ], ...selectedBlocks, blocks[ blocks.length - 1 ] ], { selection: {} } ); }, [ blocks, onChange ] ); const homePatterns = useMemo( () => { return Object.entries( homeTemplates ).map( ( [ templateName, patterns ] ) => { return { name: templateName, blocks: patterns.reduce( ( acc: BlockInstance[], pattern ) => [ ...acc, ...pattern.blocks, ], [] ), }; } ); }, [ homeTemplates ] ); return ( Editor.', 'woocommerce' ), { EditorLink: ( { recordEvent( 'customize_your_store_assembler_hub_editor_link_click', { source: 'homepage', } ); window.open( `${ ADMIN_URL }site-editor.php`, '_blank' ); return false; } } href="" /> ), } ) } content={
{ isLoading ? ( ) : ( ) }
} /> ); };