import { ProgressBar } from '@wordpress/components';
import { __, sprintf, _n } from '@wordpress/i18n';
import { Icon, check, error as errorIcon } from '@wordpress/icons';
import type { OrderRow, OrderProgressStatus } from './types';
import { assertNever, orderLabel } from './helpers';
interface ProgressViewProps {
rows: OrderRow[];
}
const renderStatusIcon = ( status: OrderProgressStatus ) => {
switch ( status ) {
case 'succeeded':
return ;
case 'failed':
return ;
case 'pending':
return (
);
default:
return assertNever( status );
}
};
const renderStatusLabel = ( status: OrderProgressStatus ): string => {
switch ( status ) {
case 'succeeded':
return __( 'Label created', 'woocommerce-shipping' );
case 'failed':
return __( 'Failed', 'woocommerce-shipping' );
case 'pending':
return __( 'Waiting…', 'woocommerce-shipping' );
default:
return assertNever( status );
}
};
export const ProgressView = ( { rows }: ProgressViewProps ) => {
const total = rows.length;
const settled = rows.filter( ( r ) => r.status !== 'pending' ).length;
const percent = total > 0 ? Math.round( ( settled / total ) * 100 ) : 0;
const progressLabel = sprintf(
/* translators: 1: number of orders processed, 2: total order count */
__( 'Processed %1$d of %2$d orders.', 'woocommerce-shipping' ),
settled,
total
);
return (
{ __( 'Creating labels…', 'woocommerce-shipping' ) }
{ progressLabel }
{ /*
* `
` renders a native `
);
};