2022-08-03 17:42:22 +00:00
|
|
|
/**
|
|
|
|
* External dependencies
|
|
|
|
*/
|
|
|
|
import { recordEvent } from '@woocommerce/tracks';
|
2023-01-19 08:52:02 +00:00
|
|
|
import { useSelect } from '@wordpress/data';
|
2022-08-03 17:42:22 +00:00
|
|
|
import { useEffect } from '@wordpress/element';
|
2023-01-19 08:52:02 +00:00
|
|
|
import { Spinner } from '@wordpress/components';
|
|
|
|
import {
|
|
|
|
EXPERIMENTAL_PRODUCT_FORM_STORE_NAME,
|
|
|
|
WCDataSelector,
|
|
|
|
} from '@woocommerce/data';
|
2022-08-03 17:42:22 +00:00
|
|
|
|
2022-08-04 13:15:30 +00:00
|
|
|
/**
|
|
|
|
* Internal dependencies
|
|
|
|
*/
|
2022-12-05 20:46:21 +00:00
|
|
|
import { ProductForm } from './product-form';
|
2023-01-18 19:11:02 +00:00
|
|
|
import { ProductTourContainer } from './tour';
|
2023-05-18 08:25:36 +00:00
|
|
|
import './add-edit-product-page.scss';
|
2023-01-19 08:52:02 +00:00
|
|
|
import './fills';
|
2022-08-04 13:15:30 +00:00
|
|
|
|
|
|
|
const AddProductPage: React.FC = () => {
|
2023-01-19 08:52:02 +00:00
|
|
|
const { isLoading } = useSelect( ( select: WCDataSelector ) => {
|
|
|
|
const { hasFinishedResolution: hasProductFormFinishedResolution } =
|
|
|
|
select( EXPERIMENTAL_PRODUCT_FORM_STORE_NAME );
|
|
|
|
return {
|
|
|
|
isLoading: ! hasProductFormFinishedResolution( 'getProductForm' ),
|
|
|
|
};
|
|
|
|
} );
|
2022-08-03 17:42:22 +00:00
|
|
|
useEffect( () => {
|
|
|
|
recordEvent( 'view_new_product_management_experience' );
|
|
|
|
}, [] );
|
2022-08-11 14:04:14 +00:00
|
|
|
|
2022-08-03 17:42:22 +00:00
|
|
|
return (
|
|
|
|
<div className="woocommerce-add-product">
|
2023-01-19 08:52:02 +00:00
|
|
|
{ isLoading ? (
|
|
|
|
<div className="woocommerce-edit-product__spinner">
|
|
|
|
<Spinner />
|
|
|
|
</div>
|
|
|
|
) : (
|
|
|
|
<>
|
|
|
|
<ProductForm />
|
|
|
|
<ProductTourContainer />
|
|
|
|
</>
|
|
|
|
) }
|
2022-08-03 17:42:22 +00:00
|
|
|
</div>
|
|
|
|
);
|
|
|
|
};
|
2022-08-04 13:15:30 +00:00
|
|
|
|
|
|
|
export default AddProductPage;
|