/**
* External dependencies
*/
import { __ } from '@wordpress/i18n';
import { Component } from 'react';
import PropTypes from 'prop-types';
import { Disabled } from '@wordpress/components';
import { ENABLE_REVIEW_RATING } from '@woocommerce/block-settings';
import ErrorPlaceholder from '@woocommerce/block-components/error-placeholder';
import LoadMoreButton from '@woocommerce/base-components/load-more-button';
import ReviewList from '@woocommerce/base-components/review-list';
import ReviewSortSelect from '@woocommerce/base-components/review-sort-select';
import withReviews from '@woocommerce/base-hocs/with-reviews';
import BlockErrorBoundary from '@woocommerce/base-components/block-error-boundary';
/**
* Block rendered in the editor.
*/
class EditorBlock extends Component {
static propTypes = {
/**
* The attributes for this block.
*/
attributes: PropTypes.object.isRequired,
// from withReviews
reviews: PropTypes.array,
totalReviews: PropTypes.number,
};
render() {
const {
attributes,
error,
isLoading,
noReviewsPlaceholder: NoReviewsPlaceholder,
reviews,
totalReviews,
} = this.props;
if ( error ) {
return (
);
}
if ( reviews.length === 0 && ! isLoading ) {
return ;
}
return (
{ attributes.showOrderby && ENABLE_REVIEW_RATING && (
) }
{ attributes.showLoadMore &&
totalReviews > reviews.length && (
) }
);
}
}
export default withReviews( EditorBlock );