Fix N/A displayed on re-enabling toggles for "Stats overview" panel after refreshing "Woocommerce > Home" page. (#38030)
* Fix N/A on stats overview on WooCommerce > Home * Add changelogs * Fix wrongfully added type definition
This commit is contained in:
parent
6fde831921
commit
8fc6972161
|
@ -0,0 +1,3 @@
|
|||
Significance: patch
|
||||
Type: fix
|
||||
Comment: Handle request with empty stats in performance-indicators report
|
|
@ -51,6 +51,15 @@ export function* getReportItems(
|
|||
path: addQueryArgs( `${ NAMESPACE }/reports/${ endpoint }`, query ),
|
||||
};
|
||||
|
||||
if ( endpoint === 'performance-indicators' && ! query.stats ) {
|
||||
yield setReportItems( endpoint, query, {
|
||||
data: [],
|
||||
totalResults: 0,
|
||||
totalPages: 0,
|
||||
} );
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
const response: {
|
||||
headers: Map< string, string >;
|
||||
|
|
|
@ -13,7 +13,7 @@ export type ReportItemsEndpoint =
|
|||
| 'coupons'
|
||||
| 'stock'
|
||||
| 'downloads'
|
||||
| 'performance_indicator';
|
||||
| 'performance-indicators';
|
||||
|
||||
export type ReportStatEndpoint =
|
||||
| 'products'
|
||||
|
@ -24,7 +24,9 @@ export type ReportStatEndpoint =
|
|||
| 'coupons'
|
||||
| 'customers';
|
||||
|
||||
export type ReportQueryParams = ReturnType< typeof getReportTableQuery >;
|
||||
export type ReportQueryParams = ReturnType< typeof getReportTableQuery > & {
|
||||
stats?: string;
|
||||
};
|
||||
export type ReportStatQueryParams = ReturnType< typeof getRequestQuery >;
|
||||
|
||||
export type CustomerReport = {
|
||||
|
@ -325,7 +327,7 @@ export type ReportItemObject = {
|
|||
| DownloadReport
|
||||
| OrderReport
|
||||
| CategoriesReport
|
||||
| PerformanceIndicatorReport;
|
||||
| PerformanceIndicatorReport[];
|
||||
totalResults: number;
|
||||
totalPages: number;
|
||||
};
|
||||
|
|
|
@ -88,8 +88,5 @@ export const StatsList = ( {
|
|||
};
|
||||
|
||||
export default withSelect( ( select, { stats, query } ) => {
|
||||
if ( stats.length === 0 ) {
|
||||
return;
|
||||
}
|
||||
return getIndicatorData( select, stats, query );
|
||||
} )( StatsList );
|
||||
|
|
|
@ -0,0 +1,5 @@
|
|||
Significance: patch
|
||||
Type: fix
|
||||
Comment: Remove if statement that caused stats not to be loaded on certain scenarios
|
||||
|
||||
|
Loading…
Reference in New Issue