2019-05-07 07:18:48 +00:00
|
|
|
/**
|
|
|
|
* External dependencies
|
|
|
|
*/
|
|
|
|
import { __, sprintf } from '@wordpress/i18n';
|
|
|
|
import { applyFilters } from '@wordpress/hooks';
|
|
|
|
import moment from 'moment';
|
|
|
|
import { Spinner } from '@wordpress/components';
|
|
|
|
import { useFilters } from '@woocommerce/components';
|
|
|
|
|
|
|
|
const HISTORICAL_DATA_STATUS_FILTER = 'woocommerce_admin_import_status';
|
|
|
|
|
|
|
|
function HistoricalDataStatus( { importDate, status } ) {
|
|
|
|
const statusLabels = applyFilters( HISTORICAL_DATA_STATUS_FILTER, {
|
2019-06-11 12:47:53 +00:00
|
|
|
nothing: __( 'Nothing To Import', 'woocommerce-admin' ),
|
2019-05-07 07:18:48 +00:00
|
|
|
ready: __( 'Ready To Import', 'woocommerce-admin' ),
|
2020-02-14 02:23:21 +00:00
|
|
|
initializing: [
|
|
|
|
__( 'Initializing', 'woocommerce-admin' ),
|
|
|
|
<Spinner key="spinner" />,
|
|
|
|
],
|
|
|
|
customers: [
|
|
|
|
__( 'Importing Customers', 'woocommerce-admin' ),
|
|
|
|
<Spinner key="spinner" />,
|
|
|
|
],
|
|
|
|
orders: [
|
|
|
|
__( 'Importing Orders', 'woocommerce-admin' ),
|
|
|
|
<Spinner key="spinner" />,
|
|
|
|
],
|
|
|
|
finalizing: [
|
|
|
|
__( 'Finalizing', 'woocommerce-admin' ),
|
|
|
|
<Spinner key="spinner" />,
|
|
|
|
],
|
2020-01-07 12:25:11 +00:00
|
|
|
finished:
|
|
|
|
importDate === -1
|
|
|
|
? __( 'All historical data imported', 'woocommerce-admin' )
|
|
|
|
: sprintf(
|
2020-02-14 02:23:21 +00:00
|
|
|
__(
|
|
|
|
'Historical data from %s onward imported',
|
|
|
|
'woocommerce-admin'
|
|
|
|
),
|
2020-01-07 12:25:11 +00:00
|
|
|
// @todo The date formatting should be localized ( 'll' ), but this is currently broken in Gutenberg.
|
|
|
|
// See https://github.com/WordPress/gutenberg/issues/12626 for details.
|
|
|
|
moment( importDate ).format( 'YYYY-MM-DD' )
|
2020-02-14 02:23:21 +00:00
|
|
|
),
|
2019-05-07 07:18:48 +00:00
|
|
|
} );
|
|
|
|
|
|
|
|
return (
|
|
|
|
<span className="woocommerce-settings-historical-data__status">
|
|
|
|
{ __( 'Status:', 'woocommerce-admin' ) + ' ' }
|
|
|
|
{ statusLabels[ status ] }
|
|
|
|
</span>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2020-02-14 02:23:21 +00:00
|
|
|
export default useFilters( HISTORICAL_DATA_STATUS_FILTER )(
|
|
|
|
HistoricalDataStatus
|
|
|
|
);
|