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:
Nathan Silveira 2023-04-28 16:15:10 -03:00 committed by GitHub
parent 6fde831921
commit 8fc6972161
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 22 additions and 6 deletions

View File

@ -0,0 +1,3 @@
Significance: patch
Type: fix
Comment: Handle request with empty stats in performance-indicators report

View File

@ -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 >;

View File

@ -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;
};

View File

@ -88,8 +88,5 @@ export const StatsList = ( {
};
export default withSelect( ( select, { stats, query } ) => {
if ( stats.length === 0 ) {
return;
}
return getIndicatorData( select, stats, query );
} )( StatsList );

View File

@ -0,0 +1,5 @@
Significance: patch
Type: fix
Comment: Remove if statement that caused stats not to be loaded on certain scenarios