2020-05-27 14:45:18 +00:00
|
|
|
/**
|
|
|
|
* External dependencies
|
|
|
|
*/
|
|
|
|
import { withProduct } from '@woocommerce/block-hocs';
|
2020-06-05 12:18:16 +00:00
|
|
|
import {
|
|
|
|
InnerBlockLayoutContextProvider,
|
|
|
|
ProductDataContextProvider,
|
|
|
|
} from '@woocommerce/shared-context';
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Internal dependencies
|
|
|
|
*/
|
|
|
|
import { BLOCK_NAME } from './constants';
|
2020-05-27 14:45:18 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* The Single Product Block.
|
|
|
|
*/
|
2020-06-05 12:18:16 +00:00
|
|
|
const Block = ( { isLoading, product, children } ) => {
|
2020-07-22 12:20:54 +00:00
|
|
|
const className = 'wc-block-single-product wc-block-layout';
|
2020-06-05 12:18:16 +00:00
|
|
|
|
|
|
|
return (
|
|
|
|
<InnerBlockLayoutContextProvider
|
|
|
|
parentName={ BLOCK_NAME }
|
|
|
|
parentClassName={ className }
|
|
|
|
>
|
2020-07-22 12:20:54 +00:00
|
|
|
<ProductDataContextProvider
|
|
|
|
product={ product }
|
|
|
|
isLoading={ isLoading }
|
|
|
|
>
|
2020-06-05 12:18:16 +00:00
|
|
|
<div className={ className }>{ children }</div>
|
|
|
|
</ProductDataContextProvider>
|
|
|
|
</InnerBlockLayoutContextProvider>
|
|
|
|
);
|
2020-05-27 14:45:18 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
export default withProduct( Block );
|