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';
|
|
|
|
|
|
|
|
const HISTORICAL_DATA_STATUS_FILTER = 'woocommerce_admin_import_status';
|
|
|
|
|
|
|
|
function HistoricalDataStatus( { importDate, status } ) {
|
2022-02-11 14:38:38 +00:00
|
|
|
/**
|
|
|
|
* Historical data import statuses.
|
|
|
|
*
|
|
|
|
* @filter woocommerce_admin_import_status
|
|
|
|
*
|
2022-03-18 11:45:14 +00:00
|
|
|
* @param {Object} statuses Import statuses.
|
|
|
|
* @param {string} statuses.nothing Nothing to import.
|
|
|
|
* @param {string} statuses.ready Ready to import.
|
|
|
|
* @param {Array} statuses.initializing Initializing string and spinner.
|
|
|
|
* @param {Array} statuses.customers Importing customers string and spinner.
|
|
|
|
* @param {Array} statuses.orders Importing orders string and spinner.
|
|
|
|
* @param {Array} statuses.finalizing Finalizing string and spinner.
|
|
|
|
* @param {string} statuses.finished Message displayed after import.
|
2022-02-11 14:38:38 +00:00
|
|
|
*/
|
2019-05-07 07:18:48 +00:00
|
|
|
const statusLabels = applyFilters( HISTORICAL_DATA_STATUS_FILTER, {
|
2022-03-30 09:00:04 +00:00
|
|
|
nothing: __( 'Nothing To Import', 'woocommerce' ),
|
|
|
|
ready: __( 'Ready To Import', 'woocommerce' ),
|
2020-02-14 02:23:21 +00:00
|
|
|
initializing: [
|
2022-03-30 09:00:04 +00:00
|
|
|
__( 'Initializing', 'woocommerce' ),
|
2020-02-14 02:23:21 +00:00
|
|
|
<Spinner key="spinner" />,
|
|
|
|
],
|
|
|
|
customers: [
|
2022-03-30 09:00:04 +00:00
|
|
|
__( 'Importing Customers', 'woocommerce' ),
|
2020-02-14 02:23:21 +00:00
|
|
|
<Spinner key="spinner" />,
|
|
|
|
],
|
|
|
|
orders: [
|
2022-03-30 09:00:04 +00:00
|
|
|
__( 'Importing Orders', 'woocommerce' ),
|
2020-02-14 02:23:21 +00:00
|
|
|
<Spinner key="spinner" />,
|
|
|
|
],
|
|
|
|
finalizing: [
|
2022-03-30 09:00:04 +00:00
|
|
|
__( 'Finalizing', 'woocommerce' ),
|
2020-02-14 02:23:21 +00:00
|
|
|
<Spinner key="spinner" />,
|
|
|
|
],
|
2020-01-07 12:25:11 +00:00
|
|
|
finished:
|
|
|
|
importDate === -1
|
2022-03-30 09:00:04 +00:00
|
|
|
? __( 'All historical data imported', 'woocommerce' )
|
2020-01-07 12:25:11 +00:00
|
|
|
: sprintf(
|
2023-11-16 11:15:11 +00:00
|
|
|
/* translators: %s: YYYY-MM-DD formatted date */
|
2020-02-14 02:23:21 +00:00
|
|
|
__(
|
|
|
|
'Historical data from %s onward imported',
|
2022-03-30 09:00:04 +00:00
|
|
|
'woocommerce'
|
2020-02-14 02:23:21 +00:00
|
|
|
),
|
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">
|
2022-03-30 09:00:04 +00:00
|
|
|
{ __( 'Status:', 'woocommerce' ) + ' ' }
|
2019-05-07 07:18:48 +00:00
|
|
|
{ statusLabels[ status ] }
|
|
|
|
</span>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2020-08-20 23:14:55 +00:00
|
|
|
export default HistoricalDataStatus;
|