Skip to content
This repository has been archived by the owner on Feb 23, 2024. It is now read-only.

Commit

Permalink
move ShippingCalculatorOptions to outside
Browse files Browse the repository at this point in the history
  • Loading branch information
senadir committed Mar 5, 2020
1 parent f2b7ab4 commit feb9b78
Showing 1 changed file with 44 additions and 32 deletions.
76 changes: 44 additions & 32 deletions assets/js/blocks/cart-checkout/cart/full-cart/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,43 @@ const renderShippingRatesControlOption = ( option ) => ( {
),
} );

const ShippingCalculatorOptions = ( {
shippingRates,
shippingRatesLoading,
shippingAddress,
} ) => {
return (
<fieldset className="wc-block-cart__shipping-options-fieldset">
<legend className="screen-reader-text">
{ __(
'Choose the shipping method.',
'woo-gutenberg-products-block'
) }
</legend>
<ShippingRatesControl
className="wc-block-cart__shipping-options"
address={
shippingAddress
? {
city: shippingAddress.city,
state: shippingAddress.state,
postcode: shippingAddress.postcode,
country: shippingAddress.country,
}
: null
}
noResultsMessage={ __(
'No shipping options were found.',
'woo-gutenberg-products-block'
) }
renderOption={ renderShippingRatesControlOption }
shippingRates={ shippingRates }
shippingRatesLoading={ shippingRatesLoading }
/>
</fieldset>
);
};

/**
* Component that renders the Cart block when user has something in cart aka "full".
*/
Expand Down Expand Up @@ -198,37 +235,6 @@ const Cart = ( {
const totalsCurrency = getCurrencyFromPriceResponse( cartTotals );
const totalRowsConfig = getTotalRowsConfig();

const ShippingCalculatorOptions = () => (
<fieldset className="wc-block-cart__shipping-options-fieldset">
<legend className="screen-reader-text">
{ __(
'Choose the shipping method.',
'woo-gutenberg-products-block'
) }
</legend>
<ShippingRatesControl
className="wc-block-cart__shipping-options"
address={
shippingAddress
? {
city: shippingAddress.city,
state: shippingAddress.state,
postcode: shippingAddress.postcode,
country: shippingAddress.country,
}
: null
}
noResultsMessage={ __(
'No shipping options were found.',
'woo-gutenberg-products-block'
) }
renderOption={ renderShippingRatesControlOption }
shippingRates={ shippingRates }
shippingRatesLoading={ shippingRatesLoading }
/>
</fieldset>
);

const cartClassName = classnames( 'wc-block-cart', {
'wc-block-cart--is-loading': isLoading,
} );
Expand Down Expand Up @@ -270,7 +276,13 @@ const Cart = ( {
'woo-gutenberg-products-block'
) }
</legend>
<ShippingCalculatorOptions />
<ShippingCalculatorOptions
shippingRates={ shippingRates }
shippingRatesLoading={
shippingRatesLoading
}
shippingAddress={ shippingAddress }
/>
</fieldset>
) }
{ ! DISPLAY_CART_PRICES_INCLUDING_TAX && (
Expand Down

0 comments on commit feb9b78

Please sign in to comment.