Update experimental-import-products to load sample products

This commit is contained in:
Chi-Hsuan Huang 2022-05-04 10:35:15 +08:00
parent cf9d2ed3b7
commit 7e4126bc9f
1 changed files with 15 additions and 1 deletions

View File

@ -7,7 +7,8 @@ import { __ } from '@wordpress/i18n';
import { Icon, chevronUp, chevronDown } from '@wordpress/icons';
import { Button } from '@wordpress/components';
import { useState } from '@wordpress/element';
import { find } from 'lodash';
import { getAdminLink } from '@woocommerce/settings';
/**
* Internal dependencies
*/
@ -17,14 +18,26 @@ import { importTypes } from './importTypes';
import './style.scss';
import useProductTypeListItems from '../experimental-products/use-product-types-list-items';
import { getProductTypes } from '../experimental-products/utils';
import LoadSampleProductModal from '../components/load-sample-product-modal';
import useLoadSampleProducts from '../components/use-load-sample-products';
const Products = () => {
const [ showStacks, setStackVisibility ] = useState< boolean >( false );
const {
loadSampleProduct,
isLoadingSampleProducts,
} = useLoadSampleProducts( {
redirectUrlAfterSuccess: getAdminLink(
'edit.php?post_type=product&wc_onboarding_active_task=products'
),
} );
const StacksComponent = (
<Stacks
items={ useProductTypeListItems(
getProductTypes( [ 'subscription' ] )
) }
onClickLoadSampleProduct={ loadSampleProduct }
/>
);
return (
@ -38,6 +51,7 @@ const Products = () => {
</Button>
{ showStacks && StacksComponent }
</div>
{ isLoadingSampleProducts && <LoadSampleProductModal /> }
</div>
);
};