Skip to content

Commit

Permalink
Code cleaning
Browse files Browse the repository at this point in the history
  • Loading branch information
cbravobernal committed Aug 12, 2022
1 parent 1d422ef commit d48d81a
Show file tree
Hide file tree
Showing 4 changed files with 1 addition and 23 deletions.
2 changes: 0 additions & 2 deletions assets/js/atomic/utils/render-parent-block.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,6 @@ const renderInnerBlocks = ( {
...( node instanceof HTMLElement ? node.dataset : {} ),
className: node instanceof Element ? node?.className : '',
};

const InnerBlockComponent = getBlockComponentFromMap(
blockName,
blockMap
Expand All @@ -181,7 +180,6 @@ const renderInnerBlocks = ( {
node?.textContent ||
''
);

// Returns text nodes without manipulation.
if ( typeof parsedElement === 'string' && !! parsedElement ) {
return parsedElement;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,10 @@ import { TotalsCoupon } from '@woocommerce/base-components/cart-checkout';
import { useStoreCartCoupons } from '@woocommerce/base-context/hooks';
import { getSetting } from '@woocommerce/settings';
import { TotalsWrapper } from '@woocommerce/blocks-checkout';
import { useState } from '@wordpress/element';

const Block = ( { className }: { className: string } ): JSX.Element | null => {
const couponsEnabled = getSetting( 'couponsEnabled', true );

/* Added a temporary setState to easily check hydration */
const [ count, setCount ] = useState( 0 );

const { applyCoupon, isApplyingCoupon } = useStoreCartCoupons( 'wc/cart' );

if ( ! couponsEnabled ) {
Expand All @@ -25,10 +21,6 @@ const Block = ( { className }: { className: string } ): JSX.Element | null => {
onSubmit={ applyCoupon }
isLoading={ isApplyingCoupon }
/>
{ /* Added a temporary button to easily check hydration */ }
<button
onClick={ () => setCount( count + 1 ) }
>{ `Counter update: ${ count }` }</button>
</TotalsWrapper>
);
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
*/
import Title from '@woocommerce/base-components/title';
import classnames from 'classnames';
import { useState } from '@wordpress/element';

const Block = ( {
className,
Expand All @@ -12,16 +11,12 @@ const Block = ( {
className: string;
content: string;
} ): JSX.Element => {
const [ count, setCount ] = useState( 0 );
return (
<Title
headingLevel="2"
className={ classnames( className, 'wc-block-cart__totals-title' ) }
>
{ content }
<button
onClick={ () => setCount( count + 1 ) }
>{ `Counter: ${ count }` }</button>
</Title>
);
};
Expand Down
9 changes: 1 addition & 8 deletions src/BlockTypesController.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
use Automattic\WooCommerce\Blocks\Integrations\IntegrationRegistry;
use Automattic\WooCommerce\Blocks\BlockTypes\Cart;
use Automattic\WooCommerce\Blocks\BlockTypes\Checkout;
use Automattic\WooCommerce\StoreApi\Utilities\NoticeHandler;

/**
* BlockTypesController class.
Expand Down Expand Up @@ -155,11 +154,7 @@ public function block_hydration_wrapper( $block_content, $block, $instance ) {
return $block_content;
}

$block_type = $instance->block_type;
if ( ! $block_type ) {
// We might use a better way to flag it here.
wc_add_notice( 'You need to make a server registration of ' . $block['blockName'], 'error' );
}
$block_type = $instance->block_type;
$attr_definitions = $block_type->attributes;

$attributes = array();
Expand Down Expand Up @@ -306,7 +301,6 @@ protected function get_block_types() {
[
'AllProducts',
'Cart',
'CartOrderSummaryCouponFormBlock',
'Checkout',
]
);
Expand All @@ -321,7 +315,6 @@ protected function get_block_types() {
[
'AllProducts',
'Cart',
'CartOrderSummaryCouponFormBlock',
'Checkout',
]
);
Expand Down

0 comments on commit d48d81a

Please sign in to comment.