import { Box, Text } from 'ink'; import React from 'react'; import { colors } from '../../config/colors.js'; import { Status } from '../journeys/install-boilerplate/context/types.js'; const areaMap = { media: 'Media', shapes: 'Shapes', grids: 'Grids', items: 'Items', languages: 'Languages', priceVariants: 'Price variants', vatTypes: 'VAT types', topicMaps: 'Topic maps', customers: 'Customers', orders: 'Orders', }; function progressText(progress: number) { const arr: string[] = Array.apply(null, Array(20)).map((_) => '-'); const filled: string[] = Array.apply(null, Array(Math.floor(progress * 20))).map((_) => '='); arr.splice(0, filled.length, ...filled); return arr.join(''); } export const ImportStatus: React.FC<{ status: Status }> = ({ status }) => { return ( <> {Object.keys(status).map((key: string) => { const name = areaMap[key as keyof typeof areaMap] || key; const { progress, warnings } = status[key]; return ( [ {progressText(progress)} ] {' '} {(progress * 100).toFixed(0).padStart(3)}%{' '} {' '} | {' '} {name} {warnings.map((warn: { message: string; code: number }, index: number) => ( ⚠ {warn.message} ({warn.code}) ))} ); })} ); };