Update `PackageRates` component to show single rates as a radio button (#46284)
* Show a single shipping option as radio button * Add changelog * Update unused dependency
This commit is contained in:
parent
7d41472206
commit
ab60527d6b
|
@ -2,10 +2,7 @@
|
|||
* External dependencies
|
||||
*/
|
||||
import { useState, useEffect } from '@wordpress/element';
|
||||
import {
|
||||
RadioControl,
|
||||
RadioControlOptionLayout,
|
||||
} from '@woocommerce/blocks-components';
|
||||
import { RadioControl } from '@woocommerce/blocks-components';
|
||||
import type { CartShippingPackageShippingRate } from '@woocommerce/types';
|
||||
import { usePrevious } from '@woocommerce/base-hooks';
|
||||
|
||||
|
@ -71,31 +68,17 @@ const PackageRates = ( {
|
|||
return noResultsMessage;
|
||||
}
|
||||
|
||||
if ( rates.length > 1 ) {
|
||||
return (
|
||||
<RadioControl
|
||||
className={ className }
|
||||
onChange={ ( value: string ) => {
|
||||
setSelectedOption( value );
|
||||
onSelectRate( value );
|
||||
} }
|
||||
highlightChecked={ highlightChecked }
|
||||
disabled={ disabled }
|
||||
selected={ selectedOption }
|
||||
options={ rates.map( renderOption ) }
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
const { label, secondaryLabel, description, secondaryDescription } =
|
||||
renderOption( rates[ 0 ] );
|
||||
|
||||
return (
|
||||
<RadioControlOptionLayout
|
||||
label={ label }
|
||||
secondaryLabel={ secondaryLabel }
|
||||
description={ description }
|
||||
secondaryDescription={ secondaryDescription }
|
||||
<RadioControl
|
||||
className={ className }
|
||||
onChange={ ( value: string ) => {
|
||||
setSelectedOption( value );
|
||||
onSelectRate( value );
|
||||
} }
|
||||
highlightChecked={ highlightChecked }
|
||||
disabled={ disabled }
|
||||
selected={ selectedOption }
|
||||
options={ rates.map( renderOption ) }
|
||||
/>
|
||||
);
|
||||
};
|
||||
|
|
|
@ -0,0 +1,4 @@
|
|||
Significance: minor
|
||||
Type: update
|
||||
|
||||
Ensure consistent styling for single shipping methods in the Checkout block
|
Loading…
Reference in New Issue