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';
|
|
|
|
|
|
|
|
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 );
|
|
|
|
const countUnreadOrders = getUnreadOrders( select, orderStatuses );
|
2020-11-25 18:51:15 +00:00
|
|
|
const manageStock = getSetting( 'manageStock', 'no' );
|
|
|
|
const countLowStockProducts = getLowStockCount( select );
|
|
|
|
|
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-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-11-06 01:21:05 +00:00
|
|
|
return (
|
|
|
|
<Accordion>
|
|
|
|
<Fragment>
|
|
|
|
{ panels.map( ( panelData ) => {
|
|
|
|
const {
|
|
|
|
className,
|
|
|
|
count,
|
|
|
|
id,
|
|
|
|
initialOpen,
|
|
|
|
panel,
|
|
|
|
title,
|
|
|
|
} = panelData;
|
|
|
|
return (
|
|
|
|
<AccordionPanel
|
|
|
|
key={ id }
|
|
|
|
className={ className }
|
|
|
|
count={ count }
|
|
|
|
initialOpen={ initialOpen }
|
|
|
|
title={ title }
|
|
|
|
>
|
|
|
|
{ panel }
|
|
|
|
</AccordionPanel>
|
|
|
|
);
|
|
|
|
} ) }
|
|
|
|
</Fragment>
|
|
|
|
</Accordion>
|
|
|
|
);
|
|
|
|
};
|