/** * Completion Step - Step 4 of ScanForm creation */ import { Button, Flex, Notice } from '@wordpress/components'; import { __, sprintf } from '@wordpress/i18n'; import { isDomesticShipment, isSafePdfUrl } from 'utils/scan-form'; import type { ScanFormLabel } from 'types'; interface CompletionStepProps { successMessage: string; processedLabelIds: number[]; pdfUrls: string[]; processedLabelBatches: number[][]; partialFailureMessage?: string | null; partialFailureLabelIds?: number[]; getLabelInfo: ( labelId: number ) => ScanFormLabel | null; } export const CompletionStep = ( { successMessage, processedLabelIds, pdfUrls, processedLabelBatches, partialFailureMessage, partialFailureLabelIds, getLabelInfo, }: CompletionStepProps ) => { return ( <> { successMessage } { partialFailureMessage && (

{ partialFailureMessage }

{ partialFailureLabelIds && partialFailureLabelIds.length > 0 && ( ) }
) }
{ __( 'Processed Labels:', 'woocommerce-shipping' ) }
{ pdfUrls.length > 0 && ( { pdfUrls.map( ( url, index ) => { if ( ! isSafePdfUrl( url ) ) { return null; } const batch = processedLabelBatches[ index ] ?? []; const firstLabel = batch.length > 0 ? getLabelInfo( batch[ 0 ] ) : null; const isDomestic = firstLabel ? isDomesticShipment( firstLabel ) : true; const batchLabel = isDomestic ? __( 'Domestic', 'woocommerce-shipping' ) : __( 'International', 'woocommerce-shipping' ); return ( ); } ) } ) } ); };