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

Commit

Permalink
Convert to tsx and replace proptypes by ts definitions
Browse files Browse the repository at this point in the history
  • Loading branch information
albarin committed Aug 4, 2023
1 parent 6339f97 commit 86a1a86
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -18,7 +18,7 @@ const EditorContainerBlock = ( {
icon,
name,
noReviewsPlaceholder,
} ) => {
}: EditorContainerBlockProps ) => {
const {
categoryIds,
productId,
Expand Down Expand Up @@ -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;
41 changes: 41 additions & 0 deletions assets/js/blocks/reviews/types.ts
Original file line number Diff line number Diff line change
@@ -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;
}

0 comments on commit 86a1a86

Please sign in to comment.