2021-01-28 14:24:01 +00:00
|
|
|
/**
|
|
|
|
* External dependencies
|
|
|
|
*/
|
|
|
|
import classnames from 'classnames';
|
|
|
|
import { useStoreCart } from '@woocommerce/base-hooks';
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Internal dependencies
|
|
|
|
*/
|
2021-02-08 11:37:55 +00:00
|
|
|
import { createSlotFill, useSlot } from '../slot';
|
2021-01-28 14:24:01 +00:00
|
|
|
|
|
|
|
const slotName = '__experimentalOrderShippingPackages';
|
2021-02-08 11:37:55 +00:00
|
|
|
const {
|
|
|
|
Fill: ExperimentalOrderShippingPackages,
|
|
|
|
Slot: OrderShippingPackagesSlot,
|
|
|
|
} = createSlotFill( slotName );
|
2021-01-28 14:24:01 +00:00
|
|
|
|
2021-02-08 11:37:55 +00:00
|
|
|
const Slot = ( { className, collapsible, noResultsMessage, renderOption } ) => {
|
2021-01-28 14:24:01 +00:00
|
|
|
// We need to pluck out receiveCart.
|
|
|
|
// eslint-disable-next-line no-unused-vars
|
|
|
|
const { extensions, receiveCart, ...cart } = useStoreCart();
|
|
|
|
const { fills } = useSlot( slotName );
|
|
|
|
const hasMultiplePackages = fills.length > 1;
|
|
|
|
return (
|
|
|
|
<OrderShippingPackagesSlot
|
|
|
|
className={ classnames(
|
|
|
|
'wc-block-components-shipping-rates-control',
|
|
|
|
className
|
|
|
|
) }
|
|
|
|
fillProps={ {
|
|
|
|
collapsible,
|
|
|
|
collapse: hasMultiplePackages,
|
|
|
|
showItems: hasMultiplePackages,
|
|
|
|
noResultsMessage,
|
|
|
|
renderOption,
|
|
|
|
extensions,
|
|
|
|
cart,
|
|
|
|
} }
|
|
|
|
/>
|
|
|
|
);
|
2021-02-08 11:37:55 +00:00
|
|
|
};
|
2021-01-28 14:24:01 +00:00
|
|
|
|
|
|
|
ExperimentalOrderShippingPackages.Slot = Slot;
|
|
|
|
|
|
|
|
export default ExperimentalOrderShippingPackages;
|