2018-10-17 18:56:50 +00:00
|
|
|
/**
|
|
|
|
* External dependencies
|
|
|
|
*/
|
|
|
|
import { __ } from '@wordpress/i18n';
|
|
|
|
import PropTypes from 'prop-types';
|
|
|
|
import { EmptyContent } from '@woocommerce/components';
|
|
|
|
|
2018-12-22 11:46:10 +00:00
|
|
|
/**
|
|
|
|
* Component to render when there is an error in a report component due to data
|
|
|
|
* not being loaded or being invalid.
|
2021-06-01 10:07:35 +00:00
|
|
|
*
|
2022-03-18 11:45:14 +00:00
|
|
|
* @param {Object} props React props.
|
2021-06-01 10:07:35 +00:00
|
|
|
* @param {string} [props.className] Additional class name to style the component.
|
2018-12-22 11:46:10 +00:00
|
|
|
*/
|
2021-06-01 10:07:35 +00:00
|
|
|
function ReportError( { className } ) {
|
|
|
|
const title = __(
|
|
|
|
'There was an error getting your stats. Please try again.',
|
2022-03-30 09:00:04 +00:00
|
|
|
'woocommerce'
|
2021-06-01 10:07:35 +00:00
|
|
|
);
|
2022-03-30 09:00:04 +00:00
|
|
|
const actionLabel = __( 'Reload', 'woocommerce' );
|
2021-06-01 10:07:35 +00:00
|
|
|
const actionCallback = () => {
|
|
|
|
// @todo Add tracking for how often an error is displayed, and the reload action is clicked.
|
|
|
|
window.location.reload();
|
|
|
|
};
|
|
|
|
return (
|
|
|
|
<EmptyContent
|
|
|
|
className={ className }
|
|
|
|
title={ title }
|
|
|
|
actionLabel={ actionLabel }
|
|
|
|
actionCallback={ actionCallback }
|
|
|
|
/>
|
|
|
|
);
|
2018-10-17 18:56:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
ReportError.propTypes = {
|
2018-12-22 11:46:10 +00:00
|
|
|
/**
|
|
|
|
* Additional class name to style the component.
|
|
|
|
*/
|
2018-11-01 17:15:53 +00:00
|
|
|
className: PropTypes.string,
|
|
|
|
};
|
|
|
|
|
2018-10-17 18:56:50 +00:00
|
|
|
export default ReportError;
|