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

Commit

Permalink
Merge pull request #2488 from woocommerce/fix/table-ext-error
Browse files Browse the repository at this point in the history
Table extension: fix page error and jsDoc
  • Loading branch information
psealock authored Jun 25, 2019
2 parents 34ec9de + 0aedae5 commit df0fb82
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
2 changes: 1 addition & 1 deletion client/analytics/components/report-table/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ class ReportTable extends Component {
* @param {array} reportTableData.rows - table rows data.
* @param {object} reportTableData.totals - total aggregates for request.
* @param {array} reportTableData.summary - summary numbers data.
* @param {array} reportTableData.items - response from api requerst.
* @param {object} reportTableData.items - response from api requerst.
*/
const { headers, ids, rows, summary } = applyFilters( TABLE_FILTER, {
endpoint,
Expand Down
11 changes: 9 additions & 2 deletions docs/examples/extensions/table-column/js/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,12 @@ import { addFilter } from '@wordpress/hooks';
import { Rating } from '@woocommerce/components';

addFilter( 'woocommerce_admin_report_table', 'plugin-domain', reportTableData => {
if ( 'products' !== reportTableData.endpoint || ! reportTableData.items.data.length ) {
if (
'products' !== reportTableData.endpoint ||
! reportTableData.items ||
! reportTableData.items.data ||
! reportTableData.items.data.length
) {
return reportTableData;
}

Expand All @@ -33,7 +38,9 @@ addFilter( 'woocommerce_admin_report_table', 'plugin-domain', reportTableData =>
},
// average_rating can be found on extended_info on productData.
{
display: <Rating rating={ Number( product.extended_info.average_rating ) } totalStars={ 5 } />,
display: (
<Rating rating={ Number( product.extended_info.average_rating ) } totalStars={ 5 } />
),
value: product.extended_info.average_rating,
},
];
Expand Down

0 comments on commit df0fb82

Please sign in to comment.