diff --git a/assets/js/blocks/reviews/editor-container-block.js b/assets/js/blocks/reviews/editor-container-block.tsx similarity index 85% rename from assets/js/blocks/reviews/editor-container-block.js rename to assets/js/blocks/reviews/editor-container-block.tsx index 1d1c0c579b3..621855f79c8 100644 --- a/assets/js/blocks/reviews/editor-container-block.js +++ b/assets/js/blocks/reviews/editor-container-block.tsx @@ -2,10 +2,10 @@ * External dependencies */ import { __ } from '@wordpress/i18n'; -import PropTypes from 'prop-types'; import { debounce } from '@woocommerce/base-utils'; import { Placeholder } from '@wordpress/components'; import { useBlockProps } from '@wordpress/block-editor'; +import { EditorContainerBlockProps } from '@woocommerce/blocks/reviews/types'; /** * Internal dependencies @@ -18,7 +18,7 @@ const EditorContainerBlock = ( { icon, name, noReviewsPlaceholder, -} ) => { +}: EditorContainerBlockProps ) => { const { categoryIds, productId, @@ -70,12 +70,4 @@ const EditorContainerBlock = ( { ); }; -EditorContainerBlock.propTypes = { - attributes: PropTypes.object.isRequired, - icon: PropTypes.node.isRequired, - name: PropTypes.string.isRequired, - noReviewsPlaceholder: PropTypes.elementType.isRequired, - className: PropTypes.string, -}; - export default EditorContainerBlock; diff --git a/assets/js/blocks/reviews/types.ts b/assets/js/blocks/reviews/types.ts new file mode 100644 index 00000000000..c205a25ee16 --- /dev/null +++ b/assets/js/blocks/reviews/types.ts @@ -0,0 +1,41 @@ +export interface PreviewReviews { + id: number; + date_created: string; + formatted_date_created: string; + date_created_gmt: string; + product_id: number; + product_name: string; + product_permalink: string; + reviewer: string; + review: string; + reviewer_avatar_urls: { [ id: number ]: string }; + rating: number; + verified: boolean; +} + +export interface Attributes { + categoryIds: number[]; + editMode: boolean; + imageType: string; + orderby: string; + productId: number; + reviewsOnLoadMore: number; + reviewsOnPageLoad: number; + showLoadMore: boolean; + showOrderby: boolean; + showProductName: boolean; + showReviewDate: boolean; + showReviewerName: boolean; + showReviewImage: boolean; + showReviewRating: boolean; + showReviewContent: boolean; + previewReviews: PreviewReviews[]; +} + +export interface EditorContainerBlockProps { + attributes: Attributes; + icon: JSX.Element; + name: string; + noReviewsPlaceholder: React.ReactNode; + className?: string; +}