Convert product-orderby-control to use typescript (https://github.com/woocommerce/woocommerce-blocks/pull/9751)
This commit is contained in:
parent
27ba84cd84
commit
bb60a90f5c
|
@ -3,7 +3,11 @@
|
|||
*/
|
||||
import { __ } from '@wordpress/i18n';
|
||||
import { SelectControl } from '@wordpress/components';
|
||||
import PropTypes from 'prop-types';
|
||||
|
||||
/**
|
||||
* Internal dependencies
|
||||
*/
|
||||
import type { ProductOrderbyControlProps } from './types';
|
||||
|
||||
/**
|
||||
* A pre-configured SelectControl for product orderby settings.
|
||||
|
@ -12,7 +16,10 @@ import PropTypes from 'prop-types';
|
|||
* @param {string} props.value
|
||||
* @param {function(any):any} props.setAttributes Setter for block attributes.
|
||||
*/
|
||||
const ProductOrderbyControl = ( { value, setAttributes } ) => {
|
||||
const ProductOrderbyControl = ( {
|
||||
value,
|
||||
setAttributes,
|
||||
}: ProductOrderbyControlProps ) => {
|
||||
return (
|
||||
<SelectControl
|
||||
label={ __( 'Order products by', 'woo-gutenberg-products-block' ) }
|
||||
|
@ -70,15 +77,4 @@ const ProductOrderbyControl = ( { value, setAttributes } ) => {
|
|||
);
|
||||
};
|
||||
|
||||
ProductOrderbyControl.propTypes = {
|
||||
/**
|
||||
* Callback to update the order setting.
|
||||
*/
|
||||
setAttributes: PropTypes.func.isRequired,
|
||||
/**
|
||||
* The selected order setting.
|
||||
*/
|
||||
value: PropTypes.string.isRequired,
|
||||
};
|
||||
|
||||
export default ProductOrderbyControl;
|
|
@ -0,0 +1,4 @@
|
|||
export interface ProductOrderbyControlProps {
|
||||
value: string;
|
||||
setAttributes: ( attributes: Record< string, unknown > ) => void;
|
||||
}
|
Loading…
Reference in New Issue