2020-11-06 01:21:05 +00:00
|
|
|
/**
|
|
|
|
* External dependencies
|
|
|
|
*/
|
|
|
|
import { useSelect } from '@wordpress/data';
|
|
|
|
import { Fragment } from '@wordpress/element';
|
|
|
|
import { Accordion, AccordionPanel } from '@woocommerce/components';
|
2020-11-23 15:06:55 +00:00
|
|
|
import { getSetting } from '@woocommerce/wc-admin-settings';
|
2020-11-06 01:21:05 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Internal dependencies
|
|
|
|
*/
|
|
|
|
import './style.scss';
|
2020-11-25 18:51:15 +00:00
|
|
|
import {
|
|
|
|
getLowStockCount,
|
|
|
|
getOrderStatuses,
|
|
|
|
getUnreadOrders,
|
|
|
|
} from './orders/utils';
|
2020-11-06 01:21:05 +00:00
|
|
|
import { getAllPanels } from './panels';
|
2020-12-02 13:30:39 +00:00
|
|
|
import { getUnapprovedReviews } from './reviews/utils';
|
2020-11-06 01:21:05 +00:00
|
|
|
|
|
|
|
export const ActivityPanel = () => {
|
2020-12-01 12:44:54 +00:00
|
|
|
const panelsData = useSelect( ( select ) => {
|
2020-11-23 15:06:55 +00:00
|
|
|
const totalOrderCount = getSetting( 'orderCount', 0 );
|
2020-11-06 16:50:24 +00:00
|
|
|
const orderStatuses = getOrderStatuses( select );
|
2020-12-02 13:30:39 +00:00
|
|
|
const reviewsEnabled = getSetting( 'reviewsEnabled', 'no' );
|
2020-11-06 16:50:24 +00:00
|
|
|
const countUnreadOrders = getUnreadOrders( select, orderStatuses );
|
2020-11-25 18:51:15 +00:00
|
|
|
const manageStock = getSetting( 'manageStock', 'no' );
|
|
|
|
const countLowStockProducts = getLowStockCount( select );
|
2020-12-02 13:30:39 +00:00
|
|
|
const countUnapprovedReviews = getUnapprovedReviews( select );
|
2020-12-29 16:19:13 +00:00
|
|
|
const publishedProductCount = getSetting( 'publishedProductCount', 0 );
|
2020-11-25 18:51:15 +00:00
|
|
|
|
2020-12-01 12:44:54 +00:00
|
|
|
return {
|
2020-11-25 18:51:15 +00:00
|
|
|
countLowStockProducts,
|
2020-11-23 15:06:55 +00:00
|
|
|
countUnreadOrders,
|
2020-11-25 18:51:15 +00:00
|
|
|
manageStock,
|
2020-11-23 15:06:55 +00:00
|
|
|
orderStatuses,
|
|
|
|
totalOrderCount,
|
2020-12-02 13:30:39 +00:00
|
|
|
reviewsEnabled,
|
|
|
|
countUnapprovedReviews,
|
2020-12-29 16:19:13 +00:00
|
|
|
publishedProductCount,
|
2020-12-01 12:44:54 +00:00
|
|
|
};
|
2020-11-06 01:21:05 +00:00
|
|
|
} );
|
2020-12-01 12:44:54 +00:00
|
|
|
|
|
|
|
const panels = getAllPanels( panelsData );
|
|
|
|
|
2020-12-29 16:19:13 +00:00
|
|
|
if ( panels.length === 0 ) {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
2020-11-06 01:21:05 +00:00
|
|
|
return (
|
|
|
|
<Accordion>
|
|
|
|
<Fragment>
|
|
|
|
{ panels.map( ( panelData ) => {
|
|
|
|
const {
|
|
|
|
className,
|
|
|
|
count,
|
|
|
|
id,
|
|
|
|
initialOpen,
|
|
|
|
panel,
|
|
|
|
title,
|
2020-12-09 20:57:41 +00:00
|
|
|
collapsible,
|
2020-11-06 01:21:05 +00:00
|
|
|
} = panelData;
|
|
|
|
return (
|
|
|
|
<AccordionPanel
|
|
|
|
key={ id }
|
|
|
|
className={ className }
|
|
|
|
count={ count }
|
|
|
|
initialOpen={ initialOpen }
|
|
|
|
title={ title }
|
2020-12-09 20:57:41 +00:00
|
|
|
collapsible={ collapsible }
|
2020-11-06 01:21:05 +00:00
|
|
|
>
|
|
|
|
{ panel }
|
|
|
|
</AccordionPanel>
|
|
|
|
);
|
|
|
|
} ) }
|
|
|
|
</Fragment>
|
|
|
|
</Accordion>
|
|
|
|
);
|
|
|
|
};
|