import { IconCheck, IconX } from '@tabler/icons-react' /** * ProgressBar - компонент прогресс бара с estimated time * @param {number} progress - прогресс от 0 до 100 * @param {string} status - статус операции * @param {number} estimatedTime - оставшееся время в секундах * @param {string} variant - цвет: 'primary', 'success', 'danger', 'warning' */ function ProgressBar({ progress = 0, status = '', estimatedTime = null, variant = 'primary', showPercentage = true, striped = false, animated = false, size = 'default' // 'sm', 'default', 'lg' }) { const sizeClass = size === 'sm' ? 'progress-sm' : size === 'lg' ? 'progress-lg' : '' const stripedClass = striped ? 'progress-bar-striped' : '' const animatedClass = animated ? 'progress-bar-animated' : '' const formatTime = (seconds) => { if (seconds < 60) { return `${Math.round(seconds)} сек` } else if (seconds < 3600) { const minutes = Math.floor(seconds / 60) const secs = Math.round(seconds % 60) return `${minutes} мин ${secs} сек` } else { const hours = Math.floor(seconds / 3600) const minutes = Math.floor((seconds % 3600) / 60) return `${hours} ч ${minutes} мин` } } return (
{status && (
{status}
)}
{estimatedTime !== null && estimatedTime > 0 && ( Осталось ~{formatTime(estimatedTime)} )} {showPercentage && ( {Math.round(progress)}% )}
{size === 'lg' && showPercentage && ( {Math.round(progress)}% )}
) } /** * MultiStepProgress - компонент для отображения многошагового прогресса */ function MultiStepProgress({ steps, currentStep, variant = 'primary' }) { const progress = ((currentStep) / steps.length) * 100 return (
{/* Индикаторы шагов */}
{steps.map((step, index) => { const isPast = index < currentStep const isCurrent = index === currentStep const status = isPast ? 'completed' : isCurrent ? 'current' : 'pending' return (
{isPast ? ( ) : ( {index + 1} )}
{step}
{index < steps.length - 1 && (
)}
) })}
{/* Прогресс бар */}
) } export { ProgressBar, MultiStepProgress } export default ProgressBar