2023-09-29 23:03:50 +00:00
/* eslint-disable @woocommerce/dependency-group */
/* eslint-disable @typescript-eslint/ban-ts-comment */
/ * *
* External dependencies
* /
import { resolveSelect } from '@wordpress/data' ;
import { ONBOARDING_STORE_NAME } from '@woocommerce/data' ;
// @ts-ignore No types for this exist yet.
import { store as coreStore } from '@wordpress/core-data' ;
2023-08-18 05:30:25 +00:00
2023-09-29 23:03:50 +00:00
// placeholder xstate async service that returns a set of theme cards
2023-08-18 05:30:25 +00:00
export const fetchThemeCards = async ( ) = > {
return [
{
2023-09-20 06:36:20 +00:00
slug : 'twentytwentyone' ,
2023-08-18 05:30:25 +00:00
name : 'Twenty Twenty One' ,
description : 'The default theme for WordPress.' ,
2023-09-29 07:44:22 +00:00
isActive : true ,
2023-09-30 00:17:36 +00:00
image : 'https://i0.wp.com/s2.wp.com/wp-content/themes/pub/twentytwentyone/screenshot.png' ,
colorPalettes : [ ] ,
2023-08-18 05:30:25 +00:00
} ,
{
2023-09-20 06:36:20 +00:00
slug : 'twentytwenty' ,
2023-08-18 05:30:25 +00:00
name : 'Twenty Twenty' ,
description : 'The previous default theme for WordPress.' ,
2023-09-20 06:36:20 +00:00
image : 'https://i0.wp.com/s2.wp.com/wp-content/themes/pub/twentytwenty/screenshot.png' ,
2023-09-30 00:17:36 +00:00
colorPalettes : [ ] ,
2023-09-20 06:36:20 +00:00
} ,
{
slug : 'tsubaki' ,
name : 'Tsubaki' ,
description :
'Tsubaki puts the spotlight on your products and your customers. This theme leverages WooCommerce to provide you with intuitive product navigation and the patterns you need to master digital merchandising.' ,
image : 'https://i0.wp.com/s2.wp.com/wp-content/themes/premium/tsubaki/screenshot.png' ,
2023-09-30 00:17:36 +00:00
colorPalettes : [ ] ,
2023-09-20 06:36:20 +00:00
} ,
{
slug : 'winkel' ,
name : 'Winkel' ,
description :
'Winkel is a minimal, product-focused theme featuring Payments block. Its clean, cool look combined with a simple layout makes it perfect for showcasing fashion items – clothes, shoes, and accessories.' ,
image : 'https://i0.wp.com/s2.wp.com/wp-content/themes/pub/winkel/screenshot.png' ,
2023-09-30 00:17:36 +00:00
colorPalettes : [
2023-09-20 06:36:20 +00:00
{
title : 'Default' ,
primary : '#ffffff' ,
secondary : '#676767' ,
} ,
{
title : 'Charcoal' ,
primary : '#1f2527' ,
secondary : '#9fd3e8' ,
} ,
{
title : 'Rainforest' ,
primary : '#eef4f7' ,
secondary : '#35845d' ,
} ,
{
title : 'Ruby Wine' ,
primary : '#ffffff' ,
secondary : '#c8133e' ,
} ,
] ,
2023-08-18 05:30:25 +00:00
} ,
] ;
} ;
2023-09-29 23:03:50 +00:00
export const fetchIntroData = async ( ) = > {
const currentTemplate = await resolveSelect (
coreStore
// @ts-expect-error No types for this exist yet.
) . __experimentalGetTemplateForLink ( '/' ) ;
const styleRevs = await resolveSelect (
coreStore
// @ts-expect-error No types for this exist yet.
) . getCurrentThemeGlobalStylesRevisions ( ) ;
const hasModifiedPages = (
await resolveSelect ( coreStore )
// @ts-expect-error No types for this exist yet.
. getEntityRecords ( 'postType' , 'page' , {
per_page : 100 ,
_fields : [ 'id' , '_links.version-history' ] ,
orderby : 'menu_order' ,
order : 'asc' ,
} )
) ? . some ( ( page : { _links : { [ key : string ] : string [ ] } } ) = > {
return page . _links ? . [ 'version-history' ] ? . length > 1 ;
} ) ;
const { getTask } = resolveSelect ( ONBOARDING_STORE_NAME ) ;
const activeThemeHasMods =
currentTemplate ? . modified !== null ||
styleRevs ? . length > 0 ||
hasModifiedPages . length > 0 ;
const customizeStoreTaskCompleted = ( await getTask ( 'customize-store' ) )
? . isComplete ;
const themeCards = await fetchThemeCards ( ) ;
return {
activeThemeHasMods ,
customizeStoreTaskCompleted ,
themeCards ,
} ;
} ;