This repository was archived by the owner on Feb 23, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 221
/
Copy pathindex.tsx
85 lines (81 loc) · 2.41 KB
/
index.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
// /**
// * External dependencies
// */
// import { createHigherOrderComponent } from '@wordpress/compose';
// import {
// BlockControls,
// store as blockEditorStore,
// } from '@wordpress/block-editor';
// import { addFilter, hasFilter } from '@wordpress/hooks';
// import { filledCart, removeCart } from '@woocommerce/icons';
// import { Icon } from '@wordpress/icons';
// import { __ } from '@wordpress/i18n';
// import { useSelect } from '@wordpress/data';
// import { EditorProvider, useEditorContext } from '@woocommerce/base-context';
// /**
// * Internal dependencies
// */
// import { useViewSwitcher } from '../../cart-checkout-shared';
// import { previewCart } from '@woocommerce/resource-previews';
// const cartViews = [
// {
// view: 'woocommerce/filled-cart-block',
// label: __( 'Filled Cart', 'woo-gutenberg-products-block' ),
// icon: <Icon icon={ filledCart } />,
// },
// {
// view: 'woocommerce/empty-cart-block',
// label: __( 'Empty Cart', 'woo-gutenberg-products-block' ),
// icon: <Icon icon={ removeCart } />,
// },
// ];
// interface View {
// view: string;
// label: string;
// icon: string | JSX.Element;
// }
// const withViewSwitcher = createHigherOrderComponent(
// ( BlockEdit ) => ( props ) => {
// const { clientId } = props;
// const { currentView, setCurrentView } = useEditorContext();
// const onViewChange = ( view: View ) => {
// console.log( 'it is working' );
// setCurrentView( view );
// };
// const { component: ViewSwitcherComponent } = useViewSwitcher(
// clientId,
// cartViews,
// onViewChange
// );
// const { isCartBlock } = useSelect( ( select ) => {
// const { getBlockName } = select( blockEditorStore );
// const currentBlockName = getBlockName( clientId );
// return {
// isCartBlock: currentBlockName === 'woocommerce/cart',
// };
// } );
// console.log( isCartBlock );
// return (
// <>
// <EditorProvider
// currentView={ currentView }
// previewData={ { previewCart } }
// >
// { ! isCartBlock && (
// <BlockControls>{ ViewSwitcherComponent }</BlockControls>
// ) }
// <BlockEdit { ...props } />
// </EditorProvider>
// </>
// );
// },
// 'withViewSwitcher'
// );
// if ( ! hasFilter( 'editor.BlockEdit', 'woocommerce/add/cart-view-switcher' ) ) {
// addFilter(
// 'editor.BlockEdit',
// 'woocommerce/add/cart-view-switcher',
// withViewSwitcher,
// 11
// );
// }